From fa455df27fd33eb849e7f515e9cb848ce3160502 Mon Sep 17 00:00:00 2001 From: openhands Date: Mon, 27 Jul 2026 14:20:28 +0000 Subject: [PATCH 1/2] feat(config): expose FUSEY_ALLOW_OTHER env var, default true MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fusey previously hardcoded `AllowOther: false` on the FUSE mount, which meant the mount was only accessible to the UID that called `mount(2)`. This broke sandbox deployments where the fusey daemon runs as root (because the container is privileged and the mounter needs CAP_SYS_ADMIN) while the consumer process — typically an agent-server running as a non-root user — has to read and write files on the mount. With `allow_other` disabled, the kernel rejects the consumer's VFS operations on the mount before fusey's permission code even runs. Introduce a `FUSEY_ALLOW_OTHER` env var (parsed via the existing `parseBoolEnv` helper, so accepts Go's `strconv.ParseBool` spellings: `true`/`false`/`1`/`0`/`t`/`f`/`T`/`F`/etc.) plumbed into a new `Config.AllowOther` field. Default it to `true` since fusey's typical deployment cannot function without it; `FUSEY_ALLOW_OTHER=false` opts back into the FUSE default for environments where access must be restricted to the mounter's UID. - internal/config: `DefaultAllowOther = true`, `Config.AllowOther`, `Load()` reads `FUSEY_ALLOW_OTHER`. - cmd/fusey: `AllowOther: false` → `AllowOther: cfg.AllowOther` on the `gofs.Mount` call. - internal/config: extend `TestLoadDefaults`, `TestLoadEnvOverrides`, and `TestLoadBadValues`; add `TestLoadAllowOther` covering the common true/false spellings. - README.md: document `FUSEY_ALLOW_OTHER` in the env-var table. Tested: `go test ./...` (CGO_ENABLED=0) passes all packages. Co-authored-by: openhands --- README.md | 1 + cmd/fusey/main.go | 2 +- internal/config/config.go | 21 ++++++++++++++++ internal/config/config_test.go | 46 ++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 122f495..a482f53 100644 --- a/README.md +++ b/README.md @@ -199,6 +199,7 @@ as a Kubernetes container without config files. | `FUSEY_PREFIX` | _(none)_ | Key prefix for all objects in the bucket (e.g. `pod-abc/`). Use this to share one bucket across multiple Fusey instances | | `FUSEY_COMPACTION_THRESHOLD` | `0.3` | Orphan fraction above which a chunk is targeted by `fusey compact` | | `FUSEY_PERSIST_INTERVAL` | `30s` | How often the index is flushed to disk and the object store | +| `FUSEY_ALLOW_OTHER` | `true` | When `true`, fusey mounts with the FUSE `allow_other` option so any user on the host can access the mountpoint. When `false`, only the UID that called `mount(2)` (the fusey daemon) can access it (the FUSE default). The default is `true` because fusey's typical deployment runs the daemon as root while the consumer (e.g. an agent-server) runs as a non-root user; without `allow_other` the kernel rejects the consumer's VFS operations before fusey's permission code runs. Set `FUSEY_ALLOW_OTHER=false` to restore the FUSE default if you need to restrict access to the mounter's UID. | ### Broker store (alternative to direct S3) diff --git a/cmd/fusey/main.go b/cmd/fusey/main.go index c36d51a..34f4c39 100644 --- a/cmd/fusey/main.go +++ b/cmd/fusey/main.go @@ -208,7 +208,7 @@ func runDaemon(daemonID, mountpoint string) { server, err := gofs.Mount(mountpoint, f.Root(), &gofs.Options{ MountOptions: fuse.MountOptions{ FsName: "fusey", - AllowOther: false, + AllowOther: cfg.AllowOther, DirectMount: true, }, }) diff --git a/internal/config/config.go b/internal/config/config.go index 4d3ae2f..ec851ef 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -15,6 +15,17 @@ const ( DefaultCompactionThreshold float64 = 0.3 DefaultPersistInterval time.Duration = 30 * time.Second DefaultBrokerAuthHeader = "X-SESSION-API-KEY" + // DefaultAllowOther matches the FUSE default (`false`) but is + // overridden to `true` here for fusey's runtime use: when fusey is + // launched inside a sandbox container, the daemon's UID (the user + // that called `mount(2)`) is typically root while the consumer + // process (e.g. an agent-server) runs as a non-root user; without + // `allow_other` the kernel rejects the consumer's VFS operations + // on the mount before fusey's permission code runs. Set + // FUSEY_ALLOW_OTHER=false to opt back into the FUSE default (the + // fusey mount will then only be accessible to the UID that + // mounted it). + DefaultAllowOther = true ) // Config holds all runtime configuration resolved from FUSEY_* environment variables. @@ -73,6 +84,12 @@ type Config struct { CompactionThreshold float64 // PersistInterval is how often the index is flushed to disk and S3 (FUSEY_PERSIST_INTERVAL). PersistInterval time.Duration + + // AllowOther controls the FUSE `allow_other` mount option + // (FUSEY_ALLOW_OTHER, default true). When true, any user on the + // host may access the mount; when false, only the UID that called + // `mount(2)` may access it (the FUSE default). + AllowOther bool } // Load reads FUSEY_* environment variables and returns a populated Config. @@ -94,6 +111,7 @@ func Load() (*Config, error) { BrokerAuthValue: os.Getenv("FUSEY_BROKER_AUTH_VALUE"), CompactionThreshold: DefaultCompactionThreshold, PersistInterval: DefaultPersistInterval, + AllowOther: DefaultAllowOther, } if v := os.Getenv("FUSEY_BROKER_AUTH_HEADER"); v != "" { cfg.BrokerAuthHeader = v @@ -126,6 +144,9 @@ func Load() (*Config, error) { if err := parseDurationEnv("FUSEY_PERSIST_INTERVAL", &cfg.PersistInterval); err != nil { return nil, err } + if err := parseBoolEnv("FUSEY_ALLOW_OTHER", &cfg.AllowOther); err != nil { + return nil, err + } return cfg, nil } diff --git a/internal/config/config_test.go b/internal/config/config_test.go index b227d1d..cebff94 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -25,6 +25,17 @@ func TestLoadDefaults(t *testing.T) { if cfg.CompactionThreshold != DefaultCompactionThreshold { t.Errorf("CompactionThreshold: got %f, want %f", cfg.CompactionThreshold, DefaultCompactionThreshold) } + // AllowOther defaults to true: fusey's typical deployment runs the + // daemon as root (because the container is privileged and the + // mounter needs CAP_SYS_ADMIN) while the consumer (agent-server) + // runs as a non-root user. Without allow_other, the kernel rejects + // the consumer's VFS operations on the mount. + if cfg.AllowOther != DefaultAllowOther { + t.Errorf("AllowOther: got %v, want %v", cfg.AllowOther, DefaultAllowOther) + } + if cfg.AllowOther != true { + t.Errorf("AllowOther: got %v, want true (default must be true)", cfg.AllowOther) + } } func TestLoadEnvOverrides(t *testing.T) { @@ -36,6 +47,7 @@ func TestLoadEnvOverrides(t *testing.T) { t.Setenv("FUSEY_ENDPOINT", "https://s3.example.com") t.Setenv("FUSEY_COMPACTION_THRESHOLD", "0.5") t.Setenv("FUSEY_PERSIST_INTERVAL", "60s") + t.Setenv("FUSEY_ALLOW_OTHER", "false") cfg, err := Load() if err != nil { @@ -65,6 +77,9 @@ func TestLoadEnvOverrides(t *testing.T) { if cfg.PersistInterval != 60*time.Second { t.Errorf("PersistInterval: got %s", cfg.PersistInterval) } + if cfg.AllowOther != false { + t.Errorf("AllowOther: got %v, want false (FUSEY_ALLOW_OTHER=false)", cfg.AllowOther) + } } func TestLoadBadValues(t *testing.T) { @@ -74,6 +89,7 @@ func TestLoadBadValues(t *testing.T) { {"FUSEY_MAX_SIZE", "notanumber"}, {"FUSEY_COMPACTION_THRESHOLD", "notafloat"}, {"FUSEY_PERSIST_INTERVAL", "notaduration"}, + {"FUSEY_ALLOW_OTHER", "yes"}, } for _, c := range cases { t.Run(c.key, func(t *testing.T) { @@ -93,3 +109,33 @@ func TestMaxFSSizeZeroIsInvalid(t *testing.T) { t.Error("expected error for FUSEY_MAX_SIZE=0") } } + +func TestLoadAllowOther(t *testing.T) { + // `1`, `t`, `T`, `TRUE`, `true`, `True` all parse to true per + // strconv.ParseBool. Covers the common opt-in spellings. + for _, v := range []string{"true", "True", "TRUE", "1"} { + t.Run("explicit_true_"+v, func(t *testing.T) { + t.Setenv("FUSEY_ALLOW_OTHER", v) + cfg, err := Load() + if err != nil { + t.Fatalf("Load: %v", err) + } + if !cfg.AllowOther { + t.Errorf("AllowOther: got %v, want true", cfg.AllowOther) + } + }) + } + + for _, v := range []string{"false", "False", "FALSE", "0"} { + t.Run("explicit_false_"+v, func(t *testing.T) { + t.Setenv("FUSEY_ALLOW_OTHER", v) + cfg, err := Load() + if err != nil { + t.Fatalf("Load: %v", err) + } + if cfg.AllowOther { + t.Errorf("AllowOther: got %v, want false", cfg.AllowOther) + } + }) + } +} From d690f841e210801e55d428b74c96d980c9abc694 Mon Sep 17 00:00:00 2001 From: openhands Date: Mon, 27 Jul 2026 14:30:22 +0000 Subject: [PATCH 2/2] docs(specs): model FUSEY_ALLOW_OTHER in mount.qnt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous commit introduced the FUSEY_ALLOW_OTHER env var and plumbed it through Config.AllowOther to the FUSE mount. This commit makes the formal mount specification aware of the new configuration knob so the spec stays the source of truth (per AGENTS.md §"Key design decisions" #1, "Specs before code"). mount.qnt changes: - Preamble: add a new "Configuration (resolved from environment variables at startup)" section between "Mount log" and "CLI dispatch surface". It documents FUSEY_ALLOW_OTHER alongside the existing CLI-surface section, including: * what the option does (allow_other mount, default true, kernel default is false) * why fusey defaults to true (consumer UID != daemon UID in the typical runtime-api sandbox) * an explicit scope note: this spec does NOT model the lifecycle differently based on ALLOW_OTHER; the option is consumed at the DaemonStarting → DaemonReady transition and either succeeds (fsAccessible = true with that option in effect) or fails (daemonMountFails, which covers the /etc/fuse.conf case where the kernel refuses allow_other). - Module body: add `const ALLOW_OTHER: bool` to the new Constants section. Modeled as a constant rather than a state variable because the value is read once from the environment at startup and never changes during the daemon's lifetime. A spec is a single-configuration slice; quint verifies invariants under each value of ALLOW_OTHER. - No new actions or invariants: the lifecycle state machine does not branch on ALLOW_OTHER, and adding a no-op invariant like `allowOtherIsConfigurationOnly = true` would be a tautology. Existing invariants (fsAccessibleIffDaemonReady, pidFileExistsWhileReachable, indexFlushedOnStop, ...) hold under both ALLOW_OTHER = true and ALLOW_OTHER = false. Note on spec validation: the spec file has a pre-existing parse error against the current Quint release (the multi-assignment init action syntax is not accepted by quint >= 0.32). This is unrelated to the present change — the same parse error exists on origin/main at specs/mount.qnt:122. Tracking that as a separate concern; the spec is not currently exercised by CI (.github/workflows/ci.yml runs only go vet + go test). Co-authored-by: openhands --- specs/mount.qnt | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/specs/mount.qnt b/specs/mount.qnt index ca0ea6c..69a8492 100644 --- a/specs/mount.qnt +++ b/specs/mount.qnt @@ -48,6 +48,31 @@ // instead of go-fuse's cryptic "fusermount exited with code 256" you also // get the kernel syscall error (EPERM, EACCES, EBUSY, ...) in mount.log. // +// Configuration (resolved from environment variables at startup): +// FUSEY_ALLOW_OTHER — controls the FUSE `allow_other` mount option +// (default `true`). When `true`, fusey asks the +// kernel for an `allow_other` mount so any user on +// the host may access the mountpoint; when `false`, +// only the UID that called `mount(2)` (the fusey +// daemon) may access it — the FUSE default. fusey +// defaults this to `true` because the typical +// deployment runs the daemon as root (the mounter +// needs `CAP_SYS_ADMIN`) while the consumer process +// (e.g. an agent-server) runs as a non-root user; +// without `allow_other` the kernel rejects the +// consumer's VFS operations before fusey's own +// permission code ever runs. +// +// This spec does NOT model the lifecycle differently based on +// FUSEY_ALLOW_OTHER: the mount option is consumed by gofs.Mount at the +// DaemonStarting → DaemonReady transition and either succeeds (the +// mount is operational with the requested option) or fails +// (`daemonMountFails`) — and that second case covers, among other +// failure modes, the situation where the kernel refuses `allow_other` +// because `/etc/fuse.conf` does not enable `user_allow_other`. The +// `ALLOW_OTHER` constant below is the spec-level projection of the +// env var; invariants in this file hold for both values. +// // CLI dispatch surface: // // cmd/fusey/main.go's main() dispatches on os.Args[1] (with `--version`/ @@ -82,6 +107,19 @@ module mount { + // -------------------------------------------------------------------------- + // Constants + // -------------------------------------------------------------------------- + + // Spec-level projection of the FUSEY_ALLOW_OTHER environment variable: + // when `true`, the daemon requests a FUSE `allow_other` mount so any user + // on the host may access the mountpoint; when `false`, only the UID that + // called `mount(2)` may access it. Modeled as a constant (not a state + // variable) because the value is read once from the environment at + // startup and does not change during the daemon's lifetime. See the + // preamble "Configuration" section for the rationale. + const ALLOW_OTHER: bool + // -------------------------------------------------------------------------- // Types // --------------------------------------------------------------------------