SearchFAQMemberlist Log in
Reply to topic Page 1 of 1
hasfullperms(), isgroup() and funny indexes
Author Message
Post hasfullperms(), isgroup() and funny indexes 
Hi,

This is probably only relevant to Ben and other's who've read some of the code.

We're trying to get the web interface to restores of old versions of directories, however we don't want the webserver to run as anything privileged and we don't want to expose the backup repositories to anything but the webserver. At the moment the webserver is added to the "rbackup" group which is the primary group of all the rdiff-backup. Restoring files seems to work fine, but when we attempt to restore a directory rdiff-backup thinks the webserver isn't a member of the directories' group, and fails when it tries to chmod() the files to 770. I've added a function issecondarygroup() to the rpath class. It currently uses the 'id' program to get all the process' group ids. Total hack, but I couldn't find any python docs that told me do it nicely. Then I 'or'ed that onto the isgroup() return statement. Do you think this is likely to cause problems?

def issecondarygroup(self):
gids = os.popen('id -G').read().strip().split(' ')
for gid in gids:
if self.data['gid'] == int(gid): return 1
return 0

This seems to have worked. However, I get an assert failure in __call__() now. I'm not entirely sure what it does. It seems to be checking if the first element of the index array is higher than the first value of old_index. Not sure why it does that. When I comment it out, it runs OK, but I've probably broken something else. Can you explain what that assert is trying to do?

def __call__(self, rp):
"""Given rpath, change permissions up and including rp"""
index, old_index = rp.index, self.current_index
self.current_index = index
if not index or index == old_index: return
assert index > old_index, (index, old_index)
self.restore_old(rp, index)
self.add_new(rp, old_index, index)

Thanks,
Ryan


Stack trace of assertion error

File "/usr/bin/rdiff-backup", line 23, in ?
rdiff_backup.Main.Main(sys.argv[1:])
File "/usr/lib/python2.3/site-packages/rdiff_backup/Main.py", line 247, in Main
take_action(rps)
File "/usr/lib/python2.3/site-packages/rdiff_backup/Main.py", line 219, in take_action
elif action == "restore": Restore(*rps)
File "/usr/lib/python2.3/site-packages/rdiff_backup/Main.py", line 452, in Restore
inc_rpath, dest_rp, time)
File "/usr/lib/python2.3/site-packages/rdiff_backup/restore.py", line 50, in Restore
TargetS.patch(target, diff_iter)
File "/usr/lib/python2.3/site-packages/rdiff_backup/restore.py", line 280, in patch
for diff in rorpiter.FillInIter(diff_iter, target):
File "/usr/lib/python2.3/site-packages/rdiff_backup/rorpiter.py", line 181, in FillInIter
for rp in rpiter:
File "/usr/lib/python2.3/site-packages/rdiff_backup/restore.py", line 244, in get_diffs_from_collated
diff = cls.get_diff(mir_rorp, target_rorp)
File "/usr/lib/python2.3/site-packages/rdiff_backup/restore.py", line 257, in get_diff
mir_rorp.setfile(cls.rf_cache.get_fp(expanded_index))
File "/usr/lib/python2.3/site-packages/rdiff_backup/restore.py", line 336, in get_fp
rf = self.get_rf(index)
File "/usr/lib/python2.3/site-packages/rdiff_backup/restore.py", line 330, in get_rf
if (index[:-1] == rf.index[:-1] or not
File "/usr/lib/python2.3/site-packages/rdiff_backup/restore.py", line 355, in add_rfs
if Globals.process_uid != 0: self.perm_changer(temp_rf.mirror_rp)
File "/usr/lib/python2.3/site-packages/rdiff_backup/restore.py", line 661, in __call__
assert index > old_index, (index, old_index)
AssertionError: (('etc', '3270'), ('etc', '3270', 'charset', 'thai'))





--
Ryan Castle <ryan < at > solutionsfirst.com.au ([email]ryan < at > solutionsfirst.com.au[/email])>
Solutions First

Post hasfullperms(), isgroup() and funny indexes 

Restoring files seems to work fine, but when we attempt to restore a
directory rdiff-backup thinks the webserver isn't a member of the
directories' group, and fails when it tries to chmod() the files to 770.
I've added a function issecondarygroup() to the rpath class. It
currently uses the 'id' program to get all the process' group ids. Total
hack, but I couldn't find any python docs that told me do it nicely.

What's wrong with 'os.getgroups()'?

David S.

Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
  


Magic SEO URL for phpBB