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
Cédric Le Ninivin
slapos.core
Commits
39b63e08
Commit
39b63e08
authored
Apr 25, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
octal cleanup
parent
ede11c8e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
21 deletions
+20
-21
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+10
-11
slapos/grid/utils.py
slapos/grid/utils.py
+10
-10
No files found.
slapos/grid/SlapObject.py
View file @
39b63e08
...
...
@@ -50,7 +50,7 @@ from slapos.grid.exception import (BuildoutFailedError, WrongPermissionError,
from
slapos.grid.networkcache
import
download_network_cached
,
upload_network_cached
from
slapos.grid.watchdog
import
getWatchdogID
REQUIRED_COMPUTER_PARTITION_PERMISSION
=
'0750'
REQUIRED_COMPUTER_PARTITION_PERMISSION
=
0o750
class
Software
(
object
):
...
...
@@ -227,7 +227,7 @@ class Software(object):
if
func
==
os
.
path
.
islink
:
os
.
unlink
(
path
)
else
:
os
.
chmod
(
path
,
0600
)
os
.
chmod
(
path
,
0
o
600
)
func
(
path
)
try
:
if
os
.
path
.
exists
(
self
.
software_path
):
...
...
@@ -297,7 +297,7 @@ class Partition(object):
open
(
self
.
key_file
,
'w'
).
write
(
partition_certificate
[
'key'
])
open
(
self
.
cert_file
,
'w'
).
write
(
partition_certificate
[
'certificate'
])
for
f
in
[
self
.
key_file
,
self
.
cert_file
]:
os
.
chmod
(
f
,
0400
)
os
.
chmod
(
f
,
0
o
400
)
os
.
chown
(
f
,
*
self
.
getUserGroupId
())
def
getUserGroupId
(
self
):
...
...
@@ -352,11 +352,10 @@ class Partition(object):
self
.
updateSymlink
(
sr_symlink
,
self
.
software_path
)
instance_stat_info
=
os
.
stat
(
self
.
instance_path
)
permission
=
oct
(
stat
.
S_IMODE
(
instance_stat_info
.
st_mode
)
)
permission
=
stat
.
S_IMODE
(
instance_stat_info
.
st_mode
)
if
permission
!=
REQUIRED_COMPUTER_PARTITION_PERMISSION
:
raise
WrongPermissionError
(
'Wrong permissions in %s : actual '
\
'permissions are : %s, wanted '
\
'are %s'
%
raise
WrongPermissionError
(
'Wrong permissions in %s: actual '
'permissions are: 0%o, wanted are 0%o'
%
(
self
.
instance_path
,
permission
,
REQUIRED_COMPUTER_PARTITION_PERMISSION
))
os
.
environ
=
getCleanEnvironment
(
pwd
.
getpwuid
(
...
...
@@ -386,7 +385,7 @@ class Partition(object):
cert_file
=
self
.
cert_file
)
open
(
config_location
,
'w'
).
write
(
buildout_text
)
os
.
chmod
(
config_location
,
0640
)
os
.
chmod
(
config_location
,
0
o
640
)
# Try to find the best possible buildout:
# *) if software_root/bin/bootstrap exists use this one to bootstrap
# locally
...
...
@@ -444,7 +443,7 @@ class Partition(object):
# check if CP/etc/run exists and it is a directory
# iterate over each file in CP/etc/run
# iterate over each file in CP/etc/service adding WatchdogID to their name
# if at least one is not 0750 raise -- partition has something funny
# if at least one is not 0
o
750 raise -- partition has something funny
runner_list
=
[]
service_list
=
[]
if
os
.
path
.
exists
(
self
.
run_path
):
...
...
slapos/grid/utils.py
View file @
39b63e08
...
...
@@ -41,7 +41,7 @@ from hashlib import md5
# Such umask by default will create paths with full permission
# for user, non writable by group and not accessible by others
SAFE_UMASK
=
027
SAFE_UMASK
=
0
o
27
PYTHON_ENVIRONMENT_REMOVE_LIST
=
[
'PYTHONHOME'
,
...
...
@@ -331,7 +331,7 @@ def launchBuildout(path, buildout_binary,
logger
.
debug
(
'Restore umask from %03o to %03o'
%
(
old_umask
,
umask
))
def
updateFile
(
file_path
,
content
,
mode
=
'0600'
):
def
updateFile
(
file_path
,
content
,
mode
=
0o600
):
"""Creates an executable with "content" as content."""
altered
=
False
if
not
(
os
.
path
.
isfile
(
file_path
))
or
\
...
...
@@ -343,15 +343,15 @@ def updateFile(file_path, content, mode='0600'):
file_file
.
flush
()
file_file
.
close
()
os
.
chmod
(
file_path
,
stat
.
S_IREAD
|
stat
.
S_IWRITE
|
stat
.
S_IEXEC
)
if
oct
(
stat
.
S_IMODE
(
os
.
stat
(
file_path
).
st_mode
)
)
!=
mode
:
os
.
chmod
(
file_path
,
int
(
mode
,
8
)
)
if
stat
.
S_IMODE
(
os
.
stat
(
file_path
).
st_mode
)
!=
mode
:
os
.
chmod
(
file_path
,
mode
)
altered
=
True
return
altered
def
updateExecutable
(
executable_path
,
content
):
"""Creates an executable with "content" as content."""
return
updateFile
(
executable_path
,
content
,
'0700'
)
return
updateFile
(
executable_path
,
content
,
0o700
)
def
createPrivateDirectory
(
path
):
...
...
@@ -359,8 +359,8 @@ def createPrivateDirectory(path):
if
not
os
.
path
.
isdir
(
path
):
os
.
mkdir
(
path
)
os
.
chmod
(
path
,
stat
.
S_IREAD
|
stat
.
S_IWRITE
|
stat
.
S_IEXEC
)
permission
=
oct
(
stat
.
S_IMODE
(
os
.
stat
(
path
).
st_mode
)
)
if
permission
not
in
(
'0700'
)
:
raise
WrongPermissionError
(
'Wrong permissions in %s '
\
': is %s
, should be 0700'
permission
=
stat
.
S_IMODE
(
os
.
stat
(
path
).
st_mode
)
if
permission
!=
0o700
:
raise
WrongPermissionError
(
'Wrong permissions in %s
:
'
\
'is 0%o
, should be 0700'
%
(
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