rdiff-backup-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [rdiff-backup-users] [PATCH] Preserve symlink permissions


From: Blair Zajac
Subject: Re: [rdiff-backup-users] [PATCH] Preserve symlink permissions
Date: Sun, 5 Nov 2006 10:02:40 -0800


On Nov 4, 2006, at 1:53 PM, Andrew Ferguson wrote:

Hi,

Some Unix systems (at least the *BSDs and Mac OS X) set the permission
bits on symbolic links to "777 - umask" at link creation. This is
different from Linux, where all symbolic links are mode 777.

This patch changes rdiff-backup's umask temporarily when it creates
symbolic links so that their exact permissions are maintained during
backup and restore. The patch is against the current CVS repository, but
should also work for 1.1.x and 1.0.x versions.

Although the permission bits seem to have no effect, I created this
patch so that rdiff-backup comes even closer to making a perfect backup
on BSD-like systems. It has been tested on Linux, Mac OS X, and during
network backup and restore.

Cheers,
Andrew

--
Andrew Ferguson - address@hidden

diff -Nur rdiff-backup-cvs/rdiff_backup/rpath.py rdiff-backup- symlink-perms/rdiff_backup/rpath.py --- rdiff-backup-cvs/rdiff_backup/rpath.py 2006-01-13 00:29:47.000000000 -0500 +++ rdiff-backup-symlink-perms/rdiff_backup/rpath.py 2006-11-04 15:55:39.000000000 -0500
@@ -100,7 +100,12 @@

        if rpin.isreg(): return copy_reg_file(rpin, rpout, compress)
        elif rpin.isdir(): rpout.mkdir()
-       elif rpin.issym(): rpout.symlink(rpin.readlink())
+       elif rpin.issym():
+               # some systems support permissions for symlinks, but
+               # only by setting at creation via the umask
+               os.umask(0777 - rpin.getperms())
+               rpout.symlink(rpin.readlink())
+               os.umask(077)   # restore rdiff-backup standard umask

I think it would be clearer to do something like this saving the current result of the umask, so if the umask is changed anywhere else, it'll always be restored:

                # some systems support permissions for symlinks, but
                # only by setting at creation via the umask
                orig_umask = os.umask(0777 - rpin.getperms())
                rpout.symlink(rpin.readlink())
                os.umask(orig_umask)

Regards,
Blair

--
Blair Zajac, Ph.D.
CTO, OrcaWare Technologies
<address@hidden>
Subversion training, consulting and support
http://www.orcaware.com/svn/






reply via email to

[Prev in Thread] Current Thread [Next in Thread]