From b994203c016fa479d87b35ebcbb1bead30ab44e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Sat, 18 May 2013 23:03:16 +0200 Subject: [PATCH] chmod should be called before chown to avoid SUID and SGRP reset. --- darc/archive.py | 8 ++++---- darc/test.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/darc/archive.py b/darc/archive.py index 9075df5db..862c69905 100644 --- a/darc/archive.py +++ b/darc/archive.py @@ -285,10 +285,6 @@ class Archive(object): xa.set(k, v) except (IOError, KeyError): pass - if have_lchmod: - os.lchmod(path, item['mode']) - elif not symlink: - os.chmod(path, item['mode']) uid = gid = None if not self.numeric_owner: uid = user2uid(item['user']) @@ -299,6 +295,10 @@ class Archive(object): os.lchown(path, uid, gid) except OSError: pass + if have_lchmod: + os.lchmod(path, item['mode']) + elif not symlink: + os.chmod(path, item['mode']) if not symlink: # FIXME: We should really call futimes here (c extension required) os.utime(path, (item['mtime'], item['mtime'])) diff --git a/darc/test.py b/darc/test.py index 54fd03588..ad93bd43e 100644 --- a/darc/test.py +++ b/darc/test.py @@ -104,7 +104,7 @@ class Test(unittest.TestCase): # File owner os.chown('input/file1', 100, 200) # File mode - os.chmod('input/file1', 0600) + os.chmod('input/file1', 7755) os.chmod('input/dir2', 0700) # Block device os.mknod('input/bdev', 0600 | stat.S_IFBLK, os.makedev(10, 20))