Repository navigation
feat(release): the tarball carries the mount helper, and install.sh can undo itself (#533) - #537
Conversation
…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.
|
Read the real
So The main binary is platform-suffixed and the helper is not. Both names are load-bearing: Verified by mutating the artifacts rather than the script, with each failure path actually run so
Each row names which check fired, because every wrong reason is still a rejection. |
Closes #533.
Installing from the release tarball now gets you the same
/etc/fstabsupport that installing the.debor.rpmdoes, andscripts/install.shcan now remove what it installed.What changed
.goreleaser.yml—archives[0].idsnames botharchivesandmount-helper. Two measuredfacts are recorded as comments there because neither is guessable:
both binaries in the same per-platform tarball. Asset names are unchanged and darwin is unaffected,
because the
mount-helperbuild is linux-only.archive has different count of binaries for each platform, which may cause your users confusion.allow_different_binary_count: trueis thereforenot a preference — without it, nothing at all is built.
packaging_test.gosays so on the field.scripts/install.sh— installsmount.objectfsbeside the binary and symlinks/sbin/mount.objectfs, with the same conservatismscripts/postinstall.shalready has: a foreignsymlink or a real file is left alone with a warning that names the
ln -s, a dangling link is nevercreated, and re-running is a no-op. New
--uninstall(removes the link, the binaries, and theinstall dir if empty) and
--no-mount-helper.One hazard the issue did not mention.
/sbin/mount.objectfsis exec'd bymount(8)as root.A link from there into a directory whose owner is not root is a local privilege escalation — and
sudo ./install.shwith the default~/.localprefix is exactly that shape.may_register()refuses it and prints the
sudo ln -sto run instead.README.mdstates the rule directly: do notrun the whole script under
sudoto 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.shis fetched over HTTPS and piped intobash— that is #138's acceptance criterion — sothere is no library file beside it to source. The maintainer scriptlets cannot source one either:
dpkgcopies them into/var/lib/dpkg/infoand runsprermwith the package's own files inwhatever state a
--forceleft them, so a sourced dependency is a scriptlet that fails to uninstall.So: a second copy, with drift caught behaviorally.
TestBothInstallPathsRegisterTheHelperTheSameWayand
TestBothUninstallPathsUnlinkTheHelperTheSameWayrunpostinstall.sh/preremove.shand thesourced
install.shfunctions through one shared table of cases — six states for install, fourfor 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/configwith-race,GOOS=linux golangci-lintandpre-commit on every changed file all pass.
Seven mutations, each confirmed to still parse, six caught by a named test: dropping
mount-helperfromarchives.ids; removingallow_different_binary_count; guttingmay_register's-Ocheck; removingunlink_mount_helper's[ "\$current" != "\$target" ]guard; makinglink_mount_helperclobber a foreign symlink withln -sf; turning the live-mountdieinto asay.The seventh survived and produced the second commit here. Narrowing
live_mounts's fstype matchchanged no outcome, because every matching row in the fixture named
objectfsas its device and thefuse.*+ device arm subsumed the rest. Anotobjectfs /mnt/renamed fuse.objectfsrow makes thefirst arm load-bearing; both discriminating mutations are now caught in both scripts.
| fuse.s3stays un-isolable and the test records why:
FSNameis hardcoded toobjectfs(#180 removed theoperator key), so isolating it would mean claiming any
fuse.s3mount is ours whatever its device,which would make
--uninstallrefuse over a stranger's filesystem. Filed separately.Note the
.goreleaser.ymldiff includes five single-line quote normalizations from pre-commit'spretty-format-yaml. That hook is not excluded for this file and the copy onmainalready failedit, so the churn is pre-existing; no test reads the quoting.
The
packagingjob is the only thing that can actually prove this — the tarball path ismount(8)behaviour nothing local stands in for.