From 66d6de935a32fbf3aae2ef091b417a6572c8e6fd Mon Sep 17 00:00:00 2001 From: Martin Pärtel Date: Tue, 13 Mar 2012 16:53:07 +0200 Subject: Added --map. --- tests/common.rb | 4 ++++ tests/test_bindfs.rb | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) (limited to 'tests') diff --git a/tests/common.rb b/tests/common.rb index e3de1a3..d030972 100755 --- a/tests/common.rb +++ b/tests/common.rb @@ -119,6 +119,10 @@ def testenv(bindfs_args, options = {}, &block) fail("ERROR: failed to umount") testcase_ok = false end + + if File.exist?("bindfs.log") + system("cat bindfs.log") + end begin Dir.chdir '..' diff --git a/tests/test_bindfs.rb b/tests/test_bindfs.rb index 54801e2..30899ed 100755 --- a/tests/test_bindfs.rb +++ b/tests/test_bindfs.rb @@ -237,3 +237,59 @@ testenv("--chmod-deny --chmod-allow-x") do assert_exception(EPERM) { chmod(0700, 'mnt/dir') } # chmod on dir should not work end +root_testenv("--map=nobody/root:@nogroup/@root") do + touch('src/file') + chown('nobody', 'nogroup', 'src/file') + + assert { File.stat('mnt/file').uid == 0 } + assert { File.stat('mnt/file').gid == 0 } + + touch('mnt/newfile') + mkdir('mnt/newdir') + + assert { File.stat('src/newfile').uid == $nobody_uid } + assert { File.stat('src/newfile').gid == $nogroup_gid } + assert { File.stat('src/newdir').uid == $nobody_uid } + assert { File.stat('src/newdir').gid == $nogroup_gid } + + assert { File.stat('mnt/newfile').uid == 0 } + assert { File.stat('mnt/newfile').gid == 0 } + assert { File.stat('mnt/newdir').uid == 0 } + assert { File.stat('mnt/newdir').gid == 0 } +end + +root_testenv("--map=@nogroup/@root") do + touch('src/file') + chown('nobody', 'nogroup', 'src/file') + + assert { File.stat('mnt/file').gid == 0 } +end + +root_testenv("--map=1/2") do + touch('src/file1') + touch('src/file2') + chown(1, nil, 'src/file1') + chown(3, nil, 'src/file2') + + assert { File.stat('mnt/file1').uid == 2 } + assert { File.stat('mnt/file2').uid == 3 } +end + +root_testenv("--map=@1/@2:@2/@1") do + touch('src/file1') + touch('src/file2') + chown(nil, 1, 'src/file1') + chown(nil, 2, 'src/file2') + + assert { File.stat('mnt/file1').gid == 2 } + assert { File.stat('mnt/file2').gid == 1 } +end + +root_testenv("-u 1 --map=1/2:3/4") do + touch('src/file1') + touch('src/file2') + chown(2, nil, 'src/file1') + + assert { File.stat('mnt/file1').uid == 1 } + assert { File.stat('mnt/file2').uid == 1 } +end -- cgit v1.2.3