Commit 4d8a1270 authored by Jean-Baptiste Petre's avatar Jean-Baptiste Petre

chownDirectory recursif

parent ff280e4f
...@@ -65,6 +65,7 @@ def prettify_xml(xml): ...@@ -65,6 +65,7 @@ def prettify_xml(xml):
from slapos.util import mkdir_p from slapos.util import mkdir_p
from slapos.util import chownDirectory
class OS(object): class OS(object):
"""Wrap parts of the 'os' module to provide logging of performed actions.""" """Wrap parts of the 'os' module to provide logging of performed actions."""
...@@ -383,7 +384,7 @@ class Computer(object): ...@@ -383,7 +384,7 @@ class Computer(object):
if alter_user: if alter_user:
slapsoft.create() slapsoft.create()
slapsoft_pw = pwd.getpwnam(slapsoft.name) slapsoft_pw = pwd.getpwnam(slapsoft.name)
os.chown(self.software_root, slapsoft_pw.pw_uid, slapsoft_pw.pw_gid) chownDirectory(path, uid, gid)
os.chmod(self.software_root, 0755) os.chmod(self.software_root, 0755)
# Speed hack: # Speed hack:
...@@ -505,7 +506,7 @@ class Partition(object): ...@@ -505,7 +506,7 @@ class Partition(object):
os.mkdir(self.path, 0750) os.mkdir(self.path, 0750)
if alter_user: if alter_user:
owner_pw = pwd.getpwnam(owner.name) owner_pw = pwd.getpwnam(owner.name)
os.chown(self.path, owner_pw.pw_uid, owner_pw.pw_gid) chownDirectory(path, uid, gid)
os.chmod(self.path, 0750) os.chmod(self.path, 0750)
......
...@@ -17,3 +17,9 @@ def mkdir_p(path, mode=0o777): ...@@ -17,3 +17,9 @@ def mkdir_p(path, mode=0o777):
else: else:
raise raise
def chownDirectory(path, uid, gid):
for root, dirs, files in os.walk(path):
for items in dirs, files:
for item in items:
os.chown(os.path.join(root, item), uid, gid)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment