summaryrefslogtreecommitdiff
path: root/lib/uid_wrapper
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-08-05 13:31:06 +1000
committerAndrew Tridgell <tridge@samba.org>2009-08-05 13:32:04 +1000
commitd40537c92a9ad7535b90218f289c35f039d03b0c (patch)
tree82c6ae372ed0573b729a04193652e697beb7c530 /lib/uid_wrapper
parentcd1d7f4be7d31388ab79c797acaf6d7730113112 (diff)
downloadsamba-d40537c92a9ad7535b90218f289c35f039d03b0c.tar.gz
samba-d40537c92a9ad7535b90218f289c35f039d03b0c.tar.bz2
samba-d40537c92a9ad7535b90218f289c35f039d03b0c.zip
fixed a uid_wrapper bug that caused a segv in the RAW-ACLS test
Diffstat (limited to 'lib/uid_wrapper')
-rw-r--r--lib/uid_wrapper/uid_wrapper.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/uid_wrapper/uid_wrapper.c b/lib/uid_wrapper/uid_wrapper.c
index 948ff65b35..f7f04316bf 100644
--- a/lib/uid_wrapper/uid_wrapper.c
+++ b/lib/uid_wrapper/uid_wrapper.c
@@ -42,6 +42,10 @@ static void uwrap_init(void)
uwrap.initialised = true;
if (getenv("UID_WRAPPER")) {
uwrap.enabled = true;
+ /* put us in one group */
+ uwrap.ngroups = 1;
+ uwrap.groups = talloc_array(talloc_autofree_context(), gid_t, 1);
+ uwrap.groups[0] = 0;
}
}
@@ -101,14 +105,17 @@ _PUBLIC_ int uwrap_setgroups(size_t size, const gid_t *list)
talloc_free(uwrap.groups);
uwrap.ngroups = 0;
-
- uwrap.groups = talloc_array(talloc_autofree_context(), gid_t, size);
- if (uwrap.groups == NULL) {
- errno = ENOMEM;
- return -1;
+ uwrap.groups = NULL;
+
+ if (size != 0) {
+ uwrap.groups = talloc_array(talloc_autofree_context(), gid_t, size);
+ if (uwrap.groups == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+ memcpy(uwrap.groups, list, size*sizeof(gid_t));
+ uwrap.ngroups = size;
}
- memcpy(uwrap.groups, list, size*sizeof(gid_t));
- uwrap.ngroups = size;
return 0;
}
@@ -130,7 +137,7 @@ _PUBLIC_ int uwrap_getgroups(int size, gid_t *list)
return -1;
}
memcpy(list, uwrap.groups, size*sizeof(gid_t));
- return 0;
+ return uwrap.ngroups;
}
_PUBLIC_ uid_t uwrap_getuid(void)