diff --git a/rqd/rqd/rqconstants.py b/rqd/rqd/rqconstants.py index 87585844e..105685270 100644 --- a/rqd/rqd/rqconstants.py +++ b/rqd/rqd/rqconstants.py @@ -223,6 +223,8 @@ MINIMUM_IDLE = config.getint(__override_section, "MINIMUM_IDLE") if config.has_option(__override_section, "SENTRY_DSN_PATH"): SENTRY_DSN_PATH = config.getint(__override_section, "SENTRY_DSN_PATH") + if config.has_option(__override_section, "SP_OS"): + SP_OS = config.get(__override_section, "SP_OS") if config.has_section(__host_env_var_section): RQD_HOST_ENV_VARS = config.options(__host_env_var_section) diff --git a/rqd/rqd/rqcore.py b/rqd/rqd/rqcore.py index 8210cfcc3..51e0b90f0 100644 --- a/rqd/rqd/rqcore.py +++ b/rqd/rqd/rqcore.py @@ -297,7 +297,7 @@ def runLinux(self): self.__writeHeader() if rqd.rqconstants.RQD_CREATE_USER_IF_NOT_EXISTS: rqd.rqutil.permissionsHigh() - rqd.rqutil.checkAndCreateUser(runFrame.user_name) + rqd.rqutil.checkAndCreateUser(runFrame.user_name, runFrame.uid, runFrame.gid) rqd.rqutil.permissionsLow() tempStatFile = "%srqd-stat-%s-%s" % (self.rqCore.machine.getTempPath(), diff --git a/rqd/rqd/rqutil.py b/rqd/rqd/rqutil.py index e9e95fe2a..df7c0bf30 100644 --- a/rqd/rqd/rqutil.py +++ b/rqd/rqd/rqutil.py @@ -132,7 +132,7 @@ def __becomeRoot(): pass -def checkAndCreateUser(username): +def checkAndCreateUser(username, uid=None, gid=None): """Check to see if the provided user exists, if not attempt to create it.""" # TODO(gregdenton): Add Windows and Mac support here. (Issue #61) if not rqd.rqconstants.RQD_BECOME_JOB_USER: @@ -141,11 +141,17 @@ def checkAndCreateUser(username): pwd.getpwnam(username) return except KeyError: - subprocess.check_call([ + cmd = [ 'useradd', '-p', str(uuid.uuid4()), # generate a random password - username - ]) + ] + if uid: + cmd += ['-u', str(uid)] + if gid: + cmd += ['-g', str(gid)] + cmd.append(username) + log.info("Frame's username not found on host. Adding user with: %s", cmd) + subprocess.check_call(cmd) def getHostIp():