ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDTools
EventLoop
Root
VomsProxySvc.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
//
8
// includes
9
//
10
11
#include <
EventLoop/VomsProxySvc.h
>
12
13
#include <
AsgMessaging/MessageCheck.h
>
14
#include <
RootCoreUtils/Assert.h
>
15
#include <
SampleHandler/GridTools.h
>
16
#include <errno.h>
17
#include <unistd.h>
18
#include <sys/types.h>
19
#include <sys/stat.h>
20
#include <fcntl.h>
21
#include <unistd.h>
22
#include <sys/types.h>
23
#include <fstream>
24
#include <TSystem.h>
25
26
//
27
// method implementations
28
//
29
30
ClassImp
(
EL::VomsProxySvc
)
31
32
namespace
EL
33
{
34
const
std::string& VomsProxySvc ::
35
algServiceName ()
36
{
37
static
std::string result =
"VomsProxySvc"
;
38
return
result;
39
}
40
41
42
43
void
VomsProxySvc ::
44
testInvariant ()
const
45
{
46
RCU_INVARIANT
(
this
!=
nullptr
);
47
}
48
49
50
51
StatusCode
VomsProxySvc ::
52
setupJob (Job&
/*job*/
)
53
{
54
RCU_CHANGE_INVARIANT
(
this
);
55
SH::ensureVomsProxy
();
56
57
const
char
*X509_USER_PROXY = getenv (
"X509_USER_PROXY"
);
58
std::string
file
;
59
if
(X509_USER_PROXY)
60
{
61
file
= X509_USER_PROXY;
62
}
else
63
{
64
std::ostringstream
str
;
65
str
<<
"/tmp/x509up_u"
<< getuid();
66
file
=
str
.str();
67
}
68
if
(
file
.empty() || gSystem->AccessPathName (
file
.c_str()) !=
false
)
69
{
70
ANA_MSG_ERROR
(
"failed to find X509 proxy file: "
<<
file
);
71
return
StatusCode::FAILURE;
72
}
73
74
{
75
std::ifstream stream (
file
);
76
char
ch;
77
while
(stream.get (ch))
78
m_proxyData += ch;
79
if
(!stream.eof())
80
{
81
ANA_MSG_ERROR
(
"error reading X509 proxy file: "
<<
file
);
82
return
StatusCode::FAILURE;
83
}
84
}
85
86
return
StatusCode::SUCCESS;
87
}
88
89
90
91
const
char
*VomsProxySvc ::
92
GetName ()
const
93
{
94
RCU_READ_INVARIANT
(
this
);
95
return
name().c_str();
96
}
97
98
99
100
StatusCode
VomsProxySvc ::
101
histInitialize ()
102
{
103
RCU_READ_INVARIANT
(
this
);
104
if
(!
SH::checkVomsProxy
())
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
}
Assert.h
RCU_INVARIANT
#define RCU_INVARIANT(x)
Definition
Assert.h:189
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition
Assert.h:219
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition
Assert.h:217
MessageCheck.h
macros for messaging and checking status codes
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
GridTools.h
ClassImp
ClassImp(EL::VomsProxySvc) namespace EL
Definition
VomsProxySvc.cxx:30
VomsProxySvc.h
EL::VomsProxySvc
Definition
VomsProxySvc.h:17
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition
AsgComponentFactories.h:16
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SH::ensureVomsProxy
void ensureVomsProxy()
ensure that we have a valid VOMS proxy available
Definition
GridTools.cxx:213
SH::checkVomsProxy
bool checkVomsProxy()
return whether we have a valid VOMS proxy available
Definition
GridTools.cxx:206
str
Definition
BTagTrackIpAccessor.cxx:11
file
TFile * file
Definition
tile_monitor.h:29
Generated on
for ATLAS Offline Software by
1.17.0