34{
35 const std::string& VomsProxySvc ::
36 algServiceName ()
37 {
38 static std::string
result =
"VomsProxySvc";
40 }
41
42
43
44 void VomsProxySvc ::
45 testInvariant () const
46 {
48 }
49
50
51
53 setupJob (Job& )
54 {
57
58 const char *X509_USER_PROXY =
getenv (
"X509_USER_PROXY");
60 if (X509_USER_PROXY)
61 {
62 file = X509_USER_PROXY;
63 } else
64 {
65 std::ostringstream
str;
66 str <<
"/tmp/x509up_u" << getuid();
68 }
69 if (
file.empty() || gSystem->AccessPathName (
file.c_str()) !=
false)
71
72 {
79 }
80
81 return StatusCode::FAILURE;
82 }
83
84
85
86 const char *VomsProxySvc ::
87 GetName () const
88 {
90 return name().c_str();
91 }
92
93
94
96 histInitialize ()
97 {
100 {
101 int fd =
open (m_fileName.c_str(), O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
102 if (fd == -1)
103 {
104 auto myerrno = errno;
105 ANA_MSG_ERROR (
"failed to create file \"" << m_fileName <<
"\": " << strerror (myerrno));
106 return EL::StatusCode::FAILURE;
107 }
108 int written =
write (fd, &m_proxyData[0], m_proxyData.size());
109 if (written == -1)
110 {
111 auto myerrno = errno;
112 ANA_MSG_ERROR (
"failed to write to file \"" << m_fileName <<
"\": " << strerror (myerrno));
113 close (fd);
114 return EL::StatusCode::FAILURE;
115 }
116 if (written < int (m_proxyData.size()))
117 {
118 ANA_MSG_ERROR (
"only wrote " << written <<
" of " << m_proxyData.size() <<
" bytes to file \"" << m_fileName <<
"\"");
119 close (fd);
120 return EL::StatusCode::FAILURE;
121 }
122 if (close (fd) == -1)
123 {
124 auto myerrno = errno;
125 ANA_MSG_ERROR (
"failed to close file \"" << m_fileName <<
"\": " << strerror (myerrno));
126 return EL::StatusCode::FAILURE;
127 }
128 if (setenv ("X509_USER_PROXY", m_fileName.c_str(), true) == -1)
129 {
130 auto myerrno = errno;
131 ANA_MSG_ERROR (
"failed to set X509_USER_PROXY: " << strerror (myerrno));
132 return EL::StatusCode::FAILURE;
133 }
134 }
135 return EL::StatusCode::SUCCESS;
136 }
137}
#define RCU_CHANGE_INVARIANT(x)
#define RCU_READ_INVARIANT(x)
#define RCU_THROW_MSG(message)
::StatusCode StatusCode
StatusCode definition for legacy code.
std::string getenv(const std::string &variableName)
get an environment variable
void ensureVomsProxy()
ensure that we have a valid VOMS proxy available
bool checkVomsProxy()
return whether we have a valid VOMS proxy available