Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
slapos.core
Commits
e4d513f3
Commit
e4d513f3
authored
Jun 28, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
grid: allow overriding of variables like USER in buildout context
parent
3aa3a2c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
15 deletions
+25
-15
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+4
-4
slapos/grid/utils.py
slapos/grid/utils.py
+21
-11
No files found.
slapos/grid/SlapObject.py
View file @
e4d513f3
...
...
@@ -465,8 +465,8 @@ class Partition(object):
process_handler
=
SlapPopen
(
invocation_list
,
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
,
logger
=
self
.
logger
),
cwd
=
self
.
instance_path
,
env
=
getCleanEnvironment
(
logger
=
self
.
logger
,
home_path
=
pwd
.
getpwuid
(
uid
).
pw_dir
),
env
=
getCleanEnvironment
(
self
.
logger
,
{
'HOME'
:
pwd
.
getpwuid
(
uid
).
pw_dir
}
),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
logger
=
self
.
logger
)
...
...
@@ -571,8 +571,8 @@ class Partition(object):
process_handler
=
SlapPopen
([
destroy_executable_location
],
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
,
logger
=
self
.
logger
),
cwd
=
self
.
instance_path
,
env
=
getCleanEnvironment
(
logger
=
self
.
logger
,
home_path
=
pwd
.
getpwuid
(
uid
).
pw_dir
),
env
=
getCleanEnvironment
(
self
.
logger
,
{
'HOME'
:
pwd
.
getpwuid
(
uid
).
pw_dir
}
),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
logger
=
self
.
logger
)
...
...
slapos/grid/utils.py
View file @
e4d513f3
...
...
@@ -118,20 +118,27 @@ def md5digest(url):
return
hashlib
.
md5
(
url
).
hexdigest
()
def
getCleanEnvironment
(
logger
,
home_path
=
'/tmp'
):
changed_env
=
{}
removed_env
=
[]
def
getCleanEnvironment
(
logger
,
override
=
None
):
if
override
is
None
:
override
=
{}
if
not
'HOME'
in
override
:
raise
KeyError
(
'Overridden environment must contain the HOME variable.'
)
removed
=
[]
env
=
os
.
environ
.
copy
()
# Clean python related environment variables
for
k
in
PYTHON_ENVIRONMENT_REMOVE_LIST
+
SYSTEM_ENVIRONMENT_REMOVE_LIST
\
+
LOCALE_ENVIRONMENT_REMOVE_LIST
:
old
=
env
.
pop
(
k
,
None
)
if
old
is
not
None
:
removed_env
.
append
(
k
)
changed_env
[
'HOME'
]
=
env
[
'HOME'
]
=
home_path
for
k
in
sorted
(
changed_env
.
iterkeys
()):
logger
.
debug
(
'Overridden %s = %r'
%
(
k
,
changed_env
[
k
]))
logger
.
debug
(
'Removed from environment: %s'
%
', '
.
join
(
sorted
(
removed_env
)))
if
old
is
not
None
and
k
not
in
override
:
removed
.
append
(
k
)
for
k
in
sorted
(
override
):
env
[
k
]
=
override
[
k
]
logger
.
debug
(
"Overridden %s = '%s'"
,
k
,
override
[
k
])
logger
.
debug
(
'Removed from environment: %s'
%
', '
.
join
(
sorted
(
removed
)))
return
env
...
...
@@ -308,8 +315,11 @@ def launchBuildout(path, buildout_binary, logger,
process_handler
=
SlapPopen
(
invocation_list
,
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
,
logger
=
logger
),
cwd
=
path
,
env
=
getCleanEnvironment
(
logger
=
logger
,
home_path
=
path
),
env
=
getCleanEnvironment
(
logger
,
{
'HOME'
:
path
,
'USER'
:
pwd
.
getpwuid
(
uid
).
pw_name
,
}),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
logger
=
logger
)
...
...
Write
Preview
Markdown
is supported
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