[debian-edu-commits] debian-edu/upstream/ 60/71: Do not call chown -R, implemnt it in python instead.

Petter Reinholdtsen pere at moszumanska.debian.org
Mon Jun 9 18:25:40 UTC 2014


This is an automated email from the git hooks/post-receive script.

pere pushed a commit to branch master
in repository libpam-mklocaluser.

commit a30ba8c6944bfe1390eb6994b527677204d68f7a
Author: Petter Reinholdtsen <pere at hungry.com>
Date:   Sat May 4 06:58:09 2013 +0000

    Do not call chown -R, implemnt it in python instead.
---
 debian/changelog     |  1 +
 debian/pam-python.py | 10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 5e2c2ce..08a9fe5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,7 @@ libpam-mklocaluser (0.8) UNRELEASED; urgency=low
     calling "echo 'something' >> /etc/file" in a subshell.
   * Do not try to syslog an exception, as a string is needed in newer
     python versions.
+  * Do not call chown -R, implemnt it in python instead.
 
  -- Petter Reinholdtsen <pere at debian.org>  Sat, 04 May 2013 08:25:53 +0200
 
diff --git a/debian/pam-python.py b/debian/pam-python.py
index 144e8da..5d293f8 100755
--- a/debian/pam-python.py
+++ b/debian/pam-python.py
@@ -20,6 +20,13 @@ def append_line(filename, line):
   f.write(line)
   f.close()
 
+def chown_recursive(path, uid, gid):
+  for root, dirs, files in os.walk(path):  
+    for dirname in dirs:  
+      os.chown(os.path.join(root, dirname), uid, gid)
+    for filename in files:
+      os.chown(os.path.join(root, filename), uid, gid)
+
 # FIXME This function always report an error
 def runcmd(pamh, cmd):
   proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,)
@@ -105,8 +112,7 @@ def check_and_create_localuser(pamh, user):
 
       # Change perm of new home dir
       os.chmod(newhomedir, dirmode)
-      # os.chown(newhomedir, uid, gid) - not recursive
-      runcmd(pamh, "/bin/chown -R %d:%d '%s'" % (uid, gid, newhomedir))
+      chown_recursive(newhomedir, uid, gid)
 
       # Flush nscd cache to get rid of original user entry
       if os.access("/usr/sbin/nscd", os.X_OK):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/upstream/libpam-mklocaluser.git



More information about the debian-edu-commits mailing list