[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Rdiff-backup-commits] rdiff-backup/rdiff_backup Globals.py fs_abiliti..
From: |
Andrew Ferguson |
Subject: |
[Rdiff-backup-commits] rdiff-backup/rdiff_backup Globals.py fs_abiliti... |
Date: |
Fri, 29 Dec 2006 16:10:15 +0000 |
CVSROOT: /sources/rdiff-backup
Module name: rdiff-backup
Changes by: Andrew Ferguson <owsla> 06/12/29 16:10:15
Modified files:
rdiff_backup : Globals.py fs_abilities.py rpath.py
Log message:
Add global to avoid unnecessary system calls on systems where umask
does not affect symlinks
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/rdiff-backup/rdiff_backup/Globals.py?cvsroot=rdiff-backup&r1=1.42&r2=1.43
http://cvs.savannah.gnu.org/viewcvs/rdiff-backup/rdiff_backup/fs_abilities.py?cvsroot=rdiff-backup&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/rdiff-backup/rdiff_backup/rpath.py?cvsroot=rdiff-backup&r1=1.103&r2=1.104
Patches:
Index: Globals.py
===================================================================
RCS file: /sources/rdiff-backup/rdiff-backup/rdiff_backup/Globals.py,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- Globals.py 24 Nov 2005 05:07:09 -0000 1.42
+++ Globals.py 29 Dec 2006 16:10:15 -0000 1.43
@@ -221,6 +221,11 @@
# prevent highbit permissions on systems which don't support them.)
permission_mask = 07777
+# If true, symlinks permissions are affected by the process umask, and
+# we should change the umask when creating them in order to preserve
+# the original permissions
+symlink_perms = None
+
def get(name):
"""Return the value of something in this module"""
return globals()[name]
Index: fs_abilities.py
===================================================================
RCS file: /sources/rdiff-backup/rdiff-backup/rdiff_backup/fs_abilities.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- fs_abilities.py 11 Jan 2006 21:23:30 -0000 1.28
+++ fs_abilities.py 29 Dec 2006 16:10:15 -0000 1.29
@@ -46,6 +46,7 @@
name = None # Short string, not used for any technical purpose
read_only = None # True if capabilities were determined
non-destructively
high_perms = None # True if suid etc perms are (read/write) supported
+ symlink_perms = None # True if symlink perms are affected by umask
def __init__(self, name = None):
"""FSAbilities initializer. name is only used in logging"""
@@ -87,6 +88,7 @@
('Directory inc
permissions',
self.dir_inc_perms),
('High-bit
permissions', self.high_perms),
+ ('Symlink
permissions', self.symlink_perms),
('Extended
filenames', self.extended_filenames)])
add_boolean_list([('Access control lists', self.acls),
('Extended attributes',
self.eas),
@@ -145,6 +147,7 @@
self.set_resource_fork_readwrite(subdir)
self.set_carbonfile()
self.set_high_perms_readwrite(subdir)
+ self.set_symlink_perms(subdir)
subdir.delete()
return self
@@ -395,6 +398,21 @@
else: self.high_perms = 1
tmp_rp.delete()
+ def set_symlink_perms(self, dir_rp):
+ """Test if symlink permissions are affected by umask"""
+ sym_source = dir_rp.append("symlinked_file1")
+ sym_source.touch()
+ sym_dest = dir_rp.append("symlinked_file2")
+ sym_dest.symlink(sym_source.path)
+ sym_dest.setdata()
+ assert sym_dest.issym()
+ orig_umask = os.umask(077)
+ if sym_dest.getperms() == 0700: self.symlink_perms = 1
+ else: self.symlink_perms = 0
+ os.umask(orig_umask)
+ sym_dest.delete()
+ sym_source.delete()
+
def get_readonly_fsa(desc_string, rp):
"""Return an fsa with given description_string
@@ -455,6 +473,9 @@
if not self.dest_fsa.high_perms:
SetConnections.UpdateGlobal('permission_mask', 0777)
+ def set_symlink_perms(self):
+ SetConnections.UpdateGlobal('symlink_perms',
+
self.dest_fsa.symlink_perms)
class BackupSetGlobals(SetGlobals):
"""Functions for setting fsa related globals for backup session"""
@@ -612,6 +633,7 @@
bsg.set_fsync_directories()
bsg.set_change_ownership()
bsg.set_high_perms()
+ bsg.set_symlink_perms()
bsg.set_chars_to_quote(Globals.rbdir)
def restore_set_globals(rpout):
@@ -632,6 +654,7 @@
# No need to fsync anything when restoring
rsg.set_change_ownership()
rsg.set_high_perms()
+ rsg.set_symlink_perms()
rsg.set_chars_to_quote(Globals.rbdir)
def single_set_globals(rp, read_only = None):
@@ -650,5 +673,6 @@
ssg.set_hardlinks()
ssg.set_change_ownership()
ssg.set_high_perms()
+ ssg.set_symlink_perms()
ssg.set_chars_to_quote(Globals.rbdir)
Index: rpath.py
===================================================================
RCS file: /sources/rdiff-backup/rdiff-backup/rdiff_backup/rpath.py,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -b -r1.103 -r1.104
--- rpath.py 5 Nov 2006 20:25:02 -0000 1.103
+++ rpath.py 29 Dec 2006 16:10:15 -0000 1.104
@@ -103,9 +103,9 @@
elif rpin.issym():
# some systems support permissions for symlinks, but
# only by setting at creation via the umask
- orig_umask = os.umask(0777 & ~rpin.getperms())
+ if Globals.symlink_perms: orig_umask = os.umask(0777 &
~rpin.getperms())
rpout.symlink(rpin.readlink())
- os.umask(orig_umask) # restore previous umask
+ if Globals.symlink_perms: os.umask(orig_umask) # restore
previous umask
elif rpin.ischardev():
major, minor = rpin.getdevnums()
rpout.makedev("c", major, minor)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Rdiff-backup-commits] rdiff-backup/rdiff_backup Globals.py fs_abiliti...,
Andrew Ferguson <=