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
Thomas Leymonerie
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
Hide 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,
...
@@ -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.networkcache
import
download_network_cached
,
upload_network_cached
from
slapos.grid.watchdog
import
getWatchdogID
from
slapos.grid.watchdog
import
getWatchdogID
REQUIRED_COMPUTER_PARTITION_PERMISSION
=
'0750'
REQUIRED_COMPUTER_PARTITION_PERMISSION
=
0o750
class
Software
(
object
):
class
Software
(
object
):
...
@@ -227,7 +227,7 @@ class Software(object):
...
@@ -227,7 +227,7 @@ class Software(object):
if
func
==
os
.
path
.
islink
:
if
func
==
os
.
path
.
islink
:
os
.
unlink
(
path
)
os
.
unlink
(
path
)
else
:
else
:
os
.
chmod
(
path
,
0600
)
os
.
chmod
(
path
,
0
o
600
)
func
(
path
)
func
(
path
)
try
:
try
:
if
os
.
path
.
exists
(
self
.
software_path
):
if
os
.
path
.
exists
(
self
.
software_path
):
...
@@ -297,7 +297,7 @@ class Partition(object):
...
@@ -297,7 +297,7 @@ class Partition(object):
open
(
self
.
key_file
,
'w'
).
write
(
partition_certificate
[
'key'
])
open
(
self
.
key_file
,
'w'
).
write
(
partition_certificate
[
'key'
])
open
(
self
.
cert_file
,
'w'
).
write
(
partition_certificate
[
'certificate'
])
open
(
self
.
cert_file
,
'w'
).
write
(
partition_certificate
[
'certificate'
])
for
f
in
[
self
.
key_file
,
self
.
cert_file
]:
for
f
in
[
self
.
key_file
,
self
.
cert_file
]:
os
.
chmod
(
f
,
0400
)
os
.
chmod
(
f
,
0
o
400
)
os
.
chown
(
f
,
*
self
.
getUserGroupId
())
os
.
chown
(
f
,
*
self
.
getUserGroupId
())
def
getUserGroupId
(
self
):
def
getUserGroupId
(
self
):
...
@@ -352,13 +352,12 @@ class Partition(object):
...
@@ -352,13 +352,12 @@ class Partition(object):
self
.
updateSymlink
(
sr_symlink
,
self
.
software_path
)
self
.
updateSymlink
(
sr_symlink
,
self
.
software_path
)
instance_stat_info
=
os
.
stat
(
self
.
instance_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
:
if
permission
!=
REQUIRED_COMPUTER_PARTITION_PERMISSION
:
raise
WrongPermissionError
(
'Wrong permissions in %s : actual '
\
raise
WrongPermissionError
(
'Wrong permissions in %s: actual '
'permissions are : %s, wanted '
\
'permissions are: 0%o, wanted are 0%o'
%
'are %s'
%
(
self
.
instance_path
,
permission
,
(
self
.
instance_path
,
permission
,
REQUIRED_COMPUTER_PARTITION_PERMISSION
))
REQUIRED_COMPUTER_PARTITION_PERMISSION
))
os
.
environ
=
getCleanEnvironment
(
pwd
.
getpwuid
(
os
.
environ
=
getCleanEnvironment
(
pwd
.
getpwuid
(
instance_stat_info
.
st_uid
).
pw_dir
)
instance_stat_info
.
st_uid
).
pw_dir
)
# Generates buildout part from template
# Generates buildout part from template
...
@@ -386,7 +385,7 @@ class Partition(object):
...
@@ -386,7 +385,7 @@ class Partition(object):
cert_file
=
self
.
cert_file
cert_file
=
self
.
cert_file
)
)
open
(
config_location
,
'w'
).
write
(
buildout_text
)
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:
# Try to find the best possible buildout:
# *) if software_root/bin/bootstrap exists use this one to bootstrap
# *) if software_root/bin/bootstrap exists use this one to bootstrap
# locally
# locally
...
@@ -444,7 +443,7 @@ class Partition(object):
...
@@ -444,7 +443,7 @@ class Partition(object):
# check if CP/etc/run exists and it is a directory
# 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/run
# iterate over each file in CP/etc/service adding WatchdogID to their name
# 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
=
[]
runner_list
=
[]
service_list
=
[]
service_list
=
[]
if
os
.
path
.
exists
(
self
.
run_path
):
if
os
.
path
.
exists
(
self
.
run_path
):
...
...
slapos/grid/utils.py
View file @
39b63e08
...
@@ -41,7 +41,7 @@ from hashlib import md5
...
@@ -41,7 +41,7 @@ from hashlib import md5
# Such umask by default will create paths with full permission
# Such umask by default will create paths with full permission
# for user, non writable by group and not accessible by others
# for user, non writable by group and not accessible by others
SAFE_UMASK
=
027
SAFE_UMASK
=
0
o
27
PYTHON_ENVIRONMENT_REMOVE_LIST
=
[
PYTHON_ENVIRONMENT_REMOVE_LIST
=
[
'PYTHONHOME'
,
'PYTHONHOME'
,
...
@@ -331,7 +331,7 @@ def launchBuildout(path, buildout_binary,
...
@@ -331,7 +331,7 @@ def launchBuildout(path, buildout_binary,
logger
.
debug
(
'Restore umask from %03o to %03o'
%
(
old_umask
,
umask
))
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."""
"""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
\
...
@@ -343,15 +343,15 @@ def updateFile(file_path, content, mode='0600'):
...
@@ -343,15 +343,15 @@ def updateFile(file_path, content, mode='0600'):
file_file
.
flush
()
file_file
.
flush
()
file_file
.
close
()
file_file
.
close
()
os
.
chmod
(
file_path
,
stat
.
S_IREAD
|
stat
.
S_IWRITE
|
stat
.
S_IEXEC
)
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
:
if
stat
.
S_IMODE
(
os
.
stat
(
file_path
).
st_mode
)
!=
mode
:
os
.
chmod
(
file_path
,
int
(
mode
,
8
)
)
os
.
chmod
(
file_path
,
mode
)
altered
=
True
altered
=
True
return
altered
return
altered
def
updateExecutable
(
executable_path
,
content
):
def
updateExecutable
(
executable_path
,
content
):
"""Creates an executable with "content" as content."""
"""Creates an executable with "content" as content."""
return
updateFile
(
executable_path
,
content
,
'0700'
)
return
updateFile
(
executable_path
,
content
,
0o700
)
def
createPrivateDirectory
(
path
):
def
createPrivateDirectory
(
path
):
...
@@ -359,8 +359,8 @@ def createPrivateDirectory(path):
...
@@ -359,8 +359,8 @@ def createPrivateDirectory(path):
if
not
os
.
path
.
isdir
(
path
):
if
not
os
.
path
.
isdir
(
path
):
os
.
mkdir
(
path
)
os
.
mkdir
(
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
=
oct
(
stat
.
S_IMODE
(
os
.
stat
(
path
).
st_mode
)
)
permission
=
stat
.
S_IMODE
(
os
.
stat
(
path
).
st_mode
)
if
permission
not
in
(
'0700'
)
:
if
permission
!=
0o700
:
raise
WrongPermissionError
(
'Wrong permissions in %s '
\
raise
WrongPermissionError
(
'Wrong permissions in %s
:
'
\
': is %s
, 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