summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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) {