summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2002-08-26 00:43:06 +0000
committerAndrew Bartlett <abartlet@samba.org>2002-08-26 00:43:06 +0000
commit9c7742727a03daa486d77a4ae5f7c4314ced6ad4 (patch)
treeb1d301b2b4fa2a8e15aac97592199950627a8a8d /source3
parent014792fc03c9d4030794e4e06fb137cd2ce32b17 (diff)
downloadsamba-9c7742727a03daa486d77a4ae5f7c4314ced6ad4.tar.gz
samba-9c7742727a03daa486d77a4ae5f7c4314ced6ad4.tar.bz2
samba-9c7742727a03daa486d77a4ae5f7c4314ced6ad4.zip
Try to support non-root-mode systems without getgrouplist().
Andrew Bartlett (This used to be commit 17096315a0f30f946ddecb79708604a111c37011)
Diffstat (limited to 'source3')
-rw-r--r--source3/auth/auth_sam.c2
-rw-r--r--source3/auth/auth_util.c16
-rw-r--r--source3/lib/system_smbd.c5
3 files changed, 15 insertions, 8 deletions
diff --git a/source3/auth/auth_sam.c b/source3/auth/auth_sam.c
index 58def0567a..ca611c46b9 100644
--- a/source3/auth/auth_sam.c
+++ b/source3/auth/auth_sam.c
@@ -404,7 +404,7 @@ static NTSTATUS check_sam_security(const struct auth_context *auth_context,
}
if (!NT_STATUS_IS_OK(nt_status = make_server_info_sam(server_info, sampass))) {
- DEBUG(0,("failed to malloc memory for server_info ret: %s\n", nt_errstr(nt_status)));
+ DEBUG(0,("check_sam_security: make_server_info_sam() failed with '%s'\n", nt_errstr(nt_status)));
return nt_status;
}
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
index 210c4d09f9..118126a275 100644
--- a/source3/auth/auth_util.c
+++ b/source3/auth/auth_util.c
@@ -643,7 +643,7 @@ static NTSTATUS get_user_groups_from_local_sam(const DOM_SID *user_sid,
}
if (sys_getgrouplist(usr->pw_name, usr->pw_gid, *unix_groups, &n_unix_groups) == -1) {
- *unix_groups = realloc(unix_groups, sizeof(gid_t) * n_unix_groups);
+ *unix_groups = Realloc(unix_groups, sizeof(gid_t) * n_unix_groups);
if (sys_getgrouplist(usr->pw_name, usr->pw_gid, *unix_groups, &n_unix_groups) == -1) {
DEBUG(0, ("get_user_groups_from_local_sam: failed to get the unix group list\n"));
SAFE_FREE(unix_groups);
@@ -657,12 +657,14 @@ static NTSTATUS get_user_groups_from_local_sam(const DOM_SID *user_sid,
DEBUG(5,("get_user_groups_from_local_sam: user is in the unix following groups\n"));
for (i = 0; i < n_unix_groups; i++)
DEBUGADD(5,("supplementary group gid:%ld\n",(long int)(*unix_groups)[i]));
-
- *groups = malloc(sizeof(DOM_SID) * n_unix_groups);
- if (!*groups) {
- DEBUG(0, ("get_user_group_from_local_sam: malloc() failed for DOM_SID list!\n"));
- SAFE_FREE(unix_groups);
- return NT_STATUS_NO_MEMORY;
+
+ if (n_unix_groups > 0) {
+ *groups = malloc(sizeof(DOM_SID) * n_unix_groups);
+ if (!*groups) {
+ DEBUG(0, ("get_user_group_from_local_sam: malloc() failed for DOM_SID list!\n"));
+ SAFE_FREE(unix_groups);
+ return NT_STATUS_NO_MEMORY;
+ }
}
*n_groups = n_unix_groups;
diff --git a/source3/lib/system_smbd.c b/source3/lib/system_smbd.c
index 580ef8a463..5eda37d903 100644
--- a/source3/lib/system_smbd.c
+++ b/source3/lib/system_smbd.c
@@ -41,6 +41,11 @@ static int getgrouplist_internals(const char *user, gid_t gid, gid_t *groups, in
gid_t *gids_saved;
int ret, ngrp_saved;
+ if (non_root_mode()) {
+ *grpcnt = 0;
+ return 0;
+ }
+
/* work out how many groups we need to save */
ngrp_saved = getgroups(0, NULL);
if (ngrp_saved == -1) {