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

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

[rdiff-backup-users] rdiff-backup on Windows


From: Josh Nisly
Subject: [rdiff-backup-users] rdiff-backup on Windows
Date: Tue, 08 Apr 2008 21:34:54 -0500
User-agent: Thunderbird 2.0.0.12 (X11/20080227)

Here are the first of the patches to the python code itself in order to run on Windows.

The fs_abilities.py changes are because we test many different file system operations in order to see if they are supported, and catch exceptions to see if they aren't. In the changed functions, the python functions being called simply don't exist on Windows, raising an attribute error. We just catch this like we catch IOError and OSError.

Python on Windows also doesn't have the getuid(), getguid(), etc. functions. What I've done is caught this case, and we simply act as if we are running as root (UID and GID of 0.) I think this is ok, at least in the short term, for the following reasons. First, most users are running their computer as administrator. This gives them read/write access to almost all the files on their computer. (Hard to believe with a unix background, but true.) Secondly, on restore, a typical user doesn't care (or even know) about things like file ownership, so restoring all files with the user running the process as the owner is fine.

I don't think this behavior is ideal, and would like to eventually try to come up with a way to determine it (probably with a C module), but I believe that it is much better to get a working port that most people can use and fix the problems with it, then work on perfecting permissions.

Thanks,
JoshN
--- rdiff_backup/fs_abilities.py        2008-01-03 09:36:48.000000000 -0600
+++ rdiff_backup/fs_abilities.py        2008-04-05 14:30:35.390625000 -0500
@@ -169,7 +169,7 @@
                try:
                        tmp_rp.chown(uid+1, gid+1) # just choose random uid/gid
                        tmp_rp.chown(0, 0)
-               except (IOError, OSError): self.ownership = 0
+               except (IOError, OSError, AttributeError): self.ownership = 0
                else: self.ownership = 1
                tmp_rp.delete()
 
@@ -184,7 +184,7 @@
                        hl_dest.hardlink(hl_source.path)
                        if hl_source.getinode() != hl_dest.getinode():
                                raise IOError(errno.EOPNOTSUPP, "Hard links 
don't compare")
-               except (IOError, OSError):
+               except (IOError, OSError, AttributeError):
                        if Globals.preserve_hardlinks != 0:
                                log.Log("Warning: hard linking not supported by 
filesystem "
                                                "at %s" % (self.root_rp.path,), 
3)
@@ -455,7 +455,7 @@
                sym_dest = dir_rp.append("symlinked_file2")
                try:
                        sym_dest.symlink(sym_source.path)
-               except (OSError):
+               except (OSError, AttributeError):
                        self.symlink_perms = 0
                else:
                        sym_dest.setdata()

--- rdiff_backup/Globals.py     2008-01-03 09:36:49.000000000 -0600
+++ rdiff_backup/Globals.py     2008-04-05 14:30:35.375000000 -0500
@@ -47,9 +47,14 @@
 
 # uid and gid of the owner of the rdiff-backup process.  This can
 # vary depending on the connection.
-process_uid = os.getuid()
-process_gid = os.getgid()
-process_groups = [process_gid] + os.getgroups()
+try:
+    process_uid = os.getuid()
+    process_gid = os.getgid()
+    process_groups = [process_gid] + os.getgroups()
+except AttributeError:
+    process_uid = 0
+    process_gid = 0
+    process_groups = [0]
 
 # If true, when copying attributes, also change target's uid/gid
 change_ownership = None


reply via email to

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