Skip to content

feat(release): the tarball carries the mount helper, and install.sh can undo itself (#533) - #537

Merged
scttfrdmn merged 4 commits into
mainfrom
feat/533-tarball-mount-helper
Sep 20, 2026
Merged

scttfrdmn merged 4 commits into
mainfrom
feat/533-tarball-mount-helper

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #533.

Installing from the release tarball now gets you the same /etc/fstab support that installing the
.deb or .rpm does, and scripts/install.sh can now remove what it installed.

What changed

.goreleaser.yml — archives[0].ids names both archives and mount-helper. Two measured
facts are recorded as comments there because neither is guessable:

  • goreleaser groups archive members by target, not by build, so naming a second build id puts
    both binaries in the same per-platform tarball. Asset names are unchanged and darwin is unaffected,
    because the mount-helper build is linux-only.
  • goreleaser then hard-fails the whole release: archive has different count of binaries for each platform, which may cause your users confusion. allow_different_binary_count: true is therefore
    not a preference — without it, nothing at all is built. packaging_test.go says so on the field.

scripts/install.sh — installs mount.objectfs beside the binary and symlinks
/sbin/mount.objectfs, with the same conservatism scripts/postinstall.sh already has: a foreign
symlink or a real file is left alone with a warning that names the ln -s, a dangling link is never
created, and re-running is a no-op. New --uninstall (removes the link, the binaries, and the
install dir if empty) and --no-mount-helper.

One hazard the issue did not mention. /sbin/mount.objectfs is exec'd by mount(8) as root.
A link from there into a directory whose owner is not root is a local privilege escalation — and
sudo ./install.sh with the default ~/.local prefix is exactly that shape. may_register()
refuses it and prints the sudo ln -s to run instead. README.md states the rule directly: do not
run the whole script under sudo to get the link.

On the issue's "one shell function the two scripts share"

That is not available to either consumer, so the request is answered with a stronger gate instead of
a weaker version of itself.

install.sh is fetched over HTTPS and piped into bash — that is #138's acceptance criterion — so
there is no library file beside it to source. The maintainer scriptlets cannot source one either:
dpkg copies them into /var/lib/dpkg/info and runs prerm with the package's own files in
whatever state a --force left them, so a sourced dependency is a scriptlet that fails to uninstall.

So: a second copy, with drift caught behaviorally. TestBothInstallPathsRegisterTheHelperTheSameWay
and TestBothUninstallPathsUnlinkTheHelperTheSameWay run postinstall.sh/preremove.sh and the
sourced install.sh functions through one shared table of cases — six states for install, four
for uninstall — asserting the same resulting link state, the same warning, and the same remedy. A
shared function would be exercised once; these are exercised twice.

Verification

go build ./..., make test, internal/config with -race, GOOS=linux golangci-lint and
pre-commit on every changed file all pass.

Seven mutations, each confirmed to still parse, six caught by a named test: dropping
mount-helper from archives.ids; removing allow_different_binary_count; gutting may_register's
-O check; removing unlink_mount_helper's [ "\$current" != "\$target" ] guard; making
link_mount_helper clobber a foreign symlink with ln -sf; turning the live-mount die into a
say.

The seventh survived and produced the second commit here. Narrowing live_mounts's fstype match
changed no outcome, because every matching row in the fixture named objectfs as its device and the
fuse.* + device arm subsumed the rest. A notobjectfs /mnt/renamed fuse.objectfs row makes the
first arm load-bearing; both discriminating mutations are now caught in both scripts. | fuse.s3
stays un-isolable and the test records why: FSName is hardcoded to objectfs (#180 removed the
operator key), so isolating it would mean claiming any fuse.s3 mount is ours whatever its device,
which would make --uninstall refuse over a stranger's filesystem. Filed separately.

Note the .goreleaser.yml diff includes five single-line quote normalizations from pre-commit's
pretty-format-yaml. That hook is not excluded for this file and the copy on main already failed
it, so the churn is pre-existing; no test reads the quoting.

The packaging job is the only thing that can actually prove this — the tarball path is
mount(8) behaviour nothing local stands in for.

…an undo itself (#533)

The /etc/fstab mount helper shipped in v0.16.0 and reached a machine if and only if the
operator installed a .deb or an .rpm: the `mount-helper` build existed and was named only
by `nfpms.ids`. That excluded the population the feature is most useful to, since this
project's documented install path is a tarball into ~/.local — the default is ~/.local
precisely because its users are frequently on a shared login node with no root at all.

The three Linux tarballs now carry `mount.objectfs` beside the binary, and install.sh
installs it into --prefix/bin and links /sbin/mount.objectfs to it.

Two goreleaser facts, both measured with `release --snapshot` rather than reasoned about:
archives group members by *target*, not by build, so adding `mount-helper` to
`archives.ids` puts the helper in the three Linux tarballs, nothing in the two darwin
ones, and renames no asset. And goreleaser then refuses the entire release — building
*nothing* — unless `allow_different_binary_count: true` says the asymmetry is deliberate.
It is: there is no /sbin/mount.TYPE on macOS, so a darwin mount.objectfs would have
nothing to register it with.

Registering needs root, and the obvious way to get root here is a local privilege
escalation, so the script refuses rather than warns. mount(8) exec's
/sbin/mount.objectfs as root; a link from there into a directory whose owner is not root
lets that owner replace the binary and run code as root the next time anybody mounts
anything — and `sudo ./install.sh` with the default ~/.local prefix is exactly that shape.
It is also the most likely way someone arrives at it, since "registering needs root" reads
as an instruction to re-run the installer under sudo. Both the helper and its directory
must be root-owned. A non-root install still installs the helper and prints the single
`ln -s` left to do; --prefix /usr/local under sudo is the registered system-wide form, and
--no-mount-helper skips it.

--uninstall, which this script has never had. scripts/preremove.sh unlinks the helper on
package removal and the tarball path had no counterpart, so a tarball install left behind
the one thing an operator cannot clean up by deleting a directory — and left dangling,
/sbin/mount.objectfs makes an fstab entry that worked before fail at `mount -a` with
mount(8)'s own "no such file or directory" against a helper path, which says considerably
less than "unknown filesystem type". It refuses while an ObjectFS filesystem is still
mounted and names the `objectfs unmount` for each, because deleting the server binary
under a live FUSE mount hangs every read against the mount point until someone unmounts it
by hand. Caches and configuration are named rather than removed.

The issue asked for one shared shell function instead of a second copy of the registration
logic, on the correct reasoning that two copies drift. There is nothing for the three
consumers to share one through. install.sh is fetched over HTTPS and piped into bash, so
it has no library beside it on disk, and fetching one would mean running an unverified
second script inside an installer whose entire header is about why the download path is
not trusted. dpkg cannot source one either: it copies maintainer scripts into
/var/lib/dpkg/info and runs prerm with the package's own files in whatever state a
--force left them, so a scriptlet whose unlink silently no-ops because a library file was
already gone leaves exactly the dangling link that function exists to prevent.

So the drift is guarded by a test instead. internal/config/mount_helper_test.go runs
*both copies* — the packaged scriptlet's and install.sh's — through one table of six cases
(nothing there, our own link, a foreign symlink, a real file, no /sbin, no helper binary)
and asserts they reach the same outcome, and the same for the two unlink paths. That is
stronger than the shared function would have been, because a shared function is exercised
once by whichever caller a test drives and these are exercised twice.

Also here, because the same test file needed them: live_mounts matches all three of
fstype fuse.objectfs, fstype fuse.s3, and any fuse.* with a device of objectfs, with a
test that runs preremove.sh's copy against the same /proc/mounts. internal/fuse sets
Subtype "s3" alongside FSName "objectfs", so a grep for fuse.objectfs alone finds nothing
on a real mount — a defect preremove.sh shipped with for several releases, which this
second copy must not reintroduce.

Unrelated to the change: pre-commit's pretty-format-yaml normalizes five double-quoted
scalars in .goreleaser.yml to single quotes. The committed file already did not satisfy
that hook, so the churn appears on the first commit to touch the file rather than being
introduced by it. Both spellings parse to the same string and packaging_test.go reads the
values, not the quoting.
…tch fixture (#533)

The /proc/mounts fixture asserted three matching rows, and every one of them named `objectfs`
as its device. That makes the three `case` arms in `live_mounts`/`objectfs_mountpoints`
indistinguishable: the third arm's `[ "$device" = "objectfs" ]` already covers all three rows, so
deleting the whole `fuse.objectfs |` alternative from the first arm changes no outcome. Measured,
not predicted — the mutation survived.

A `notobjectfs /mnt/renamed fuse.objectfs` row can only be matched by the first arm. With it,
dropping `fuse.objectfs` from arm 1 and deleting arm 2 entirely are both caught, by name, in both
scripts:

    install.sh: arm 1 loses fuse.objectfs              CAUGHT by install.sh_live_mounts
    install.sh: the fuse.* + device arm deleted         CAUGHT by install.sh_live_mounts
    preremove.sh: arm 1 loses fuse.objectfs            CAUGHT by preremove.sh_objectfs_mountpoints
    preremove.sh: the fuse.* + device arm deleted       CAUGHT by preremove.sh_objectfs_mountpoints

`| fuse.s3` stays un-isolable and the comment says why rather than adding a row that asserts an
undecided rule. buildMountOptions hardcodes `FSName: "objectfs"` (#180 removed the operator-facing
key for lack of a reader), so every mount ObjectFS can produce today has device=objectfs and the
third arm catches it regardless. Isolating that alternative means claiming any `fuse.s3` mount is
ours whatever its device — `-o subtype=s3` is not reserved, and a stranger's mount would make
`--uninstall` refuse over a filesystem it has nothing to do with. Narrowing the union is a change
to a shipped scriptlet's matching rule and belongs in its own issue.
…elper (#533)

The packaging job built five tarballs and never opened one. internal/config/packaging_test.go
asserts .goreleaser.yml *says* to archive the mount-helper build; nothing said goreleaser did, and
the mechanism it relies on is not behaviour to assume across an upgrade — goreleaser groups archive
members by target rather than by build, which is the only reason naming a second build in one
`archives[].ids` entry lands a second binary inside the existing per-platform tarballs instead of
producing a second colliding set.

The member names are measured against a real `make package-linux`, not derived:

    objectfs-linux-amd64.tar.gz    mount.objectfs, objectfs-linux-amd64
    objectfs-linux-arm64.tar.gz    mount.objectfs, objectfs-linux-arm64
    objectfs-linux-armv7.tar.gz    mount.objectfs, objectfs-linux-armv7
    objectfs-darwin-amd64.tar.gz   objectfs-darwin-amd64
    objectfs-darwin-arm64.tar.gz   objectfs-darwin-arm64

The two builds template `binary:` differently and both names are load-bearing: the helper is
unsuffixed because mount(8) resolves `/sbin/mount.$TYPE` by exact filename, and the main binary is
suffixed because that is what install.sh looks up (`$work/$PROGRAM-$platform`, install.sh:820).

Four assertions, each with a distinct reason to exist:

- the exact member set of linux-amd64, not a grep — a stray CHANGELOG/LICENSE/README trio is what
  `files: - none*` prevents, and `files: []` silently reads as *unset* and puts them back
- mount.objectfs in *every* linux tarball, because `allow_different_binary_count: true` makes the
  darwin asymmetry legal and thereby makes any asymmetry legal; a mount-helper build whose goarch
  list drifted would be accepted by goreleaser without a word
- darwin unchanged, which is the check that fails if that build's linux-only `goos:` ever widens
- a floor of five tarballs, because two of the above iterate over globs

Verified by mutating the artifacts rather than the script, with the failure paths actually run so
the `::error::` lines are known to render: dropping the helper from amd64, dropping it from arm64
only, a stray LICENSE in a darwin tarball, a stray README in a linux one, and a tarball deleted are
each caught, by a different assertion, and the unmodified tree passes.

Note the install-script job cannot cover this: it fetches the last *published* release on purpose
(ci.yml:47), so it verifies this tree's installer against the previous release's assets and will not
see the helper until a release ships with it.
@scttfrdmn

Copy link
Copy Markdown
Owner Author

Read the real packaging job log from the first run rather than a local dry run, and it showed the
gap: goreleaser built all five tarballs (so allow_different_binary_count: true does work under
the pinned v2.18.1, and the archives were produced) but the job never opened one. The config test
proves .goreleaser.yml says to archive the helper; nothing said goreleaser did it.

install-script cannot close that — it fetches the last published release on purpose
(ci.yml:47), so it checks this tree's installer against the previous release's assets and will not
see the helper until a release ships with it.

So aad9834 adds a step to packaging that opens the tarballs. Member names measured against a real
make package-linux, not guessed — and one of them corrected an assumption I had:

objectfs-linux-amd64.tar.gz    mount.objectfs, objectfs-linux-amd64
objectfs-linux-arm64.tar.gz    mount.objectfs, objectfs-linux-arm64
objectfs-linux-armv7.tar.gz    mount.objectfs, objectfs-linux-armv7
objectfs-darwin-amd64.tar.gz   objectfs-darwin-amd64
objectfs-darwin-arm64.tar.gz   objectfs-darwin-arm64

The main binary is platform-suffixed and the helper is not. Both names are load-bearing: mount(8)
resolves /sbin/mount.$TYPE by exact filename, and install.sh:820 looks the main binary up as
$work/$PROGRAM-$platform.

Verified by mutating the artifacts rather than the script, with each failure path actually run so
the ::error:: lines are known to render:

Mutation Caught by
unmodified dist/ passes
linux-amd64 loses mount.objectfs the exact member-set check
linux-arm64 only loses it the every-linux-tarball loop
a stray LICENSE in a darwin tarball the darwin-unchanged check
a stray README.md in linux-amd64 the exact member-set check
a tarball deleted the five-tarball floor

Each row names which check fired, because every wrong reason is still a rejection.

@scttfrdmn
scttfrdmn merged commit 5f45c94 into main Sep 20, 2026
42 checks passed
@scttfrdmn
scttfrdmn deleted the feat/533-tarball-mount-helper branch September 20, 2026 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The release tarball and install.sh do not carry the mount helper

1 participant