Commit 544376ef authored by owsla's avatar owsla

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@883 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent 9cb482ee
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)
......
......@@ -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
......
......@@ -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)
......
......@@ -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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment