From 12640a12e266e3530854956c71ff7136e22830b5 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Wed, 10 May 2006 16:04:16 +0000
Subject: [PATCH] svn merge -r7979:7997
 https://eris.llnl.gov/svn/slurm/branches/slurm-1.0

---
 NEWS                          |  8 ++++++++
 src/slurmctld/partition_mgr.c | 37 ++++++++++++++---------------------
 2 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/NEWS b/NEWS
index fc19dfc33a7..fb6e95a9916 100644
--- a/NEWS
+++ b/NEWS
@@ -115,16 +115,24 @@ documents those changes that are of interest to users and admins.
  -- Remove some use of cr_enabled flag in slurmctld job record, use 
     new flag "test_only" in select_g_job_test() instead.
 
+* Changes in SLURM 1.0.13
+=========================
+ -- Fix for AllowGroups option to work when the /etc/group file doesn't 
+    contain all users in group by adding the uids of the names in /etc/passwd
+    that have a gid of that which we are looking for.
+
 * Changes in SLURM 1.0.12
 =========================
  -- Report node state of DRAIN rather than DOWN if DOWN with DRAIN flag set.
  -- Initialize job->mail_type to 0 (NONE) for job submission.
  -- Fix for stalled task stdout/stderr when buffered I/O is used, and
     a single line exceeds 4096 bytes.
+ -- Memory leak fixes for maui plugin (hjcao@nudt.edu.cn)
  -- Fix for spinning srun when the terminal to which srun is talking
     goes away.
  -- Don't set avail_node_bitmap for DRAINED nodes on slurmctld reconfig
     (can schedule a job on drained node after reconfig).
+ 
 
 * Changes in SLURM 1.0.11
 =========================
diff --git a/src/slurmctld/partition_mgr.c b/src/slurmctld/partition_mgr.c
index 28c07ef6d7b..9a9a3a31d35 100644
--- a/src/slurmctld/partition_mgr.c
+++ b/src/slurmctld/partition_mgr.c
@@ -973,7 +973,7 @@ uid_t *_get_group_members(char *group_name)
 {
 	struct group *group_struct_ptr;
 	struct passwd *user_pw_ptr;
-	int i, j;
+	int i, j, offset = 1;
 	uid_t *group_uids = NULL;
 	int uid_cnt = 0;
 
@@ -989,25 +989,11 @@ uid_t *_get_group_members(char *group_name)
 		if (group_struct_ptr->gr_mem[i] == NULL)
 			break;
 	}
-	uid_cnt = i;
-
-	/* 
-	   if uid_cnt is 0 we will add the gid as a uid 
-	   this seems to be a problem with standard linux systems
-	   if a user is added to the system it will not be added to 
-	   the /etc/group file as a user inside it's own group
-	*/
-	if(uid_cnt)
-		j = uid_cnt;
-	else
-		j = 1;
 
-	group_uids = (uid_t *) xmalloc(sizeof(uid_t) * (j + 1));
-	memset(group_uids, 0, (sizeof(uid_t) * (j + 1)));
+	uid_cnt = i;
+	group_uids = (uid_t *) xmalloc(sizeof(uid_t) * (uid_cnt + 1));
+	memset(group_uids, 0, (sizeof(uid_t) * (uid_cnt + 1)));
 	
-	if(!uid_cnt) {
-		group_uids[0] = group_struct_ptr->gr_gid;
-	}
 	j = 0;
 	for (i = 0; i < uid_cnt; i++) {
 		user_pw_ptr = getpwnam(group_struct_ptr->gr_mem[i]);
@@ -1015,12 +1001,19 @@ uid_t *_get_group_members(char *group_name)
 			if (user_pw_ptr->pw_uid)
 				group_uids[j++] = user_pw_ptr->pw_uid;
 		} else
-			error
-			    ("Could not find user %s in configured group %s",
-			     group_struct_ptr->gr_mem[i], group_name);
+			error("Could not find user %s in configured group %s",
+			      group_struct_ptr->gr_mem[i], group_name);
 		setpwent();
 	}
-
+	
+	while((user_pw_ptr = getpwent())) {
+		if(user_pw_ptr->pw_gid != group_struct_ptr->gr_gid)
+			continue;
+		j++;
+		xrealloc(group_uids, ((j+1) * sizeof(uid_t)));
+		group_uids[j-1] = user_pw_ptr->pw_uid;		
+	}
+	setpwent();
 	setgrent();
 	return group_uids;
 }
-- 
GitLab