From c4e5bc4bb932f709998e203db1ca3b2c71edcb06 Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Thu, 7 Jan 2016 12:36:35 +0000
Subject: [PATCH] Task #8899: Set HOME and USER, since supervisord does not

---
 LCS/PyCommon/dbcredentials.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/LCS/PyCommon/dbcredentials.py b/LCS/PyCommon/dbcredentials.py
index 7fb06c209d8..05f89b60fdf 100644
--- a/LCS/PyCommon/dbcredentials.py
+++ b/LCS/PyCommon/dbcredentials.py
@@ -20,12 +20,19 @@
 # $Id$
 
 from glob import glob
-from os import environ
+import os
+import pwd
 from ConfigParser import SafeConfigParser, NoSectionError, DuplicateSectionError
 from optparse import OptionGroup
 
 __all__ = ["DBCredentials", "options_group", "parse_options"]
 
+# obtain the environment, and add USER and HOME if needed (since supervisord does not)
+environ = os.environ
+user_info = pwd.getpwduid(os.getuid())
+environ.setdefault("HOME", user_info["pw_dir"])
+environ.setdefault("USER", user_info["pw_name"])
+
 def findfiles(pattern):
   """ Returns a list of files matched by `pattern'.
       The pattern can include environment variables using the
-- 
GitLab