mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-15 19:06:38 +00:00
chmod should be called before chown to avoid SUID and SGRP reset.
This commit is contained in:
parent
1dc1411302
commit
b994203c01
2 changed files with 5 additions and 5 deletions
|
@ -285,10 +285,6 @@ def restore_attrs(self, path, item, symlink=False):
|
||||||
xa.set(k, v)
|
xa.set(k, v)
|
||||||
except (IOError, KeyError):
|
except (IOError, KeyError):
|
||||||
pass
|
pass
|
||||||
if have_lchmod:
|
|
||||||
os.lchmod(path, item['mode'])
|
|
||||||
elif not symlink:
|
|
||||||
os.chmod(path, item['mode'])
|
|
||||||
uid = gid = None
|
uid = gid = None
|
||||||
if not self.numeric_owner:
|
if not self.numeric_owner:
|
||||||
uid = user2uid(item['user'])
|
uid = user2uid(item['user'])
|
||||||
|
@ -299,6 +295,10 @@ def restore_attrs(self, path, item, symlink=False):
|
||||||
os.lchown(path, uid, gid)
|
os.lchown(path, uid, gid)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
if have_lchmod:
|
||||||
|
os.lchmod(path, item['mode'])
|
||||||
|
elif not symlink:
|
||||||
|
os.chmod(path, item['mode'])
|
||||||
if not symlink:
|
if not symlink:
|
||||||
# FIXME: We should really call futimes here (c extension required)
|
# FIXME: We should really call futimes here (c extension required)
|
||||||
os.utime(path, (item['mtime'], item['mtime']))
|
os.utime(path, (item['mtime'], item['mtime']))
|
||||||
|
|
|
@ -104,7 +104,7 @@ def test_basic_functionality(self):
|
||||||
# File owner
|
# File owner
|
||||||
os.chown('input/file1', 100, 200)
|
os.chown('input/file1', 100, 200)
|
||||||
# File mode
|
# File mode
|
||||||
os.chmod('input/file1', 0600)
|
os.chmod('input/file1', 7755)
|
||||||
os.chmod('input/dir2', 0700)
|
os.chmod('input/dir2', 0700)
|
||||||
# Block device
|
# Block device
|
||||||
os.mknod('input/bdev', 0600 | stat.S_IFBLK, os.makedev(10, 20))
|
os.mknod('input/bdev', 0600 | stat.S_IFBLK, os.makedev(10, 20))
|
||||||
|
|
Loading…
Reference in a new issue