Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect permissions on the mount root dir #12

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 3.12 FATAL_ERROR)

project (fuse3-p7zip
VERSION 1.2.1
VERSION 1.2.2
DESCRIPTION "fuse3 file system that uses the p7zip library to mount archives"
LANGUAGES CXX
)
Expand Down
18 changes: 12 additions & 6 deletions src/fuse3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
#include <memory>
#include <vector>

#define CMD_OPT(t, m) \
{ \
t, offsetof(struct cmd_params_t, m), 1 \
}
#define CMD_OPT(t, m) {t, offsetof(struct cmd_params_t, m), 1}

enum arg_status : int {
ARG_DISCARD = 0,
Expand All @@ -34,6 +31,7 @@ static struct cmd_params_t {
char* password = nullptr;
char* passfile = nullptr;
std::vector<std::string> cli_args;
bool allow_other = false;
} cmd_params;

static const fuse_opt opts_spec[] = {CMD_OPT("--password=%s", password), CMD_OPT("-p %s", password),
Expand Down Expand Up @@ -111,8 +109,13 @@ void Fuse::Params::print_usage()

int Fuse::Params::process_arg(Fuse::Params* fuse, const char* arg, int key, struct fuse_args* outargs)
{
// printf("key: %d, arg: %s\n", key, arg);
LogDebug("key: %d, arg: %s\n", key, arg);
switch (key) {
case FUSE_OPT_KEY_OPT:
if (strcmp("allow_other", arg) == 0) {
cmd_params.allow_other = true;
return ARG_DISCARD;
}
case FUSE_OPT_KEY_NONOPT:
cmd_params.cli_args.emplace_back(arg);
if (cmd_params.cli_args.back().empty()) fuse->print_usage();
Expand Down Expand Up @@ -254,7 +257,10 @@ ssize_t Fuse::execute(sevenzip::IArchive* arc)
static auto cache = Cache{arc, sevenzip::ExtractCallback(password()), Cache::FileTree()};
auto root = sevenzip::Path("/");
auto root_stat = arc->stat();
root_stat.st_mode = (root_stat.st_mode & ~S_IFMT) | S_IFDIR;

root_stat.st_mode = (root_stat.st_mode & ~S_IFMT) | S_IFDIR | S_IXUSR | S_IXGRP;
if (cmd_params.allow_other) root_stat.st_mode |= S_IROTH | S_IXOTH;

cache.tree.emplace(root, std::make_pair(arc->end(), root_stat));
for (auto it = arc->begin(); it != arc->end(); ++it) {
//log().printf("it: '%s'\n", it.path().c_str());
Expand Down
Loading