Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
File Transfer Service
fts-rest
Commits
43793775
Commit
43793775
authored
Aug 11, 2015
by
Alejandro Alvarez Ayllon
Browse files
FTS-299
: Try default proxy location
parent
ff46e74c
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/fts3/rest/client/context.py
View file @
43793775
...
...
@@ -59,7 +59,13 @@ def _get_x509_list(cert):
return
x509_list
# Base class for actors
def
_get_default_proxy
():
"""
Returns the default proxy location
"""
return
"/tmp/x509up_u%d"
%
os
.
geteuid
()
class
Context
(
object
):
def
_read_passwd_from_stdin
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -68,19 +74,19 @@ class Context(object):
return
self
.
passwd
def
_set_x509
(
self
,
ucert
,
ukey
):
if
not
ukey
:
if
ucert
:
ukey
=
ucert
elif
'X509_USER_PROXY'
in
os
.
environ
:
ukey
=
os
.
environ
[
'X509_USER_PROXY'
]
elif
'X509_USER_KEY'
in
os
.
environ
:
ukey
=
os
.
environ
[
'X509_USER_KEY'
]
if
not
ucert
:
default_proxy_location
=
_get_default_proxy
()
# User certificate and key locations
if
ucert
and
not
ukey
:
ukey
=
ucert
elif
not
ucert
:
if
'X509_USER_PROXY'
in
os
.
environ
:
ucert
=
os
.
environ
[
'X509_USER_PROXY'
]
ukey
=
ucert
=
os
.
environ
[
'X509_USER_PROXY'
]
elif
os
.
path
.
exists
(
default_proxy_location
):
ukey
=
ucert
=
default_proxy_location
elif
'X509_USER_CERT'
in
os
.
environ
:
ucert
=
os
.
environ
[
'X509_USER_CERT'
]
ukey
=
os
.
environ
.
get
(
'X509_USER_KEY'
,
ucert
)
if
ucert
and
ukey
:
self
.
x509_list
=
_get_x509_list
(
ucert
)
...
...
@@ -115,10 +121,10 @@ class Context(object):
self
.
ucert
=
self
.
ukey
=
None
if
not
self
.
ucert
and
not
self
.
ukey
:
log
ging
.
warning
(
"No user certificate given!"
)
log
.
warning
(
"No user certificate given!"
)
else
:
log
ging
.
debug
(
"User certificte: %s"
%
self
.
ucert
)
log
ging
.
debug
(
"User private key: %s"
%
self
.
ukey
)
log
.
debug
(
"User certific
a
te: %s"
%
self
.
ucert
)
log
.
debug
(
"User private key: %s"
%
self
.
ukey
)
def
_set_endpoint
(
self
,
endpoint
):
self
.
endpoint
=
endpoint
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment