31{
32 const std::string& VomsProxySvc ::
33 algServiceName ()
34 {
35 static std::string
result =
"VomsProxySvc";
37 }
38
39
40
41 void VomsProxySvc ::
42 testInvariant () const
43 {
44 }
45
46
47
49 setupJob (Job& )
50 {
53
54 const char *X509_USER_PROXY =
getenv (
"X509_USER_PROXY");
56 if (X509_USER_PROXY)
57 {
58 file = X509_USER_PROXY;
59 } else
60 {
61 std::ostringstream
str;
62 str <<
"/tmp/x509up_u" << getuid();
64 }
65 if (
file.empty() || gSystem->AccessPathName (
file.c_str()) !=
false)
66 {
68 return StatusCode::FAILURE;
69 }
70
71 {
77 {
79 return StatusCode::FAILURE;
80 }
81 }
82
83 return StatusCode::SUCCESS;
84 }
85
86
87
88 const char *VomsProxySvc ::
89 GetName () const
90 {
92 return name().c_str();
93 }
94
95
96
98 histInitialize ()
99 {
102 {
103 int fd =
open (m_fileName.c_str(), O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR);
104 if (fd == -1)
105 {
106 auto myerrno = errno;
107 ANA_MSG_ERROR (
"failed to create file \"" << m_fileName <<
"\": " << strerror (myerrno));
108 return EL::StatusCode::FAILURE;
109 }
110 int written =
write (fd, &m_proxyData[0], m_proxyData.size());
111 if (written == -1)
112 {
113 auto myerrno = errno;
114 ANA_MSG_ERROR (
"failed to write to file \"" << m_fileName <<
"\": " << strerror (myerrno));
115 close (fd);
116 return EL::StatusCode::FAILURE;
117 }
118 if (written < int (m_proxyData.size()))
119 {
120 ANA_MSG_ERROR (
"only wrote " << written <<
" of " << m_proxyData.size() <<
" bytes to file \"" << m_fileName <<
"\"");
121 close (fd);
122 return EL::StatusCode::FAILURE;
123 }
124 if (close (fd) == -1)
125 {
126 auto myerrno = errno;
127 ANA_MSG_ERROR (
"failed to close file \"" << m_fileName <<
"\": " << strerror (myerrno));
128 return EL::StatusCode::FAILURE;
129 }
130 if (setenv ("X509_USER_PROXY", m_fileName.c_str(), true) == -1)
131 {
132 auto myerrno = errno;
133 ANA_MSG_ERROR (
"failed to set X509_USER_PROXY: " << strerror (myerrno));
134 return EL::StatusCode::FAILURE;
135 }
136 }
137 return EL::StatusCode::SUCCESS;
138 }
139}
#define RCU_CHANGE_INVARIANT(x)
#define RCU_READ_INVARIANT(x)
::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