mirror of
https://github.com/google/fuse-archive.git
synced 2026-11-20 16:41:43 +00:00
Add -o noexternal option to disable external decompression filters
- Introduce the 'noexternal' mount option which clears the PATH environment variable. This prevents libarchive from finding and executing external programs (like gzip, xz, etc.) for decompression. - Update PrintUsage() and README.md to document the new option. - Add integration test case in tests/test.py to verify environmental isolation.
This commit is contained in:
@@ -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).
|
||||
|
||||
|
||||
@@ -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<std::string> 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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user