From: Rob Browning Date: Sat, 9 Oct 2010 17:57:26 +0000 (-0500) Subject: Add metadata test_restore_restricted_user_group(). X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=c6196bd608e1a5f335454881177edb0ab4b319a8;p=packages%2Fb%2Fbup.git Add metadata test_restore_restricted_user_group(). --- diff --git a/lib/bup/t/tmetadata.py b/lib/bup/t/tmetadata.py index e5973f6..5e5be58 100644 --- a/lib/bup/t/tmetadata.py +++ b/lib/bup/t/tmetadata.py @@ -123,3 +123,26 @@ def test_apply_to_path_error(): subprocess.call(['chmod', '700', tmpdir]) finally: subprocess.call(['rm', '-rf', tmpdir]) + + +@wvtest +def test_restore_restricted_user_group(): + if os.geteuid == 0 or detect_fakeroot(): + return + tmpdir = tempfile.mkdtemp(prefix='bup-tmetadata-') + try: + path = tmpdir + '/foo' + subprocess.call(['mkdir', path]) + m = metadata.from_path(path, archive_path=path, save_symlinks=True) + WVPASSEQ(m.path, path) + WVPASSEQ(m.apply_to_path(path), None) + orig_uid = m.uid + m.uid = 0; + WVEXCEPT(metadata.MetadataApplicationError, + m.apply_to_path, path, restore_numeric_ids=True) + m.uid = orig_uid + m.gid = 0; + WVEXCEPT(metadata.MetadataApplicationError, + m.apply_to_path, path, restore_numeric_ids=True) + finally: + subprocess.call(['rm', '-rf', tmpdir])