svn commit: samba r4372 - in branches/SAMBA_4_0/source/rpc_server/samr: .

Stefan (metze) Metzmacher metze at samba.org
Mon Dec 27 07:16:13 GMT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

vlendec at samba.org schrieb:
| Author: vlendec
| Date: 2004-12-26 23:31:19 +0000 (Sun, 26 Dec 2004)
| New Revision: 4372

Hi Volker,

one little comment...

| Changeset:
| Modified: branches/SAMBA_4_0/source/rpc_server/samr/dcesrv_samr.c
| ===================================================================
| --- branches/SAMBA_4_0/source/rpc_server/samr/dcesrv_samr.c	2004-12-26 22:41:38 UTC (rev 4371)
| +++ branches/SAMBA_4_0/source/rpc_server/samr/dcesrv_samr.c	2004-12-26 23:31:19 UTC (rev 4372)
| @@ -1065,7 +1065,73 @@
|  static NTSTATUS samr_LookupRids(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
|  		       struct samr_LookupRids *r)
|  {
| -	DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
| +	struct dcesrv_handle *h;
| +	struct samr_domain_state *d_state;
| +	int i;
| +	NTSTATUS status = NT_STATUS_OK;
| +
| +	ZERO_STRUCT(r->out.names);
| +	ZERO_STRUCT(r->out.types);
| +
| +	DCESRV_PULL_HANDLE(h, r->in.domain_handle, SAMR_HANDLE_DOMAIN);
| +
| +	d_state = h->data;
| +
| +	if (r->in.num_rids == 0)
| +		return NT_STATUS_OK;
| +
| +	r->out.names.names = talloc_array_p(mem_ctx, struct samr_String,
| +					    r->in.num_rids);
| +	if (r->out.names.names == NULL)
| +		return NT_STATUS_NO_MEMORY;
| +
| +	r->out.types.ids = talloc_array_p(mem_ctx, uint32_t, r->in.num_rids);
| +	if (r->out.types.ids == NULL)
| +		return NT_STATUS_NO_MEMORY;

if we would fail here we would return the uninitialized r->out.names.names array.
I mostly use local var's for names and ids, and set the out values at the end of the function.
with that we don't need ugly error initialization in the error pathes.

Btw: it's good to see you working on samba 4 code :-)
| +	r->out.names.count = r->in.num_rids;
| +	r->out.types.count = r->in.num_rids;
| +
| +	for (i=0; i<r->in.num_rids; i++) {
| +		struct ldb_message **res;
| +		int count;
| +		const char * const attrs[] = { 	"sAMAccountType",
| +						"sAMAccountName", NULL };
| +		struct samr_String *str;
| +		uint32_t atype;
| +
| +		str = &r->out.names.names[i];
| +
| +		ZERO_STRUCTP(str);
| +		r->out.types.ids[i] = 0;
| +
| +		count = samdb_search(d_state->sam_ctx, mem_ctx,
| +				     d_state->domain_dn, &res, attrs,
| +				     "(objectSid=%s-%u)", d_state->domain_sid,
| +				     r->in.rids[i]);
| +		if (count != 1) {
| +			status = STATUS_SOME_UNMAPPED;
| +			continue;
| +		}
| +
| +		str->string = samdb_result_string(res[0], "sAMAccountName",
| +						  NULL);
| +		
| +		atype = samdb_result_uint(res[0], "sAMAccountType", 0);
| +		if (atype == 0) {
| +			status = STATUS_SOME_UNMAPPED;
| +			continue;
| +		}
| +
| +		r->out.types.ids[i] = samdb_atype_map(atype);
| +		
| +		if (r->out.types.ids[i] == SID_NAME_UNKNOWN) {
| +			status = STATUS_SOME_UNMAPPED;
| +			continue;
| +		}
| +	}
| +	
| +	return status;
|  }

- --
metze

Stefan Metzmacher <metze at samba.org> www.samba.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3-nr1 (Windows XP)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBz7a9m70gjA5TCD8RAq8AAKDP9LFXR+ATFeMhaO/KlP79zdmGsQCeKwOV
/sDAlKui9cDZD/bBrfAb0bU=
=aeTI
-----END PGP SIGNATURE-----


More information about the samba-technical mailing list