svn commit: samba r20150 - in branches/SAMBA_3_0/source:
nsswitch script/tests
simo
idra at samba.org
Wed Dec 13 16:42:30 GMT 2006
Opss I didn't mean to commit the last file in this commit, but that
should remove a warning we have in using samba4 smbtroture anyway, so
I'll not revert unless the build farm becomes unhappy.
Simo.
On Wed, 2006-12-13 at 16:39 +0000, idra at samba.org wrote:
> Author: idra
> Date: 2006-12-13 16:39:50 +0000 (Wed, 13 Dec 2006)
> New Revision: 20150
>
> WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20150
>
> Log:
>
> better memory handling for some functions, make sure we don't
> leak memory by using the wrong(long lived) mem context
>
>
> Modified:
> branches/SAMBA_3_0/source/nsswitch/idmap_rid.c
> branches/SAMBA_3_0/source/nsswitch/winbindd_async.c
> branches/SAMBA_3_0/source/nsswitch/winbindd_group.c
> branches/SAMBA_3_0/source/nsswitch/winbindd_util.c
> branches/SAMBA_3_0/source/script/tests/selftest.sh
>
>
> Changeset:
> Modified: branches/SAMBA_3_0/source/nsswitch/idmap_rid.c
> ===================================================================
> --- branches/SAMBA_3_0/source/nsswitch/idmap_rid.c 2006-12-13 11:19:51 UTC (rev 20149)
> +++ branches/SAMBA_3_0/source/nsswitch/idmap_rid.c 2006-12-13 16:39:50 UTC (rev 20150)
> @@ -81,12 +81,12 @@
> return ret;
> }
>
> -static NTSTATUS idmap_rid_id_to_sid(struct idmap_rid_context *ctx, struct id_map *map)
> +static NTSTATUS idmap_rid_id_to_sid(TALLOC_CTX *memctx, struct idmap_rid_context *ctx, struct id_map *map)
> {
> char *domname, *name;
> enum lsa_SidType sid_type;
>
> - if (!ctx || !map) {
> + if (!memctx || !ctx || !map) {
> return NT_STATUS_INVALID_PARAMETER;
> }
>
> @@ -99,7 +99,7 @@
>
> sid_compose(map->sid, &ctx->dom_sid, map->xid.id - ctx->low_id + ctx->base_rid);
>
> - if (winbindd_lookup_name_by_sid(ctx, map->sid, &domname, &name, &sid_type)) {
> + if (winbindd_lookup_name_by_sid(memctx, map->sid, &domname, &name, &sid_type)) {
> switch (sid_type) {
> case SID_NAME_USER:
> if (map->xid.type != ID_TYPE_UID) {
> @@ -136,13 +136,13 @@
> Single sid to id lookup function.
> **********************************/
>
> -static NTSTATUS idmap_rid_sid_to_id(struct idmap_rid_context *ctx, struct id_map *map)
> +static NTSTATUS idmap_rid_sid_to_id(TALLOC_CTX *memctx, struct idmap_rid_context *ctx, struct id_map *map)
> {
> char *domname, *name;
> enum lsa_SidType sid_type;
> uint32_t rid;
>
> - if (!ctx || !map) {
> + if (!memctx || !ctx || !map) {
> return NT_STATUS_INVALID_PARAMETER;
> }
>
> @@ -150,7 +150,7 @@
> map->xid.id = rid - ctx->base_rid + ctx->low_id;
>
> /* check if this is a valid SID and set the type */
> - if (winbindd_lookup_name_by_sid(ctx, map->sid, &domname, &name, &sid_type)) {
> + if (winbindd_lookup_name_by_sid(memctx, map->sid, &domname, &name, &sid_type)) {
> switch (sid_type) {
> case SID_NAME_USER:
> map->xid.type = ID_TYPE_UID;
> @@ -188,17 +188,24 @@
>
> static NTSTATUS idmap_rid_unixids_to_sids(struct idmap_domain *dom, struct id_map **ids)
> {
> - struct idmap_rid_context *ctx;
> + struct idmap_rid_context *ridctx;
> + TALLOC_CTX *ctx;
> NTSTATUS ret;
> int i;
>
> - ctx = talloc_get_type(dom->private_data, struct idmap_rid_context);
> + ridctx = talloc_get_type(dom->private_data, struct idmap_rid_context);
>
> + ctx = talloc_new(dom);
> + if ( ! ctx) {
> + DEBUG(0, ("Out of memory!\n"));
> + return NT_STATUS_NO_MEMORY;
> + }
> +
> for (i = 0; ids[i]; i++) {
> /* make sure it is marked as unmapped before resolveing */
> ids[i]->mapped = False;
>
> - ret = idmap_rid_id_to_sid(ctx, ids[i]);
> + ret = idmap_rid_id_to_sid(ctx, ridctx, ids[i]);
>
> if (( ! NT_STATUS_IS_OK(ret)) &&
> ( ! NT_STATUS_EQUAL(ret, NT_STATUS_NONE_MAPPED))) {
> @@ -207,6 +214,7 @@
> }
> }
>
> + talloc_free(ctx);
> return NT_STATUS_OK;
> }
>
> @@ -216,17 +224,24 @@
>
> static NTSTATUS idmap_rid_sids_to_unixids(struct idmap_domain *dom, struct id_map **ids)
> {
> - struct idmap_rid_context *ctx;
> + struct idmap_rid_context *ridctx;
> + TALLOC_CTX *ctx;
> NTSTATUS ret;
> int i;
>
> - ctx = talloc_get_type(dom->private_data, struct idmap_rid_context);
> + ridctx = talloc_get_type(dom->private_data, struct idmap_rid_context);
>
> + ctx = talloc_new(dom);
> + if ( ! ctx) {
> + DEBUG(0, ("Out of memory!\n"));
> + return NT_STATUS_NO_MEMORY;
> + }
> +
> for (i = 0; ids[i]; i++) {
> /* make sure it is marked as unmapped before resolveing */
> ids[i]->mapped = False;
>
> - ret = idmap_rid_sid_to_id(ctx, ids[i]);
> + ret = idmap_rid_sid_to_id(ctx, ridctx, ids[i]);
>
> if (( ! NT_STATUS_IS_OK(ret)) &&
> ( ! NT_STATUS_EQUAL(ret, NT_STATUS_NONE_MAPPED))) {
> @@ -236,6 +251,7 @@
> }
> }
>
> + talloc_free(ctx);
> return NT_STATUS_OK;
> }
>
>
> Modified: branches/SAMBA_3_0/source/nsswitch/winbindd_async.c
> ===================================================================
> --- branches/SAMBA_3_0/source/nsswitch/winbindd_async.c 2006-12-13 11:19:51 UTC (rev 20149)
> +++ branches/SAMBA_3_0/source/nsswitch/winbindd_async.c 2006-12-13 16:39:50 UTC (rev 20150)
> @@ -738,8 +738,8 @@
> {
> enum lsa_SidType type;
> DOM_SID sid;
> - char *name = NULL;
> - char *dom_name = NULL;
> + char *name;
> + char *dom_name;
>
> /* Ensure null termination */
> state->request.data.sid[sizeof(state->request.data.sid)-1]='\0';
>
> Modified: branches/SAMBA_3_0/source/nsswitch/winbindd_group.c
> ===================================================================
> --- branches/SAMBA_3_0/source/nsswitch/winbindd_group.c 2006-12-13 11:19:51 UTC (rev 20149)
> +++ branches/SAMBA_3_0/source/nsswitch/winbindd_group.c 2006-12-13 16:39:50 UTC (rev 20150)
> @@ -442,8 +442,8 @@
> {
> struct winbindd_domain *domain;
> enum lsa_SidType name_type;
> - char *dom_name = NULL;
> - char *group_name = NULL;
> + char *dom_name;
> + char *group_name;
> size_t gr_mem_len;
> size_t num_gr_mem;
> char *gr_mem;
>
> Modified: branches/SAMBA_3_0/source/nsswitch/winbindd_util.c
> ===================================================================
> --- branches/SAMBA_3_0/source/nsswitch/winbindd_util.c 2006-12-13 11:19:51 UTC (rev 20149)
> +++ branches/SAMBA_3_0/source/nsswitch/winbindd_util.c 2006-12-13 16:39:50 UTC (rev 20150)
> @@ -718,6 +718,9 @@
> NTSTATUS result;
> struct winbindd_domain *domain;
>
> + *dom_name = NULL;
> + *name = NULL;
> +
> domain = find_lookup_domain_from_sid(sid);
>
> if (!domain) {
> @@ -736,7 +739,6 @@
> }
>
> *type = SID_NAME_UNKNOWN;
> - *name = talloc_strdup(mem_ctx, name_deadbeef);
>
> return False;
> }
>
> Modified: branches/SAMBA_3_0/source/script/tests/selftest.sh
> ===================================================================
> --- branches/SAMBA_3_0/source/script/tests/selftest.sh 2006-12-13 11:19:51 UTC (rev 20149)
> +++ branches/SAMBA_3_0/source/script/tests/selftest.sh 2006-12-13 16:39:50 UTC (rev 20150)
> @@ -95,8 +95,6 @@
> log file = $LOGDIR/log.%m
> log level = 0
>
> - passdb backend = tdbsam
> -
> name resolve order = bcast
> EOF
>
> @@ -108,6 +106,8 @@
> interfaces = $TORTURE_INTERFACES
> panic action = $SCRIPTDIR/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
> include = $COMMONCONFFILE
> +
> + passdb backend = tdbsam
> EOF
>
> cat >$SAMBA4CONFFILE<<EOF
> @@ -126,6 +126,8 @@
> panic action = $SCRIPTDIR/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
> include = $COMMONCONFFILE
>
> + passdb backend = tdbsam
> +
> ; Necessary to add the build farm hacks
> add user script = /bin/false
> add machine script = /bin/false
--
Simo Sorce
Samba Team GPL Compliance Officer
email: idra at samba.org
http://samba.org
More information about the samba-technical
mailing list