File indexing completed on 2026-04-10 08:39:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 from pilot.util.container import execute
0011
0012 import logging
0013 logger = logging.getLogger(__name__)
0014
0015
0016 def get_distinguished_name():
0017 """
0018 Get the user DN.
0019 Note: the DN is also sent by the server to the pilot in the job description (produserid).
0020
0021 :return: User DN (string).
0022 """
0023
0024 dn = ""
0025 executable = 'arcproxy -i subject'
0026 exit_code, stdout, stderr = execute(executable)
0027 if exit_code != 0 or "ERROR:" in stderr:
0028 logger.warning("arcproxy failed: ec=%d, stdout=%s, stderr=%s" % (exit_code, stdout, stderr))
0029
0030 if "command not found" in stderr or "Can not find certificate file" in stderr:
0031 logger.warning("arcproxy experienced a problem (will try voms-proxy-info instead)")
0032
0033
0034 executable = 'voms-proxy-info -subject'
0035 exit_code, stdout, stderr = execute(executable)
0036
0037 if exit_code == 0:
0038 dn = stdout
0039 logger.info('DN = %s' % dn)
0040 cn = "/CN=proxy"
0041 if not dn.endswith(cn):
0042 logger.info("DN does not end with %s (will be added)" % cn)
0043 dn += cn
0044
0045 else:
0046 logger.warning("user=self set but cannot get proxy: %d, %s" % (exit_code, stdout))
0047
0048 return dn