summaryrefslogtreecommitdiff
path: root/source3/groupdb/mapping.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2004-02-02 01:46:30 +0000
committerGerald Carter <jerry@samba.org>2004-02-02 01:46:30 +0000
commita870ff546ce9128e3bf8bb3ddc88f5eeb98d2eda (patch)
tree9e2f27eb92aa97692268818a5d3ae4a921f53c13 /source3/groupdb/mapping.c
parent152e2282164069d63dde7b15f96d637db5a25245 (diff)
downloadsamba-a870ff546ce9128e3bf8bb3ddc88f5eeb98d2eda.tar.gz
samba-a870ff546ce9128e3bf8bb3ddc88f5eeb98d2eda.tar.bz2
samba-a870ff546ce9128e3bf8bb3ddc88f5eeb98d2eda.zip
janitor duty (merges from 3.0) and cleanup compiler warning on SuSE 9 in the end mapper code
(This used to be commit 902d4a647a88d1def09d5b1eacb06ab1561f3dec)
Diffstat (limited to 'source3/groupdb/mapping.c')
-rw-r--r--source3/groupdb/mapping.c74
1 files changed, 44 insertions, 30 deletions
diff --git a/source3/groupdb/mapping.c b/source3/groupdb/mapping.c
index 97abbd46e3..048a6c5db0 100644
--- a/source3/groupdb/mapping.c
+++ b/source3/groupdb/mapping.c
@@ -701,10 +701,12 @@ BOOL get_group_from_gid(gid_t gid, GROUP_MAP *map)
BOOL get_sid_list_of_group(gid_t gid, DOM_SID **sids, int *num_sids)
{
struct group *grp;
- struct passwd *pwd;
int i=0;
char *gr;
DOM_SID *s;
+
+ struct sys_pwent *userlist;
+ struct sys_pwent *user;
if(!init_group_mapping()) {
DEBUG(0,("failed to initialize group mapping"));
@@ -751,41 +753,53 @@ BOOL get_sid_list_of_group(gid_t gid, DOM_SID **sids, int *num_sids)
winbind_off();
- setpwent();
- while ((pwd=getpwent()) != NULL) {
- if (pwd->pw_gid==gid) {
- SAM_ACCOUNT *group_member_acct = NULL;
- BOOL found_user;
- s = Realloc((*sids), sizeof(**sids)*(*num_sids+1));
- if (!s) {
- DEBUG(0,("get_sid_list_of_group: unable to enlarge SID list!\n"));
- winbind_on();
- return False;
- }
- else (*sids) = s;
+ user = userlist = getpwent_list();
+
+ while (user != NULL) {
+
+ SAM_ACCOUNT *group_member_acct = NULL;
+ BOOL found_user;
+
+ if (user->pw_gid != gid) {
+ user = user->next;
+ continue;
+ }
+
+ s = Realloc((*sids), sizeof(**sids)*(*num_sids+1));
+ if (!s) {
+ DEBUG(0,("get_sid_list_of_group: unable to enlarge "
+ "SID list!\n"));
+ pwent_free(userlist);
+ winbind_on();
+ return False;
+ }
+ else (*sids) = s;
- if (!NT_STATUS_IS_OK(pdb_init_sam(&group_member_acct))) {
- continue;
- }
+ if (!NT_STATUS_IS_OK(pdb_init_sam(&group_member_acct))) {
+ continue;
+ }
- become_root();
- found_user = pdb_getsampwnam(group_member_acct, pwd->pw_name);
- unbecome_root();
+ become_root();
+ found_user = pdb_getsampwnam(group_member_acct, user->pw_name);
+ unbecome_root();
- if (found_user) {
- sid_copy(&(*sids)[*num_sids], pdb_get_user_sid(group_member_acct));
+ if (found_user) {
+ sid_copy(&(*sids)[*num_sids],
+ pdb_get_user_sid(group_member_acct));
+ (*num_sids)++;
+ } else {
+ DEBUG(4,("get_sid_list_of_group: User %s [uid == %lu] "
+ "has no samba account\n",
+ user->pw_name, (unsigned long)user->pw_uid));
+ if (algorithmic_uid_to_sid(&(*sids)[*num_sids],
+ user->pw_uid))
(*num_sids)++;
- } else {
- DEBUG(4,("get_sid_list_of_group: User %s [uid == %lu] has no samba account\n",
- pwd->pw_name, (unsigned long)pwd->pw_uid));
- if (algorithmic_uid_to_sid(&(*sids)[*num_sids], pwd->pw_uid))
- (*num_sids)++;
- }
-
- pdb_free_sam(&group_member_acct);
}
+ pdb_free_sam(&group_member_acct);
+
+ user = user->next;
}
- endpwent();
+ pwent_free(userlist);
DEBUG(10, ("got primary groups, members: [%d]\n", *num_sids));
winbind_on();