Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…/OpenCue into blender-addon-dev
  • Loading branch information
n-jay committed Aug 17, 2024
2 parents bc34849 + b21aa6b commit 021f527
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions rqd/rqd/rqconstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion rqd/rqd/rqcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
14 changes: 10 additions & 4 deletions rqd/rqd/rqutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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():
Expand Down

0 comments on commit 021f527

Please sign in to comment.