@@ -207,7 +207,7 @@ def install_isolate():
207207 assert_root ()
208208 root = pwd .getpwnam ("root" )
209209 try :
210- cmsuser_grp = grp .getgrnam ( CMSUSER )
210+ cmsuser_grp = grp .getgrgid ( pwd . getpwnam ( CMSUSER ). pw_gid )
211211 except :
212212 print ("[Error] The user %s doesn't exist yet" % CMSUSER )
213213 print ("[Error] You need to run the install command at least once" )
@@ -279,22 +279,15 @@ def install():
279279 # Get real user to run non-sudo commands
280280 real_user = get_real_user ()
281281
282- try :
283- cmsuser_gr = grp .getgrnam (CMSUSER )
284- except KeyError :
285- print ("===== Creating group %s" % CMSUSER )
286- subprocess .check_call (["groupadd" , CMSUSER , "--system" ])
287- cmsuser_gr = grp .getgrnam (CMSUSER )
288-
289282 try :
290283 cmsuser_pw = pwd .getpwnam (CMSUSER )
291284 except KeyError :
292285 print ("===== Creating user %s" % CMSUSER )
293286 subprocess .check_call (["useradd" , CMSUSER , "--system" ,
294287 "--comment" , "CMS default user" ,
295- "--shell" , "/bin/false" , "--no-create-home" ,
296- "--no-user-group" , "--gid" , CMSUSER ])
288+ "--shell" , "/bin/false" , "-U" ])
297289 cmsuser_pw = pwd .getpwnam (CMSUSER )
290+ cmsuser_gr = grp .getgrgid (cmsuser_pw .pw_gid )
298291
299292 root_pw = pwd .getpwnam ("root" )
300293
@@ -338,18 +331,19 @@ def install():
338331 os .umask (old_umask )
339332
340333 if real_user != "root" :
341- print ("===== Adding yourself to the %s group" % CMSUSER )
334+ gr_name = cmsuser_gr .gr_name
335+ print ("===== Adding yourself to the %s group" % gr_name )
342336 if ask ("Type Y if you want me to automatically add "
343- "\" %s\" to the %s group: " % (real_user , CMSUSER )):
344- subprocess .check_call (["usermod" , "-a" , "-G" , CMSUSER , real_user ])
337+ "\" %s\" to the %s group: " % (real_user , gr_name )):
338+ subprocess .check_call (["usermod" , "-a" , "-G" , gr_name , real_user ])
345339 print ("""
346340###########################################################################
347341### ###
348342### Remember that you must now logout in order to make the change ###
349343### effective ("the change" is: being in the %s group). ###
350344### ###
351345###########################################################################
352- """ % CMSUSER )
346+ """ % gr_name )
353347 else :
354348 print ("""
355349###########################################################################
@@ -361,7 +355,7 @@ def install():
361355### You must also logout to make the change effective. ###
362356### ###
363357###########################################################################
364- """ % (CMSUSER , CMSUSER ))
358+ """ % (gr_name , gr_name ))
365359
366360
367361def uninstall ():
@@ -407,7 +401,8 @@ def uninstall():
407401 if ask ("Do you want to delete user %s? [y/N] " % CMSUSER ):
408402 subprocess .check_call (["userdel" , CMSUSER ])
409403 try :
410- # Just to check whether it exists.
404+ # Just to check whether it exists. If CMSUSER had a different primary
405+ # group, we'll do nothing here.
411406 grp .getgrnam (CMSUSER )
412407 except KeyError :
413408 pass
0 commit comments