mirror of
https://github.com/vgough/encfs.git
synced 2024-11-29 11:23:52 +01:00
Add extended attributes tests
This commit is contained in:
parent
97d1b83d71
commit
adbddf1f9e
@ -245,7 +245,7 @@ static bool processArgs(int argc, char *argv[],
|
||||
// 'o' : arguments meant for fuse
|
||||
// 't' : syslog tag
|
||||
int res =
|
||||
getopt_long(argc, argv, "HsSfvdmi:o:t:", long_options, &option_index);
|
||||
getopt_long(argc, argv, "HsSfvdmi:o:t:V", long_options, &option_index);
|
||||
|
||||
if (res == -1) break;
|
||||
|
||||
@ -355,6 +355,9 @@ static bool processArgs(int argc, char *argv[],
|
||||
case 'V':
|
||||
// xgroup(usage)
|
||||
cerr << autosprintf(_("encfs version %s"), VERSION) << endl;
|
||||
#if defined(HAVE_XATTR)
|
||||
cerr << "Compiled with : HAVE_XATTR" << endl;
|
||||
#endif
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'H':
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
# Test EncFS normal and paranoid mode
|
||||
|
||||
use Test::More tests => 106;
|
||||
use Test::More tests => 112;
|
||||
use File::Path;
|
||||
use File::Copy;
|
||||
use File::Temp;
|
||||
@ -12,6 +12,29 @@ require("tests/common.pl");
|
||||
|
||||
my $tempDir = $ENV{'TMPDIR'} || "/tmp";
|
||||
|
||||
# Find attr binary
|
||||
# Linux
|
||||
my @setattr = ("attr", "-s", "encfs", "-V", "hello");
|
||||
my @getattr = ("attr", "-g", "encfs");
|
||||
if(system("which xattr > /dev/null 2>&1") == 0)
|
||||
{
|
||||
# Mac OS X
|
||||
@setattr = ("xattr", "-sw", "encfs", "hello");
|
||||
@getattr = ("xattr", "-sp", "encfs");
|
||||
}
|
||||
if(system("which lsextattr > /dev/null 2>&1") == 0)
|
||||
{
|
||||
# FreeBSD
|
||||
@setattr = ("setextattr", "-h", "user", "encfs", "hello");
|
||||
@getattr = ("getextattr", "-h", "user", "encfs");
|
||||
}
|
||||
# Do we support xattr ?
|
||||
my $have_xattr = 1;
|
||||
if(system("./build/encfs -V 2>&1 | grep -q HAVE_XATTR") != 0)
|
||||
{
|
||||
$have_xattr = 0;
|
||||
}
|
||||
|
||||
# test filesystem in standard config mode
|
||||
&runTests('standard');
|
||||
|
||||
@ -268,7 +291,7 @@ sub encName
|
||||
return $enc;
|
||||
}
|
||||
|
||||
# Test symlinks & hardlinks
|
||||
# Test symlinks & hardlinks, and extended attributes
|
||||
sub links
|
||||
{
|
||||
my $hardlinkTests = shift;
|
||||
@ -293,6 +316,14 @@ sub links
|
||||
ok( link("$crypt/data", "$crypt/data.2"), "hard link");
|
||||
checkContents("$crypt/data.2", $contents, "hardlink read");
|
||||
};
|
||||
|
||||
# extended attributes
|
||||
my $return_code = ($have_xattr) ? system(@setattr, "$crypt/data") : 0;
|
||||
is($return_code, 0, "extended attributes can be set (return code was $return_code)");
|
||||
$return_code = ($have_xattr) ? system(@getattr, "$crypt/data") : 0;
|
||||
is($return_code, 0, "extended attributes can be get (return code was $return_code)");
|
||||
$return_code = ($have_xattr) ? system(@getattr, "$crypt/data-rel") : 1;
|
||||
isnt($return_code, 0, "extended attributes operations do not follow symlinks (return code was $return_code)");
|
||||
}
|
||||
|
||||
# Test mount
|
||||
|
@ -26,6 +26,12 @@ if(system("which lsextattr > /dev/null 2>&1") == 0)
|
||||
# FreeBSD
|
||||
@binattr = ("lsextattr", "-h", "user");
|
||||
}
|
||||
# Do we support xattr ?
|
||||
my $have_xattr = 1;
|
||||
if(system("./build/encfs -V 2>&1 | grep -q HAVE_XATTR") != 0)
|
||||
{
|
||||
$have_xattr = 0;
|
||||
}
|
||||
|
||||
# Helper function
|
||||
# Create a new empty working directory
|
||||
@ -98,8 +104,7 @@ sub symlink_test
|
||||
$dec = readlink("$decrypted/symlink");
|
||||
ok( $dec eq $target, "symlink to '$target'") or
|
||||
print("# (original) $target' != '$dec' (decrypted)\n");
|
||||
system(@binattr, "$decrypted/symlink");
|
||||
my $return_code = $?;
|
||||
my $return_code = ($have_xattr) ? system(@binattr, "$decrypted/symlink") : 0;
|
||||
is($return_code, 0, "symlink to '$target' extended attributes can be read (return code was $return_code)");
|
||||
unlink("$plain/symlink");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user