Fwd: [PATCHES] simple gpo patches fixes

Douglas Bagnall douglas.bagnall at catalyst.net.nz
Fri Apr 13 00:43:14 UTC 2018


hi David,

On 13/04/18 01:27, David Mulder via samba-technical wrote:
> I've fixed the couple of issues you mentioned and re-pushed. Thanks!
> 

Unfortunately there is more to fix, which I didn't notice before because
I distracted by the other things:

> +static PyObject *py_check_refresh_gpo_list(PyObject * self,
> +					   PyObject * args)
> +{
> +	TALLOC_CTX *frame = talloc_stackframe();
> +	ADS *ads = NULL;
> +	const char *cache_dir = NULL;
> +	struct GROUP_POLICY_OBJECT *gpo_ptr = NULL;
> +	PyObject *gpo_list = NULL;
> +	PyObject *gpo_obj = NULL;
> +	NTSTATUS status;
> +	PyObject *ret = NULL;
> +
> +	if (!PyArg_ParseTuple(args, "OO|s", &ads, &gpo_list, &cache_dir)) {
> +		goto out;
> +	}
> +	gpo_obj = PyList_GetItem(gpo_list, 0);
> +	if (!gpo_obj) {
> +		goto out;
> +	}
> +	gpo_ptr = (struct GROUP_POLICY_OBJECT *)pytalloc_get_ptr(gpo_obj);

This is wrong. If the object supplied to the python function is not a
GPO object, nothing good will come of this. You need to check the type
of gpo_obj, with something like this

	ret = PyObject_TypeCheck(gpo_obj, &GPOType);
	if (! ret) {
               error
        }

or use py_check_dcerpc_type().

Douglas

> +
> +	if (!cache_dir) {
> +		cache_dir = cache_path(GPO_CACHE_DIR);
> +		if (!cache_dir) {
> +			PyErr_SetString(PyExc_MemoryError,
> +				"Failed to determine gpo cache dir");
> +			goto out;
> +		}
> +	}
> +
> +	status = check_refresh_gpo_list(ads->ads_ptr, frame, cache_dir, 0,
> +					gpo_ptr);
> +	if (!NT_STATUS_IS_OK(status)) {
> +		PyErr_SetNTSTATUS(status);
> +		goto out;
> +	}
> +
> +	ret = Py_True;
> +out:
> +	TALLOC_FREE(frame);
> +	return ret;
> +}
> +
>  /* Global methods aka do not need a special pyobject type */
>  static PyObject *py_gpo_get_sysvol_gpt_versi




More information about the samba-technical mailing list