summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorowsla <owsla@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2008-04-13 11:25:22 +0000
committerowsla <owsla@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2008-04-13 11:25:22 +0000
commitb03c72c54cf5f650ffbc76768ce74f37bb24269b (patch)
tree85711a1467afd171f1f43b59060b648b2042b1eb
parente0169c64228d64cf857d486c897f41ed074cbab4 (diff)
downloadrdiff-backup-b03c72c54cf5f650ffbc76768ce74f37bb24269b.tar.gz
Handle Windows' lack of getuid(), getgid(), hardlinks and symlinks in
fs_abilities.py. Use subproces.Popen() on Windows since it does not support os.popen2(). (Patch from Josh Nisly) git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@883 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
-rw-r--r--rdiff-backup/CHANGELOG4
-rw-r--r--rdiff-backup/rdiff_backup/Globals.py11
-rw-r--r--rdiff-backup/rdiff_backup/SetConnections.py9
-rw-r--r--rdiff-backup/rdiff_backup/fs_abilities.py6
4 files changed, 23 insertions, 7 deletions
diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG
index 40fd33b..a7dba33 100644
--- a/rdiff-backup/CHANGELOG
+++ b/rdiff-backup/CHANGELOG
@@ -1,6 +1,10 @@
New in v1.1.16 (????/??/??)
---------------------------
+Handle Windows' lack of getuid(), getgid(), hardlinks and symlinks in
+fs_abilities.py. Use subproces.Popen() on Windows since it does not support
+os.popen2(). (Patch from Josh Nisly)
+
Let setup.py accept arguments on Windows. (Patch from Josh Nisly)
Get cmodule.c building natively on Windows. (Patch from Josh Nisly)
diff --git a/rdiff-backup/rdiff_backup/Globals.py b/rdiff-backup/rdiff_backup/Globals.py
index 9a71ce9..740127c 100644
--- a/rdiff-backup/rdiff_backup/Globals.py
+++ b/rdiff-backup/rdiff_backup/Globals.py
@@ -47,9 +47,14 @@ server = None
# 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
diff --git a/rdiff-backup/rdiff_backup/SetConnections.py b/rdiff-backup/rdiff_backup/SetConnections.py
index 0d30cf0..176dd6a 100644
--- a/rdiff-backup/rdiff_backup/SetConnections.py
+++ b/rdiff-backup/rdiff_backup/SetConnections.py
@@ -132,7 +132,14 @@ def init_connection(remote_cmd):
if not remote_cmd: return Globals.local_connection
Log("Executing " + remote_cmd, 4)
- stdin, stdout = os.popen2(remote_cmd)
+ if os.name == "nt":
+ import subprocess
+ process = subprocess.Popen(remote_cmd, shell=False, bufsize=0,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE)
+ (stdin, stdout) = (process.stdin, process.stdout)
+ else:
+ stdin, stdout = os.popen2(remote_cmd)
conn_number = len(Globals.connections)
conn = connection.PipeConnection(stdout, stdin, conn_number)
diff --git a/rdiff-backup/rdiff_backup/fs_abilities.py b/rdiff-backup/rdiff_backup/fs_abilities.py
index a45a8f9..cf7c88c 100644
--- a/rdiff-backup/rdiff_backup/fs_abilities.py
+++ b/rdiff-backup/rdiff_backup/fs_abilities.py
@@ -169,7 +169,7 @@ class FSAbilities:
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 @@ class FSAbilities:
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)
@@ -460,7 +460,7 @@ class FSAbilities:
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()