diff --git a/README.md b/README.md index fee0a2a..dda3f30 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,11 @@ numeric suffix (e.g., `archive (1)`). : Do not use libarchive's format bidding system to detect the archive format. Instead, strictly rely on the file extension. +**-o noexternal** +: Do not use external programs for decompression. This is achieved by clearing + the `PATH` environment variable, ensuring that only decompression filters + implemented natively or statically linked into **libarchive** are used. + **-o dmask=M** : Directory permission mask in octal (default is 0022). diff --git a/fuse-archive.cc b/fuse-archive.cc index 5a64618..79bda94 100644 --- a/fuse-archive.cc +++ b/fuse-archive.cc @@ -91,6 +91,7 @@ struct Context { LogLevel log_level = LogLevel::INFO; int help = 0; int version = 0; + int can_use_external_filters = 1; std::vector archives; }; @@ -123,6 +124,7 @@ fuse_opt const g_fuse_opts[] = { {"nohardlinks", offsetof(Context, options.hardlinks), 0}, {"noxattrs", offsetof(Context, options.xattrs), 0}, {"nobidding", offsetof(Context, options.bidding), 0}, + {"noexternal", offsetof(Context, can_use_external_filters), 0}, {"default_permissions", offsetof(Context, options.default_permissions), 1}, #if FUSE_USE_VERSION >= 30 {"direct_io", offsetof(Context, options.direct_io), 1}, @@ -240,6 +242,7 @@ general options: -o nohardlinks no hard links -o noxattrs no extended attributes -o nobidding rely on file extension to detect archive format + -o noexternal do not use external programs for decompression -o dmask=M directory permission mask in octal (default 0022) -o fmask=M file permission mask in octal (default 0022))" #if FUSE_USE_VERSION >= 30 @@ -357,6 +360,10 @@ int main(int const argc, char** const argv) try { return EXIT_FAILURE; } + if (!ctx.can_use_external_filters) { + setenv("PATH", "", 1); + } + // Determine where the mount point should be. // The last non-option argument is the mount point, unless only one such // argument was provided, in which case it is both the archive and the base diff --git a/tests/test.py b/tests/test.py index b0b340a..b0d12b2 100755 --- a/tests/test.py +++ b/tests/test.py @@ -2275,6 +2275,9 @@ def TestInvalidArchive(): CheckArchiveMountingError('archive.xxx', 30, options=['-o', 'nobidding']) CheckArchiveMountingError('--help', 30, options=['-o', 'nobidding']) + # Test noexternal + CheckArchiveMountingError('romeo.txt.b64', 30, options=['-o', 'noexternal']) + if os.getuid() != 0: with tempfile.NamedTemporaryFile() as f: os.chmod(f.name, 0)