From 53d1cf1644df37843253be2df176f7bdd5d12a31 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Wed, 3 Feb 2010 16:44:29 -0500 Subject: 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 --- ipaserver/install/dsinstance.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'ipaserver/install/dsinstance.py') diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py index 4fcb914c..9a71b7f5 100644 --- a/ipaserver/install/dsinstance.py +++ b/ipaserver/install/dsinstance.py @@ -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") -- cgit