Fwd: [PATCHES] simple gpo patches fixes

David Mulder dmulder at suse.com
Fri Apr 13 12:44:24 UTC 2018



On 04/12/2018 06:43 PM, Douglas Bagnall wrote:
> 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().
Good point. And by the way, the reason for extracting the gpo_ptr from
the front of the list is due to the way we transform the linked list
into a python list in py_ads_get_gpo_list().
>
> 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
>

-- 
David Mulder
SUSE Labs Software Engineer - Samba
dmulder at suse.com
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)




More information about the samba-technical mailing list