#include <EventLoop/VomsProxySvc.h>
#include <AsgMessaging/MessageCheck.h>
#include <RootCoreUtils/Assert.h>
#include <RootCoreUtils/ThrowMsg.h>
#include <SampleHandler/GridTools.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <fstream>
#include <TSystem.h>
Go to the source code of this file.
◆ ClassImp()
Definition at line 38 of file VomsProxySvc.cxx.
42 const std::string& VomsProxySvc ::
45 static std::string
result =
"VomsProxySvc";
52 testInvariant ()
const
65 const char *X509_USER_PROXY =
getenv (
"X509_USER_PROXY");
69 file = X509_USER_PROXY;
72 std::ostringstream
str;
73 str <<
"/tmp/x509up_u" << getuid();
76 if (
file.empty() || gSystem->AccessPathName (
file.c_str()) !=
false)
88 return StatusCode::FAILURE;
93 const char *VomsProxySvc ::
97 return name().c_str();
108 int fd =
open (m_fileName.c_str(), O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
111 auto myerrno = errno;
112 ANA_MSG_ERROR (
"failed to create file \"" << m_fileName <<
"\": " << strerror (myerrno));
113 return EL::StatusCode::FAILURE;
115 int written =
write (
fd, &m_proxyData[0], m_proxyData.size());
118 auto myerrno = errno;
119 ANA_MSG_ERROR (
"failed to write to file \"" << m_fileName <<
"\": " << strerror (myerrno));
121 return EL::StatusCode::FAILURE;
123 if (written <
int (m_proxyData.size()))
125 ANA_MSG_ERROR (
"only wrote " << written <<
" of " << m_proxyData.size() <<
" bytes to file \"" << m_fileName <<
"\"");
127 return EL::StatusCode::FAILURE;
129 if (close (
fd) == -1)
131 auto myerrno = errno;
132 ANA_MSG_ERROR (
"failed to close file \"" << m_fileName <<
"\": " << strerror (myerrno));
133 return EL::StatusCode::FAILURE;
135 if (setenv (
"X509_USER_PROXY", m_fileName.c_str(),
true) == -1)
137 auto myerrno = errno;
138 ANA_MSG_ERROR (
"failed to set X509_USER_PROXY: " << strerror (myerrno));
139 return EL::StatusCode::FAILURE;
142 return EL::StatusCode::SUCCESS;