Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
machinejobfeatures
mjf-scripts
Commits
6acc1ecd
Commit
6acc1ecd
authored
May 09, 2016
by
Andrew McNab
Browse files
make-jobfeatures.htcondor cannot use $USER
parent
3505e5b5
Changes
2
Hide whitespace changes
Inline
Side-by-side
VERSION
View file @
6acc1ecd
VERSION=00.1
2
VERSION=00.1
3
make-jobfeatures.htcondor
View file @
6acc1ecd
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment