servicePath omits /run/wrappers/bin and NoNewPrivileges=true blocks sudo; add an enableSudo option #1
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
servicePath(the module'sEnvironment=PATH=entry) never contains/run/wrappers/bin, and the unit hardcodesNoNewPrivileges = true. On NixOS hosts where the terminal must runsudo/su/ping, baresudoresolves the non-setuid store symlink and fails with "must be owned by uid 0 and have the setuid bit set".Login shells appear to work (NixOS patches bash to source
/etc/bashrc, which prepends/run/wrappers/bin), but non-login shells - i.e. whatPOST /executeruns (bash flagshBc) - do not. That asymmetry makes the bug look like an auth problem.Workarounds today need an overlay that fights the module's private
let:servicePathis not exported, so overridingEnvironment=PATHmeans duplicating the whole toolchain list, which rots on every upstream bump.Proposal
Add
services.open-terminal.enableSudo(defaultfalse):PathPrependmatters: PATH is first-match, and/run/current-system/sw/binis already on the service PATH, soPathAppendleaves the broken symlink first and the fix is silently dead.Option docs should warn that this grants root to anyone who can reach the API as that user, and that it does not by itself enable passwordless sudo (the host still needs
security.sudo.wheelNeedsPassword/ sudoers).Context
Discovered while enabling sudo on nix-dev (RandomRepair/nixos-config
4e303e1,ac82268).Fixed in
9f458ffon main: newservices.open-terminal.enableSudo(bool, default false).When true the emitted unit gets
NoNewPrivileges=falseplusPathPrepend=/run/wrappers/binviaserviceConfig. Prepended, not appended:/run/current-system/sw/bin/sudois a plain non-setuid store symlink and PATH is first-match.ExtraEnvwas ruled out -- the generated unit emits a literal ignoredExtraEnv=line, and the unit sets PATH twice (a quoted nixpkgs default line and the module toolchain line), so parsing them can pick the default one.Verified by evaluating the pinned example config: default arm is byte-identical to before (still
NoNewPrivileges=true, noPathPrepend);enableSudo=trueyields both lines. README option table updated.Downstream RandomRepair/nixos-config#1 now sets
enableSudo = trueand keeps only theProtectSystem = mkForce "off"host override; generated unit diff against the deployed one was empty, so no behavior change on nix-dev. The api.key 0700/root-owner tradeoff is tracked separately as RandomRepair/nixos-config#3 and stays open there; this issue covers only the module option.