Wed 26 Dec 2007 06:23:20 PM UTC, comment #5:
Alrighty, I'll reopen this so we can discuss.
Let me get this straight: rdiff-backup runs as UID X, writes files as owned by UID Y, which have permission 000, but it is able to chmod those files? Wouldn't it have to chmod them to 004 (or better, 044) in order to read them?
You need to narrow your except statements so that you don't catch errors you don't know how to handle. If we take your new patch, it should look like:
sig = Null
try:
sig = Rdiff.get_signature(dest_rp)
except IOError, e:
if (e.errno == errno.EPERM):
try:
dest_rp.chmod(0400 | dest_rp.getperms())
except IOError, e:
if (e.errno == errno.EPERM):
log.Log.FatalError("Could not open...")
else:
raise
sig = Rdiff.get_signature(dest_rp)
else:
raise
return sig
Now, I imagine that the above code is a good deal slower than the code currently in rdiff-backup. Also, the first except clause is going to be hit fairly often because it replaces the original if statement that used to handle the chmod. The try/except machinery is slower than an if statement.
This code is along a critical path: get_one_sig_fp() gets hit once for every regular file. AFS sounds like a pretty sophisticated filesystem that made the mistake of trying to live in a Unix environment. :-)
I noticed you also submited a patch in Debian for AFS. If I'm reading that one correctly, ideally you would want to see the high_perms test broken into high_perms_files and high_perms_dirs tests, so that rdiff-backup could set those independently. Right?
|
Wed 26 Dec 2007 07:05:31 AM UTC, comment #3:
I don't think your patch will do the right thing in my environment. AFS is weird. It's possible to have a process which is authenticated to AFS in such a way that the files it writes have a different uid than the process's uid. If you think of NFS's root/anon mapping, you'll get the right idea, although the mechanism is different, and the process is not owned by root. In addition, AFS has directory acls which are more powerful that stat() can represent, so they are invisible to stat().
In my situation, I have a rdiff-backup process running as uid X which is writing files owned by uid Y. This process will also be able to chmod the files it creates. If the file is mode 600, then the the new code will not assert, but because dest_rp.readable() is false, get_one_sig will return None, which I think will cause those files not to be backed up (this is inconvenient for me to test).
In general, I think code which presumes filesystem semantics is always going to be more fragile than simply performing the necessary operations, and handling exceptions if they occur.
Taken to the logical extreme, this would argue for an even simpler method body than in my original patch:
try:
return Rdiff.get_signature(dest_rp)
except:
# This branch can happen with root source and non-root
# destination. Permissions are changed permanently, which
# should propogate to the diffs
dest_rp.chmod(0400 | dest_rp.getperms())
return Rdiff.get_signature(dest_rp)
|
Mon 01 Oct 2007 04:29:46 AM UTC, original submission:
Hi
I'm a new user and try to use rdiff-backup in my environnement.
I got the foillowing problem with 1.05 and reproduce it with 1.1.14
The first rdiff backup is ok, but the following rdiff crash with traceback.
I made some tracking, but i'm new in python. This patch seems working, but i don't know the reason of the 'assert'
--- backup.py.old 2007-10-01 06:22:17.000000000 +0200
+++ backup.py 2007-09-30 22:30:51.000000000 +0200
@@ -206,7 +206,8 @@
# This branch can happen with root source and non-root
# destination. Permissions are changed permanently, which
# should propogate to the diffs
- assert dest_rp.isowner(), 'no ownership of %s' % (dest_rp.path,)
+ #assert dest_rp.isowner(), 'no ownership of %s' % (dest_rp.path,)
+ dest_rp.isowner()
dest_rp.chmod(0400 | dest_rp.getperms())
return Rdiff.get_signature(dest_rp)
My environnement :
fedora 7 lanch a rdiff on a nfs mounted directory (/net/d2r2/BACKUP/...)
The nfs has the particularity to force mapping of user :
/BACKUP *(rw,all_squash,anonuid=99,anongid=99)
Here is the end of the log (level 9)
Sun Sep 30 12:32:13 2007 Regressing attributes of /net/d2r2/BACKUP/nx/rdiff/Private/Thunderbird/extensions/{e9a9c0c3-8673-ae31-8a09-b52878ed1e}/uninstall
Sun Sep 30 12:32:13 2007 Copying attributes from ('Thunderbird', 'extensions', '{e9a9c0c3-8673-ae31-8a09-b52878ed1e}', 'uninstall') to /net/d2r2/BACKUP/nx/rdiff/Private/Thunderbird/extensions/{e9a9c0c3-8673-ae31-8a09-b52878ed1e}/uninstall
Sun Sep 30 12:32:13 2007 Setting time of /net/d2r2/BACKUP/nx/rdiff/Private/Thunderbird/extensions/{e9a9c0c3-8673-ae31-8a09-b52878ed1e}/uninstall to 1113044062
Sun Sep 30 12:32:13 2007 Regressing attributes of /net/d2r2/BACKUP/nx/rdiff/Private/Thunderbird/extensions/{e9a9c0c3-8673-ae31-8a09-b52878ed1e}
Sun Sep 30 12:32:13 2007 Copying attributes from ('Thunderbird', 'extensions', '{e9a9c0c3-8673-ae31-8a09-b52878ed1e}') to /net/d2r2/BACKUP/nx/rdiff/Private/ThunderbiSun Sep 30 12:32:14 2007 Exception 'no ownership of /net/d2r2/BACKUP/nx/rdiff/Private/Admin/Admin/Redhat.pdf' raised of class '<type 'exceptions.AssertionError'>':
File "/usr/lib/python2.5/site-packages/rdiff_backup/Main.py", line 302, in error_check_Main
try: Main(arglist)
File "/usr/lib/python2.5/site-packages/rdiff_backup/Main.py", line 322, in Main
take_action(rps)
File "/usr/lib/python2.5/site-packages/rdiff_backup/Main.py", line 278, in take_action
elif action == "backup": Backup(rps[0], rps[1])
File "/usr/lib/python2.5/site-packages/rdiff_backup/Main.py", line 341, in Backup
backup.Mirror_and_increment(rpin, rpout, incdir)
File "/usr/lib/python2.5/site-packages/rdiff_backup/backup.py", line 51, in Mirror_and_increment
DestS.patch_and_increment(dest_rpath, source_diffiter, inc_rpath)
File "/usr/lib/python2.5/site-packages/rdiff_backup/backup.py", line 227, in patch_and_increment
for diff in rorpiter.FillInIter(source_diffiter, dest_rpath):
File "/usr/lib/python2.5/site-packages/rdiff_backup/rorpiter.py", line 169, in FillInIter
first_rp = rpiter.next() # StopIteration gets passed upwards
File "/usr/lib/python2.5/site-packages/rdiff_backup/backup.py", line 103, in get_diffs
for dest_sig in dest_sigiter:
File "/usr/lib/python2.5/site-packages/rdiff_backup/backup.py", line 178, in get_sigs
src_rorp, dest_rorp)
File "/usr/lib/python2.5/site-packages/rdiff_backup/backup.py", line 193, in get_one_sig
sig_fp = cls.get_one_sig_fp(dest_rp)
File "/usr/lib/python2.5/site-packages/rdiff_backup/backup.py", line 209, in get_one_sig_fp
assert dest_rp.isowner(), 'no ownership of %s' % (dest_rp.path,)
rd/extensions/{e9a9c0c3-8673-ae31-8a09-b52878ed1e}
Sun Sep 30 12:32:13 2007 Setting time of /net/d2r2/BACKUP/nx/rdiff/Private/Thunderbird/extensions/{e9a9c0c3-8673-ae31-8a09-b52878ed1e} to 1113044062
Sun Sep 30 12:32:13 2007 Regressing attributes of /net/d2r2/BACKUP/nx/rdiff/Private/Thunderbird/extensions
Sun Sep 30 12:32:13 2007 Copying attributes from ('Thunderbird', 'extensions') to /net/d2r2/BACKUP/nx/rdiff/Private/Thunderbird/extensions
Sun Sep 30 12:32:13 2007 Setting time of /net/d2r2/BACKUP/nx/rdiff/Private/Thunderbird/extensions to 1190921064
Sun Sep 30 12:32:13 2007 Regressing attributes of /net/d2r2/BACKUP/nx/rdiff/Private/Thunderbird
Sun Sep 30 12:32:13 2007 Copying attributes from ('Thunderbird',) to /net/d2r2/BACKUP/nx/rdiff/Private/Thunderbird
Sun Sep 30 12:32:13 2007 Setting time of /net/d2r2/BACKUP/nx/rdiff/Private/Thunderbird to 1191087496
Sun Sep 30 12:32:13 2007 Regressing attributes of /net/d2r2/BACKUP/nx/rdiff/Private
Sun Sep 30 12:32:13 2007 Copying attributes from () to /net/d2r2/BACKUP/nx/rdiff/Private
Sun Sep 30 12:32:13 2007 Setting time of /net/d2r2/BACKUP/nx/rdiff/Private to 1183649797
Sun Sep 30 12:32:13 2007 Deleting /net/d2r2/BACKUP/nx/rdiff/Private/rdiff-backup-data/current_mirror.2007-09-30T11:59:19+02:00.data
Sun Sep 30 12:32:13 2007 Reading globbing filelist /tmp/tmp.VHGbvC3005
Sun Sep 30 12:32:13 2007 Reading globbing filelist /tmp/tmp.qzUhzA3003
Sun Sep 30 12:32:13 2007 Writing mirror marker /net/d2r2/BACKUP/nx/rdiff/Private/rdiff-backup-data/current_mirror.2007-09-30T12:26:53+02:00.data
Sun Sep 30 12:32:13 2007 Starting increment operation /home/laurent/Private to /net/d2r2/BACKUP/nx/rdiff/Private
Traceback (most recent call last):
File "/usr/bin/rdiff-backup", line 23, in <module>
rdiff_backup.Main.error_check_Main(sys.argv[1:])
File "/usr/lib/python2.5/site-packages/rdiff_backup/Main.py", line 302, in error_check_Main
try: Main(arglist)
File "/usr/lib/python2.5/site-packages/rdiff_backup/Main.py", line 322, in Main
take_action(rps)
File "/usr/lib/python2.5/site-packages/rdiff_backup/Main.py", line 278, in take_action
elif action == "backup": Backup(rps[0], rps[1])
File "/usr/lib/python2.5/site-packages/rdiff_backup/Main.py", line 341, in Backup
backup.Mirror_and_increment(rpin, rpout, incdir)
File "/usr/lib/python2.5/site-packages/rdiff_backup/backup.py", line 51, in Mirror_and_increment
DestS.patch_and_increment(dest_rpath, source_diffiter, inc_rpath)
File "/usr/lib/python2.5/site-packages/rdiff_backup/backup.py", line 227, in patch_and_increment
for diff in rorpiter.FillInIter(source_diffiter, dest_rpath):
File "/usr/lib/python2.5/site-packages/rdiff_backup/rorpiter.py", line 169, in FillInIter
first_rp = rpiter.next() # StopIteration gets passed upwards
File "/usr/lib/python2.5/site-packages/rdiff_backup/backup.py", line 103, in get_diffs
for dest_sig in dest_sigiter:
File "/usr/lib/python2.5/site-packages/rdiff_backup/backup.py", line 178, in get_sigs
src_rorp, dest_rorp)
File "/usr/lib/python2.5/site-packages/rdiff_backup/backup.py", line 193, in get_one_sig
sig_fp = cls.get_one_sig_fp(dest_rp)
File "/usr/lib/python2.5/site-packages/rdiff_backup/backup.py", line 209, in get_one_sig_fp
assert dest_rp.isowner(), 'no ownership of %s' % (dest_rp.path,)
AssertionError: no ownership of /net/d2r2/BACKUP/nx/rdiff/Private/Admin/Admin/Redhat.pdf
====>>>>> Error backup rdiff
|