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
Łukasz Nowak
slapos.core
Commits
1d9e2b88
Commit
1d9e2b88
authored
May 29, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
whitespace
parent
05abf98d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
slapos/grid/utils.py
slapos/grid/utils.py
+12
-12
No files found.
slapos/grid/utils.py
View file @
1d9e2b88
...
@@ -181,15 +181,15 @@ def dropPrivileges(uid, gid, logger):
...
@@ -181,15 +181,15 @@ def dropPrivileges(uid, gid, logger):
# twice
# twice
current_uid
,
current_gid
=
os
.
getuid
(),
os
.
getgid
()
current_uid
,
current_gid
=
os
.
getuid
(),
os
.
getgid
()
if
uid
==
0
or
gid
==
0
:
if
uid
==
0
or
gid
==
0
:
raise
OSError
(
'Dropping privileges to uid = %r or '
\
raise
OSError
(
'Dropping privileges to uid = %r or '
'gid = %r is too dangerous'
%
(
uid
,
gid
))
'gid = %r is too dangerous'
%
(
uid
,
gid
))
if
current_uid
or
current_gid
:
if
current_uid
or
current_gid
:
logger
.
debug
(
'Running as uid = %r, gid = %r, dropping
not needed and not
'
logger
.
debug
(
'Running as uid = %r, gid = %r, dropping '
'
possible'
%
(
current_uid
,
current_gid
))
'not needed and not
possible'
%
(
current_uid
,
current_gid
))
return
return
# drop privileges
# drop privileges
user_name
=
pwd
.
getpwuid
(
uid
)[
0
]
user_name
=
pwd
.
getpwuid
(
uid
)[
0
]
group_list
=
set
(
[
x
.
gr_gid
for
x
in
grp
.
getgrall
()
if
user_name
in
x
.
gr_mem
]
)
group_list
=
set
(
x
.
gr_gid
for
x
in
grp
.
getgrall
()
if
user_name
in
x
.
gr_mem
)
group_list
.
add
(
gid
)
group_list
.
add
(
gid
)
os
.
initgroups
(
pwd
.
getpwuid
(
uid
)[
0
],
gid
)
os
.
initgroups
(
pwd
.
getpwuid
(
uid
)[
0
],
gid
)
os
.
setgid
(
gid
)
os
.
setgid
(
gid
)
...
@@ -224,7 +224,7 @@ def dropPrivileges(uid, gid, logger):
...
@@ -224,7 +224,7 @@ def dropPrivileges(uid, gid, logger):
pass
pass
else
:
else
:
raise
ValueError
(
'%s it was possible to go back to uid = %r and gid = '
raise
ValueError
(
'%s it was possible to go back to uid = %r and gid = '
'%r which is fatal.'
%
(
message_pre
,
current_uid
,
current_gid
))
'%r which is fatal.'
%
(
message_pre
,
current_uid
,
current_gid
))
logger
.
debug
(
'Succesfully dropped privileges to uid=%r gid=%r'
%
(
uid
,
gid
))
logger
.
debug
(
'Succesfully dropped privileges to uid=%r gid=%r'
%
(
uid
,
gid
))
...
@@ -253,7 +253,7 @@ def bootstrapBuildout(path, logger, buildout=None,
...
@@ -253,7 +253,7 @@ def bootstrapBuildout(path, logger, buildout=None,
else
:
else
:
# buildout is importable, so use this one
# buildout is importable, so use this one
invocation_list
.
extend
([
"-c"
,
"import sys ; sys.path="
+
str
(
sys
.
path
)
+
invocation_list
.
extend
([
"-c"
,
"import sys ; sys.path="
+
str
(
sys
.
path
)
+
" ; import zc.buildout.buildout ; sys.argv[1:1]="
+
\
" ; import zc.buildout.buildout ; sys.argv[1:1]="
+
repr
(
additional_buildout_parametr_list
+
[
'bootstrap'
])
+
" ; "
repr
(
additional_buildout_parametr_list
+
[
'bootstrap'
])
+
" ; "
"zc.buildout.buildout.main()"
])
"zc.buildout.buildout.main()"
])
...
@@ -271,7 +271,7 @@ def bootstrapBuildout(path, logger, buildout=None,
...
@@ -271,7 +271,7 @@ def bootstrapBuildout(path, logger, buildout=None,
stderr
=
subprocess
.
STDOUT
,
stderr
=
subprocess
.
STDOUT
,
logger
=
logger
)
logger
=
logger
)
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
message
=
'Failed to run buildout profile in directory %r'
%
(
path
)
message
=
'Failed to run buildout profile in directory %r'
%
path
logger
.
error
(
message
)
logger
.
error
(
message
)
raise
BuildoutFailedError
(
'%s:
\
n
%s
\
n
'
%
(
message
,
process_handler
.
output
))
raise
BuildoutFailedError
(
'%s:
\
n
%s
\
n
'
%
(
message
,
process_handler
.
output
))
except
OSError
as
exc
:
except
OSError
as
exc
:
...
@@ -314,7 +314,7 @@ def launchBuildout(path, buildout_binary, logger,
...
@@ -314,7 +314,7 @@ def launchBuildout(path, buildout_binary, logger,
stderr
=
subprocess
.
STDOUT
,
stderr
=
subprocess
.
STDOUT
,
logger
=
logger
)
logger
=
logger
)
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
message
=
'Failed to run buildout profile in directory %r'
%
(
path
)
message
=
'Failed to run buildout profile in directory %r'
%
path
logger
.
error
(
message
)
logger
.
error
(
message
)
raise
BuildoutFailedError
(
'%s:
\
n
%s
\
n
'
%
(
message
,
process_handler
.
output
))
raise
BuildoutFailedError
(
'%s:
\
n
%s
\
n
'
%
(
message
,
process_handler
.
output
))
except
OSError
as
exc
:
except
OSError
as
exc
:
...
@@ -328,8 +328,8 @@ def updateFile(file_path, content, mode=0o600):
...
@@ -328,8 +328,8 @@ def updateFile(file_path, content, mode=0o600):
"""Creates an executable with "content" as content."""
"""Creates an executable with "content" as content."""
altered
=
False
altered
=
False
if
not
(
os
.
path
.
isfile
(
file_path
))
or
\
if
not
(
os
.
path
.
isfile
(
file_path
))
or
\
not
(
hashlib
.
md5
(
open
(
file_path
).
read
()).
digest
()
==
\
not
(
hashlib
.
md5
(
open
(
file_path
).
read
()).
digest
()
==
hashlib
.
md5
(
content
).
digest
()):
hashlib
.
md5
(
content
).
digest
()):
with
open
(
file_path
,
'w'
)
as
fout
:
with
open
(
file_path
,
'w'
)
as
fout
:
fout
.
write
(
content
)
fout
.
write
(
content
)
altered
=
True
altered
=
True
...
@@ -352,6 +352,6 @@ def createPrivateDirectory(path):
...
@@ -352,6 +352,6 @@ def createPrivateDirectory(path):
os
.
chmod
(
path
,
stat
.
S_IREAD
|
stat
.
S_IWRITE
|
stat
.
S_IEXEC
)
os
.
chmod
(
path
,
stat
.
S_IREAD
|
stat
.
S_IWRITE
|
stat
.
S_IEXEC
)
permission
=
stat
.
S_IMODE
(
os
.
stat
(
path
).
st_mode
)
permission
=
stat
.
S_IMODE
(
os
.
stat
(
path
).
st_mode
)
if
permission
!=
0o700
:
if
permission
!=
0o700
:
raise
WrongPermissionError
(
'Wrong permissions in %s: '
\
raise
WrongPermissionError
(
'Wrong permissions in %s: '
'is 0%o, should be 0700'
'is 0%o, should be 0700'
%
(
path
,
permission
))
%
(
path
,
permission
))
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