pidl uid_t and gid_t

Stefan (metze) Metzmacher metze at samba.org
Tue Mar 1 00:40:45 MST 2011


Am 01.03.2011 08:37, schrieb Andrew Bartlett:
> On Tue, 2011-03-01 at 08:33 +0100, Stefan (metze) Metzmacher wrote:
>> Hi Andrew,
>>
>>> commit 646aefd998c1af366dcaee6cbc2bad9359a71f45
>>> Author: Andrew Bartlett <abartlet at samba.org>
>>> Date:   Fri Feb 11 18:45:32 2011 +1100
>>>
>>>     pidl Add support for uid_t and gid_t types
>>>     
>>>     These are mapped to uint64_t, which should be big enough.  This is
>>>     proposed to be used for internal Samba representations, where it would
>>>     be more painful to convert all the callers to an uint64_t calling
>>>     convention.
>>>     
>>>     Andrew Bartlett
>>
>>> +/*
>>> +  push a gid_t
>>> +*/
>>> +_PUBLIC_ enum ndr_err_code ndr_push_gid_t(struct ndr_push *ndr, int ndr_flags, gid_t g)
>>> +{
>>> +	return ndr_push_udlong(ndr, NDR_SCALARS, (uint64_t)g);
>>> +}
>>> +
>>> +/*
>>> +  pull a gid_t
>>> +*/
>>> +_PUBLIC_ enum ndr_err_code ndr_pull_gid_t(struct ndr_pull *ndr, int ndr_flags, gid_t *g)
>>> +{
>>> +	uint64_t gg;
>>> +	NDR_CHECK(ndr_pull_udlong(ndr, ndr_flags, &gg));
>>> +	*g = (gid_t)gg;
>>> +	if (unlikely(gg != *g)) {
>>> +		DEBUG(0,(__location__ ": gid_t pull doesn't fit 0x%016llx\n",
>>> +			 (unsigned long long)gg));
>>> +		return NDR_ERR_NDR64;
>>> +	}
>>> +	return NDR_ERR_SUCCESS;
>>> +}
>>> +
>>> +
>>> +/*
>>>    pull a ipv4address
>>>  */
>>>  _PUBLIC_ enum ndr_err_code ndr_pull_ipv4address(struct ndr_pull *ndr, int ndr_flags, const char **address)
>>> @@ -1050,6 +1100,16 @@ _PUBLIC_ void ndr_print_time_t(struct ndr_print *ndr, const char *name, time_t t
>>>  	}
>>>  }
>>>  
>>> +_PUBLIC_ void ndr_print_uid_t(struct ndr_print *ndr, const char *name, uid_t u)
>>> +{
>>> +	ndr_print_dlong(ndr, name, u);
>>> +}
>>> +
>>> +_PUBLIC_ void ndr_print_gid_t(struct ndr_print *ndr, const char *name, gid_t g)
>>> +{
>>> +	ndr_print_dlong(ndr, name, g);
>>> +}
>>> +
>>>  _PUBLIC_ void ndr_print_union(struct ndr_print *ndr, const char *name, int level, const char *type)
>>>  {
>>>  	if (ndr->flags & LIBNDR_PRINT_ARRAY_HEX) {
>>> diff --git a/pidl/lib/Parse/Pidl/NDR.pm b/pidl/lib/Parse/Pidl/NDR.pm
>>> index 3edb9b7..5ade5c1 100644
>>> --- a/pidl/lib/Parse/Pidl/NDR.pm
>>> +++ b/pidl/lib/Parse/Pidl/NDR.pm
>>> @@ -66,6 +66,8 @@ my $scalar_alignment = {
>>>  	'string' => 4,
>>>  	'string_array' => 4, #???
>>>  	'time_t' => 4,
>>> +	'uid_t' => 8,
>>> +	'gid_t' => 8,
>>>  	'NTTIME' => 4,
>>>  	'NTTIME_1sec' => 4,
>>>  	'NTTIME_hyper' => 8,
>>
>> udlong aligns to 4 byte and not to 8 as hyper would do.
> 
> Thanks.  I guess it would be better to map it to a hyper then?

Sounds good

metze

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20110301/58f37a28/attachment.pgp>


More information about the samba-technical mailing list