mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Handle the case where the DS group exists but the user does not
If the group exists but the user doesn't then useradd blows up trying to create the user and group. So test to see if the group exists and if it does pass along the -g argument to useradd. Resolves #502960
This commit is contained in:
committed by
Jason Gerard DeRose
parent
4216a627c3
commit
53d1cf1644
@@ -21,6 +21,7 @@
|
||||
import shutil
|
||||
import logging
|
||||
import pwd
|
||||
import grp
|
||||
import glob
|
||||
import sys
|
||||
import os
|
||||
@@ -217,6 +218,14 @@ class DsInstance(service.Service):
|
||||
user_exists = False
|
||||
logging.debug("adding ds user %s" % self.ds_user)
|
||||
args = ["/usr/sbin/useradd", "-c", "DS System User", "-d", "/var/lib/dirsrv", "-M", "-r", "-s", "/sbin/nologin", self.ds_user]
|
||||
try:
|
||||
# if the group already exists we need to request to add it,
|
||||
# otherwise useradd will create it for us
|
||||
grp.getgrnam(self.ds_user)
|
||||
args.append("-g")
|
||||
args.append(self.ds_user)
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
ipautil.run(args)
|
||||
logging.debug("done adding user")
|
||||
|
||||
Reference in New Issue
Block a user