Skip to content

fix(cli): do not print the banner again on the sudo re-invoke - #807

Merged
discount-elf merged 2 commits into
mainfrom
feat/no-banner-on-sudo-reexec
Dec 4, 2026
Merged

discount-elf merged 2 commits into
mainfrom
feat/no-banner-on-sudo-reexec

Conversation

@discount-elf

Copy link
Copy Markdown
Contributor

Why

When the install tree is root-owned, building the package manager re-invokes the CLI under sudo. The first run has already printed the banner, and the re-invoked run printed it again.

What

  • Adds `banner.Suppress()`, which sets `PEL_NO_BANNER=true` for the process and anything it execs (the variable from feat(cli): suppress the banner when PEL_NO_BANNER is set #806).
  • Calls it after the banner is printed and before the manager is built in `update`, `update list`, `refresh` and `clean`.
  • For the `plugin` subcommands (`install`, `uninstall`, `update`, `info`, `list`, `search`) the call sits in `NewCLIPluginManager`, the one place they all build a manager. Those commands print their banner in `run…ForHumans`, below `RunE`, so setting the variable at the top of `RunE` would have suppressed the first banner as well.
  • Bumps orbital from v0.2.5 to v0.2.8. v0.2.5 re-invokes with plain `sudo`, which drops the variable under the default `env_reset`; v0.2.6 onwards uses `sudo -E`. Without the bump the change has no effect. The bump also brings orbital's S3 region auto-configuration and anonymous-credential fallback, and moves the indirect AWS S3 SDK modules forward.

Testing

  • `go test -tags=unit` passes for `internal/cli/{banner,plugin,update,refresh,clean}`, `internal/opsmgr` and `internal/metastructure/plugin_manager`, including a new test for `Suppress`.
  • End to end with a stand-in `sudo` on `PATH` that resets the environment unless given `-E`, running `formae clean` in a pseudo-terminal against root-owned `/opt/pel`: `main` prints the banner twice, this branch prints it once and the re-invoked process sees `PEL_NO_BANNER=true`.
  • Not run against real sudo. `sudo -E` is honoured when the sudoers rule allows it, which a rule granting `ALL` commands does.

v0.2.6 onwards re-invokes the CLI with sudo -E, so the environment
reaches the privileged run. v0.2.5 dropped it under sudo's default
env_reset.
Commands that build a package manager against a root-owned install tree
are re-invoked under sudo, and the second run printed the banner a
second time. They now set PEL_NO_BANNER once their own banner is out, so
the re-invoked process stays quiet.
@discount-elf
discount-elf merged commit bf219aa into main Dec 4, 2026
46 checks passed
@discount-elf
discount-elf deleted the feat/no-banner-on-sudo-reexec branch December 4, 2026 18:50
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.

1 participant