From 6c9e0ea2f00744b82872b610fbe90cd059bcbfe8 Mon Sep 17 00:00:00 2001 From: Diego Tavares Date: Tue, 12 Nov 2024 16:04:21 -0800 Subject: [PATCH] [rqd] Allow customizing HOME and MAIL environments Our environment requires a customized home and email dir that needs to be set on the frame environment variable. This change allows it to be set on rqd.conf as RQD_CUSTOM_HOME_PREFIX and RQD_CUSTOM_MAIL_PREFIX --- rqd/rqd/rqconstants.py | 7 +++++++ rqd/rqd/rqcore.py | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/rqd/rqd/rqconstants.py b/rqd/rqd/rqconstants.py index 6f23ebc89..4537b3113 100644 --- a/rqd/rqd/rqconstants.py +++ b/rqd/rqd/rqconstants.py @@ -72,6 +72,9 @@ # Copy specific environment variable from the RQD host to the frame env. RQD_HOST_ENV_VARS = [] +RQD_CUSTOM_HOME_PREFIX = None +RQD_CUSTOM_MAIL_PREFIX = None + RQD_BECOME_JOB_USER = True RQD_CREATE_USER_IF_NOT_EXISTS = True SENTRY_DSN_PATH = None @@ -226,6 +229,10 @@ 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_option(__override_section, "RQD_CUSTOM_HOME_PREFIX"): + RQD_CUSTOM_HOME_PREFIX = config.get(__override_section, "RQD_CUSTOM_HOME_PREFIX") + if config.has_option(__override_section, "RQD_CUSTOM_MAIL_PREFIX"): + RQD_CUSTOM_MAIL_PREFIX = config.get(__override_section, "RQD_CUSTOM_MAIL_PREFIX") 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 abff2aed0..f3d42e475 100644 --- a/rqd/rqd/rqcore.py +++ b/rqd/rqd/rqcore.py @@ -98,6 +98,16 @@ def __createEnvVariables(self): self.frameEnv["CUE_GPU_MEMORY"] = str(self.rqCore.machine.getGpuMemoryFree()) self.frameEnv["SP_NOMYCSHRC"] = "1" + if rqd.rqconstants.RQD_CUSTOM_HOME_PREFIX: + self.frameEnv["HOME"] = "%s/%s" % ( + rqd.rqconstants.RQD_CUSTOM_HOME_PREFIX, + self.runFrame.user_name) + + if rqd.rqconstants.RQD_CUSTOM_MAIL_PREFIX: + self.frameEnv["MAIL"] = "%s/%s" % ( + rqd.rqconstants.RQD_CUSTOM_MAIL_PREFIX, + self.runFrame.user_name) + if platform.system() == "Windows": for variable in ["SYSTEMROOT", "APPDATA", "TMP", "COMMONPROGRAMFILES", "SYSTEMDRIVE"]: if variable in os.environ: