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
Lu Xu
slapos.core
Commits
f19053df
Commit
f19053df
authored
Jun 14, 2011
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Import getpwnam directly.
Prepares for incomming monkey-patching.
parent
050aadbe
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
slapos/format/__init__.py
slapos/format/__init__.py
+6
-6
No files found.
slapos/format/__init__.py
View file @
f19053df
...
@@ -27,13 +27,13 @@
...
@@ -27,13 +27,13 @@
##############################################################################
##############################################################################
from
optparse
import
OptionParser
,
Option
from
optparse
import
OptionParser
,
Option
from
xml_marshaller
import
xml_marshaller
from
xml_marshaller
import
xml_marshaller
from
pwd
import
getpwnam
import
ConfigParser
import
ConfigParser
import
grp
import
grp
import
logging
import
logging
import
netaddr
import
netaddr
import
netifaces
import
netifaces
import
os
import
os
import
pwd
import
random
import
random
import
slapos.slap
as
slap
import
slapos.slap
as
slap
import
socket
import
socket
...
@@ -306,7 +306,7 @@ class Computer:
...
@@ -306,7 +306,7 @@ class Computer:
slapsoft
.
path
=
self
.
software_root
slapsoft
.
path
=
self
.
software_root
if
alter_user
:
if
alter_user
:
slapsoft
.
create
()
slapsoft
.
create
()
slapsoft_pw
=
pwd
.
getpwnam
(
slapsoft
.
name
)
slapsoft_pw
=
getpwnam
(
slapsoft
.
name
)
os
.
chown
(
self
.
software_root
,
slapsoft_pw
.
pw_uid
,
slapsoft_pw
.
pw_gid
)
os
.
chown
(
self
.
software_root
,
slapsoft_pw
.
pw_uid
,
slapsoft_pw
.
pw_gid
)
os
.
chmod
(
self
.
software_root
,
0755
)
os
.
chmod
(
self
.
software_root
,
0755
)
...
@@ -391,7 +391,7 @@ class Partition:
...
@@ -391,7 +391,7 @@ class Partition:
if
not
os
.
path
.
exists
(
self
.
path
):
if
not
os
.
path
.
exists
(
self
.
path
):
os
.
mkdir
(
self
.
path
,
0750
)
os
.
mkdir
(
self
.
path
,
0750
)
if
alter_user
:
if
alter_user
:
owner_pw
=
pwd
.
getpwnam
(
owner
.
name
)
owner_pw
=
getpwnam
(
owner
.
name
)
os
.
chown
(
self
.
path
,
owner_pw
.
pw_uid
,
owner_pw
.
pw_gid
)
os
.
chown
(
self
.
path
,
owner_pw
.
pw_uid
,
owner_pw
.
pw_gid
)
os
.
chmod
(
self
.
path
,
0750
)
os
.
chmod
(
self
.
path
,
0750
)
...
@@ -433,7 +433,7 @@ class User:
...
@@ -433,7 +433,7 @@ class User:
user_parameter_list
.
extend
([
'-G'
,
','
.
join
(
self
.
additional_group_list
)])
user_parameter_list
.
extend
([
'-G'
,
','
.
join
(
self
.
additional_group_list
)])
user_parameter_list
.
append
(
self
.
name
)
user_parameter_list
.
append
(
self
.
name
)
try
:
try
:
pwd
.
getpwnam
(
self
.
name
)
getpwnam
(
self
.
name
)
except
KeyError
:
except
KeyError
:
callAndRead
([
'useradd'
]
+
user_parameter_list
)
callAndRead
([
'useradd'
]
+
user_parameter_list
)
else
:
else
:
...
@@ -451,7 +451,7 @@ class User:
...
@@ -451,7 +451,7 @@ class User:
"""
"""
try
:
try
:
pwd
.
getpwnam
(
self
.
name
)
getpwnam
(
self
.
name
)
return
True
return
True
except
KeyError
:
except
KeyError
:
...
@@ -489,7 +489,7 @@ class Tap:
...
@@ -489,7 +489,7 @@ class Tap:
owner_id
=
int
(
open
(
check_file
).
read
().
strip
())
owner_id
=
int
(
open
(
check_file
).
read
().
strip
())
except
Exception
:
except
Exception
:
pass
pass
if
(
owner_id
is
None
)
or
(
owner_id
!=
pwd
.
getpwnam
(
owner
.
name
).
pw_uid
):
if
(
owner_id
is
None
)
or
(
owner_id
!=
getpwnam
(
owner
.
name
).
pw_uid
):
callAndRead
([
'tunctl'
,
'-t'
,
self
.
name
,
'-u'
,
owner
.
name
])
callAndRead
([
'tunctl'
,
'-t'
,
self
.
name
,
'-u'
,
owner
.
name
])
callAndRead
([
'ip'
,
'link'
,
'set'
,
self
.
name
,
'up'
])
callAndRead
([
'ip'
,
'link'
,
'set'
,
self
.
name
,
'up'
])
...
...
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