Skip to content

Commit ba2844a

Browse files
committed
Adding more logic around the KRB5CCNAME env variable
1 parent a9d750a commit ba2844a

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

bin/stashcp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,20 @@ def doWriteBack(source, destination):
3232

3333
# Get the scitoken content
3434
if 'KRB5CCNAME' in os.environ:
35-
scitoken_file = os.environ['KRB5CCNAME']
35+
# First, try to split the environment variable:
36+
# Format: KRB5CCNAME=FILE:/var/lib/condor/execute/dir_24688/nobody.cc
37+
if ':' in os.environ['KRB5CCNAME']:
38+
# Try splitting
39+
scitoken_file = os.environ['KRB5CCNAME'].split(':', 1)
40+
if not os.path.exists(scitoken_file):
41+
scitoken_file = None
42+
if scitoken_file == None:
43+
# Splitting failed, now try just looking at the os.environ:
44+
scitoken_file = os.environ['KRB5CCNAME']
45+
if not os.path.exists(scitoken_file):
46+
scitoken_file = None
47+
logging.error("Unable to find SciToken file, environment variable KRB5CCNAME=%s, but file not found" % (os.environ['KRB5CCNAME']))
48+
return 1
3649
else:
3750
logging.error("Unable to find SciToken file, environment variable \"KRB5CCNAME\" not found.")
3851
return 1

0 commit comments

Comments
 (0)