From c7cea40ddc962fff1afee41abef8a5911f7c83e6 Mon Sep 17 00:00:00 2001 From: benrubson Date: Sat, 26 Aug 2017 11:50:01 +0200 Subject: [PATCH 1/2] Run sudo tests also if user is root --- INSTALL.md | 3 ++- integration/normal.t.pl | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index f8f0302..175e129 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -28,7 +28,8 @@ tests will run almost instantly: make test Integration tests will take ~20 seconds to run and will mount an -encrypted filesystem and run tests on it: +encrypted filesystem and run tests on it: +*running integration tests from root (or with sudo) will run additional ones* make integration diff --git a/integration/normal.t.pl b/integration/normal.t.pl index 840d32c..c5d679b 100755 --- a/integration/normal.t.pl +++ b/integration/normal.t.pl @@ -34,6 +34,7 @@ if(system("which lsextattr > /dev/null 2>&1") == 0) $setattr = "setextattr -h user encfs hello"; $getattr = "getextattr -h user encfs"; } + # Do we support xattr ? my $have_xattr = 1; if(system("./build/encfs --verbose --version 2>&1 | grep -q HAVE_XATTR") != 0) @@ -41,6 +42,17 @@ if(system("./build/encfs --verbose --version 2>&1 | grep -q HAVE_XATTR") != 0) $have_xattr = 0; } +# Did we ask, or are we simply able to run "sudo" tests ? +my $sudo_cmd; +if (! $<) +{ + $sudo_cmd=""; +} +elsif (defined($ENV{'SUDO_TESTS'})) +{ + $sudo_cmd="sudo"; +} + # test filesystem in standard config mode &runTests('standard'); @@ -443,8 +455,8 @@ sub checkReadError # Test that write errors are correctly thrown up to us sub checkWriteError { - # No OSX impl, and requires sudo which is inconvenient outside of CI. - if($^O eq "darwin" || !defined($ENV{'SUDO_TESTS'})) { + # No OSX impl (for now, feel free to find how to), and requires "sudo". + if($^O eq "darwin" || !defined($sudo_cmd)) { ok(1, "write error"); ok(1, "write error"); ok(1, "write error"); @@ -455,7 +467,7 @@ sub checkWriteError my $mnt = "$workingDir/checkWriteError.mnt"; mkdir($crypt) || BAIL_OUT($!); mkdir($mnt) || BAIL_OUT($!); - system("sudo mount -t tmpfs -o size=1m tmpfs $crypt"); + system("$sudo_cmd mount -t tmpfs -o size=1m tmpfs $crypt"); ok( $? == 0, "mount command returns 0") || return; system("./build/encfs --standard --extpass=\"echo test\" $crypt $mnt 2>&1"); ok( $? == 0, "encfs command returns 0") || return; @@ -464,6 +476,6 @@ sub checkWriteError ok ($!{ENOSPC}, "write returned $! instead of ENOSPC"); close OUT; portable_unmount($mnt); - system("sudo umount $crypt"); + system("$sudo_cmd umount $crypt"); } } From fbe0c52aaa82e347296677348433283f3099f01e Mon Sep 17 00:00:00 2001 From: benrubson Date: Sun, 27 Aug 2017 09:50:13 +0200 Subject: [PATCH 2/2] Run sudo tests checking effective UID --- integration/normal.t.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/normal.t.pl b/integration/normal.t.pl index c5d679b..0ee74e0 100755 --- a/integration/normal.t.pl +++ b/integration/normal.t.pl @@ -44,7 +44,7 @@ if(system("./build/encfs --verbose --version 2>&1 | grep -q HAVE_XATTR") != 0) # Did we ask, or are we simply able to run "sudo" tests ? my $sudo_cmd; -if (! $<) +if ($> == 0) { $sudo_cmd=""; }