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 <fstream>
22
#include <TSystem.h>
23
24
//
25
// method implementations
26
//
27
28
ClassImp
(
EL::VomsProxySvc
)
29
30
namespace
EL
31
{
32
const
std::string& VomsProxySvc ::
33
algServiceName ()
34
{
35
static
std::string result =
"VomsProxySvc"
;
36
return
result;
37
}
38
39
40
41
void
VomsProxySvc ::
42
testInvariant ()
const
43
{
44
}
45
46
47
48
StatusCode
VomsProxySvc ::
49
setupJob (Job&
/*job*/
)
50
{
51
RCU_CHANGE_INVARIANT
(
this
);
52
SH::ensureVomsProxy
();
53
54
const
char
*X509_USER_PROXY = getenv (
"X509_USER_PROXY"
);
55
std::string
file
;
56
if
(X509_USER_PROXY)
57
{
58
file
= X509_USER_PROXY;
59
}
else
60
{
61
std::ostringstream
str
;
62
str
<<
"/tmp/x509up_u"
<< getuid();
63
file
=
str
.str();
64
}
65
if
(
file
.empty() || gSystem->AccessPathName (
file
.c_str()) !=
false
)
66
{
67
ANA_MSG_ERROR
(
"failed to find X509 proxy file: "
<<
file
);
68
return
StatusCode::FAILURE;
69
}
70
71
{
72
std::ifstream stream (
file
);
73
char
ch;
74
while
(stream.get (ch))
75
m_proxyData += ch;
76
if
(!stream.eof())
77
{
78
ANA_MSG_ERROR
(
"error reading X509 proxy file: "
<<
file
);
79
return
StatusCode::FAILURE;
80
}
81
}
82
83
return
StatusCode::SUCCESS;
84
}
85
86
87
88
const
char
*VomsProxySvc ::
89
GetName ()
const
90
{
91
RCU_READ_INVARIANT
(
this
);
92
return
name().c_str();
93
}
94
95
96
97
StatusCode
VomsProxySvc ::
98
histInitialize ()
99
{
100
RCU_READ_INVARIANT
(
this
);
101
if
(!
SH::checkVomsProxy
())
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
}
Assert.h
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:295
GridTools.h
ClassImp
ClassImp(EL::VomsProxySvc) namespace EL
Definition
VomsProxySvc.cxx:28
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:228
SH::checkVomsProxy
bool checkVomsProxy()
return whether we have a valid VOMS proxy available
Definition
GridTools.cxx:221
str
Definition
BTagTrackIpAccessor.cxx:11
file
TFile * file
Definition
tile_monitor.h:29
Generated on
for ATLAS Offline Software by
1.17.0