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

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

Re: [rdiff-backup-users] BUG: directory with no permission


From: Andrew Ferguson
Subject: Re: [rdiff-backup-users] BUG: directory with no permission
Date: Wed, 28 Feb 2007 18:11:09 -0500
User-agent: Thunderbird 1.5.0.9 (Macintosh/20061207)

Frederic Bastien wrote:
> Hi,
> 
> I have found a bug. I'm a Java/C/C++ programmer, so it will be easier 
> for you to correct it them it. I use rdiff-backup 1.1.9. I have 
> simplified the step to reproduce it like this:
> 
> #mkdir t
> #chmod a-rxw t
> #rdiff-backup t t2

Ok, this quick and dirty patch fixes the case you have run into.
However, if rdiff-backup is going to support root source/target
directories that are unreadable, a more extensive patch is needed to
handle --restore, --list-increments, etc.

Does anyone think this patch is on the right track? Suggestions?

Andrew

-- 
Andrew Ferguson - address@hidden

--- rdiff-backup-cvs/rdiff_backup/Main.py       2007-01-29 21:00:34.000000000 
-0500
+++ rdiff-backup-local/rdiff_backup/Main.py     2007-02-28 17:50:35.000000000 
-0500
@@ -286,12 +286,16 @@
        elif action == "verify": Verify(rps[0])
        else: raise AssertionError("Unknown action " + action)
 
-def cleanup():
+def cleanup(rps):
        """Do any last minute cleaning before exiting"""
+       global rpin_perms
        Log("Cleaning up", 6)
        if ErrorLog.isopen(): ErrorLog.close()
        Log.close_logfile()
        if not Globals.server: SetConnections.CloseConnections()
+       if rpin_perms is not None:
+           rps[0].chmod(rpin_perms)
+           rps[1].chmod(rpin_perms)
 
 def error_check_Main(arglist):
        """Run Main on arglist, suppressing stack trace for routine errors"""
@@ -308,6 +312,8 @@
 
 def Main(arglist):
        """Start everything up!"""
+       global rpin_perms
+       rpin_perms = None
        parse_cmdlineoptions(arglist)
        check_action()
        cmdpairs = SetConnections.get_cmd_pairs(args, remote_schema, remote_cmd)
@@ -316,7 +322,7 @@
        final_set_action(rps)
        misc_setup(rps)
        take_action(rps)
-       cleanup()
+       cleanup(rps)
        if return_val is not None: sys.exit(return_val)
 
 def Backup(rpin, rpout):
@@ -355,6 +361,7 @@
 
 def backup_check_dirs(rpin, rpout):
        """Make sure in and out dirs exist and are directories"""
+       global rpin_perms
        if rpout.lstat() and not rpout.isdir():
                if not force: Log.FatalError("Destination %s exists and is not 
a "
                                                                         
"directory" % rpout.path)
@@ -372,6 +379,15 @@
                Log.FatalError("Source directory %s does not exist" % rpin.path)
        elif not rpin.isdir():
                Log.FatalError("Source %s is not a directory" % rpin.path)
+
+       if not rpin.hasfullperms() or not rpout.hasfullperms():
+               if rpin.isowner() and rpout.isowner():
+                       rpin_perms = rpin.getperms()
+                       rpin.chmod(0700)
+                       rpout.chmod(0700)
+               else:
+                   Log.FatalError("Souce directory %s is unreadable" % 
rpin.path)
+
        Globals.rbdir = rpout.append_path("rdiff-backup-data")
 
 def backup_set_rbdir(rpin, rpout):

reply via email to

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