]> arthur.barton.de Git - bup.git/commitdiff
Add metadata test_restore_restricted_user_group().
authorRob Browning <rlb@defaultvalue.org>
Sat, 9 Oct 2010 17:57:26 +0000 (12:57 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sat, 9 Oct 2010 17:57:26 +0000 (12:57 -0500)
lib/bup/t/tmetadata.py

index e5973f622a0de48aaffcf94545d2c24ef1fc80bd..5e5be5845100136528511aa2ec63fc927d901c26 100644 (file)
@@ -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])