From 54ca86ac56272de13d374bee9e6c0289177e4899 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Fri, 5 May 2006 17:02:51 +0000
Subject: [PATCH] fix for user not being in it's own group.  gid is now added
 as a uid to partitions with Allowgroups set

---
 src/slurmctld/partition_mgr.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/slurmctld/partition_mgr.c b/src/slurmctld/partition_mgr.c
index d4147808a0c..28c07ef6d7b 100644
--- a/src/slurmctld/partition_mgr.c
+++ b/src/slurmctld/partition_mgr.c
@@ -991,9 +991,23 @@ uid_t *_get_group_members(char *group_name)
 	}
 	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 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)));
 	
+	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]);
-- 
GitLab