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