1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-27 03:21:53 +03:00

Try to support non-root-mode systems without getgrouplist().

Andrew Bartlett
This commit is contained in:
Andrew Bartlett 0001-01-01 00:00:00 +00:00
parent a613dde7ed
commit 17096315a0
3 changed files with 15 additions and 8 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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) {