41{
42 const std::string& VomsProxySvc ::
43 algServiceName ()
44 {
45 static std::string
result =
"VomsProxySvc";
47 }
48
49
50
51 void VomsProxySvc ::
52 testInvariant () const
53 {
55 }
56
57
58
59 StatusCode VomsProxySvc ::
60 setupJob (Job& )
61 {
64
65 const char *X509_USER_PROXY =
getenv (
"X509_USER_PROXY");
67 if (X509_USER_PROXY)
68 {
69 file = X509_USER_PROXY;
70 } else
71 {
72 std::ostringstream
str;
73 str <<
"/tmp/x509up_u" << getuid();
75 }
76 if (
file.empty() || gSystem->AccessPathName (
file.c_str()) !=
false)
78
79 {
86 }
87
88 return StatusCode::FAILURE;
89 }
90
91
92
93 const char *VomsProxySvc ::
94 GetName () const
95 {
97 return name().c_str();
98 }
99
100
101
102 StatusCode VomsProxySvc ::
103 histInitialize ()
104 {
107 {
108 int fd =
open (m_fileName.c_str(), O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
109 if (fd == -1)
110 {
111 auto myerrno = errno;
112 ANA_MSG_ERROR (
"failed to create file \"" << m_fileName <<
"\": " << strerror (myerrno));
113 return EL::StatusCode::FAILURE;
114 }
115 int written =
write (fd, &m_proxyData[0], m_proxyData.size());
116 if (written == -1)
117 {
118 auto myerrno = errno;
119 ANA_MSG_ERROR (
"failed to write to file \"" << m_fileName <<
"\": " << strerror (myerrno));
120 close (fd);
121 return EL::StatusCode::FAILURE;
122 }
123 if (written < int (m_proxyData.size()))
124 {
125 ANA_MSG_ERROR (
"only wrote " << written <<
" of " << m_proxyData.size() <<
" bytes to file \"" << m_fileName <<
"\"");
126 close (fd);
127 return EL::StatusCode::FAILURE;
128 }
129 if (close (fd) == -1)
130 {
131 auto myerrno = errno;
132 ANA_MSG_ERROR (
"failed to close file \"" << m_fileName <<
"\": " << strerror (myerrno));
133 return EL::StatusCode::FAILURE;
134 }
135 if (setenv ("X509_USER_PROXY", m_fileName.c_str(), true) == -1)
136 {
137 auto myerrno = errno;
138 ANA_MSG_ERROR (
"failed to set X509_USER_PROXY: " << strerror (myerrno));
139 return EL::StatusCode::FAILURE;
140 }
141 }
142 return EL::StatusCode::SUCCESS;
143 }
144}
#define RCU_CHANGE_INVARIANT(x)
#define RCU_READ_INVARIANT(x)
#define RCU_THROW_MSG(message)
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