Commit 6acc1ecd authored by Andrew McNab's avatar Andrew McNab
Browse files

make-jobfeatures.htcondor cannot use $USER

parent 3505e5b5
VERSION=00.12
VERSION=00.13
......@@ -59,6 +59,7 @@
import os
import re
import pwd
import sys
import stat
import time
......@@ -105,30 +106,35 @@ if 'mjf_tmp_dir=' in fromRun + fromSysconfig:
except:
pass
try:
userName = pwd.getpwuid(os.getuid())[0]
except:
userName = str(os.getuid())
# First make sure the mjfTmpDir/mjf-$USER directory exists
try:
os.mkdir(mjfTmpDir + '/mjf-' + os.environ['USER'])
os.mkdir(mjfTmpDir + '/mjf-' + userName)
except:
# Ok if exists already
pass
try:
userDirStat = os.stat(mjfTmpDir + '/mjf-' + os.environ['USER'])
userDirStat = os.stat(mjfTmpDir + '/mjf-' + userName)
except:
print mjfTmpDir + '/mjf-' + os.environ['USER'] + ' could not be created'
print mjfTmpDir + '/mjf-' + userName + ' could not be created'
sys.exit(12)
# Check it is owned by us
if userDirStat.st_uid != os.getuid() or userDirStat.st_gid != os.getgid():
print mjfTmpDir + '/mjf-' + os.environ['USER'] + ' has the wrong UID/GID'
print mjfTmpDir + '/mjf-' + userName + ' has the wrong UID/GID'
sys.exit(13)
# Ensure the right permissions
os.chmod(mjfTmpDir + '/mjf-' + os.environ['USER'],
os.chmod(mjfTmpDir + '/mjf-' + userName,
stat.S_IRWXU + stat.S_IRGRP + stat.S_IXGRP + stat.S_IROTH + stat.S_IXOTH)
# Now the directory for this job (but with # -> _)
jobfeaturesDir = mjfTmpDir + '/mjf-' + os.environ['USER'] + '/jobfeatures-' + job_id.replace('#', '_')
jobfeaturesDir = mjfTmpDir + '/mjf-' + userName + '/jobfeatures-' + job_id.replace('#', '_')
try:
os.mkdir(jobfeaturesDir)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment