omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

`sudo visudo` opens an empty buffer named `--` instead of /etc/sudoers.tmp (regression from #11495)

Open burninc0de opened this issue 1 month ago • 2 comments

Title: sudo visudo opens an empty buffer named -- instead of /etc/sudoers.tmp (regression from #11495)


What happens

On a stock install with the default editor, sudo visudo opens the editor on a blank buffer named --. /etc/sudoers.tmp is loaded, but only as the second buffer, so the first thing on screen is an empty file and it looks like the sudoers file is empty.

Editing and saving that blank buffer does not touch the sudoers file: visudo reports /etc/sudoers.tmp unchanged and discards the edit.

Environment

  • Omarchy 4.0.6-1 (quattro)
  • sudo 1.9.17p2, nvim (no vi/vim/nano installed)
  • EDITOR=omarchy-launch-editor --inline, NVIM_APPNAME untouched, default editor = neovim

Reproduction

$ sudo visudo

Expected: nvim shows the contents of /etc/sudoers (5031 bytes on a stock Arch sudoers).

Actual: nvim opens two buffers, the first one empty:

buf: /home/user/--
buf: /etc/sudoers.tmp

:n reaches the real file. Nothing was lost — /etc/sudoers is intact — but the screen suggests otherwise.

Why

visudo invokes the editor with its own -- separator. Confirmed with a probe editor set via SUDO_EDITOR:

arg1=[--]
arg2=[/etc/sudoers.tmp]

/etc/sudoers deliberately keeps the editor across sudo for visudo only:

Defaults!/usr/bin/visudo env_keep += "SUDO_EDITOR EDITOR VISUAL"

so visudo runs omarchy-launch-editor --inline -- /etc/sudoers.tmp.

Since #11495 (b72d7e5, "Treat command operands as literal values") the wrapper appends its own separator to whatever it receives:

case "${editor##*/}" in
nvim | vim | nano | micro | hx | helix | fresh)
  if [[ $inline == "true" ]]; then
    exec "$editor" -- "$@"        # → nvim -- -- /etc/sudoers.tmp
  else
    exec omarchy-launch-tui "$editor" -- "$@"
  fi
  ;;
*)
  exec setsid uwsm-app -- "$editor" -- "$@"   # GUI editors: same doubling
  ;;
esac

Everything after the first -- is a filename to the editor, so the second -- becomes a file of its own (nvim --headless ... -- -- /tmp/real.txt lists exactly that: buf: /tmp/--, buf: /tmp/real.txt).

All three branches are affected; the --inline GUI-detach problem in #9503 is a separate issue.

Regression window

  • Before b72d7e5 (merged 2026-09-22, in 4.0.6): exec "$editor" "$@" → nvim /etc/sudoers.tmp → works.
  • After: double separator → empty first buffer.

Any caller that already terminates its option list is now broken the same way; visudo is the one that matters for everyone on a stock install. vipw/vigr (#11461) pass a bare path and are fine.

Workaround

sudo EDITOR=nvim visudo

or press :n in the buffer that opens. For the actual config change, a drop-in avoids visudo entirely:

sudo tee /etc/sudoers.d/99-flair >/dev/null <<'EOF'
Defaults pwfeedback
Defaults insults
EOF
sudo chmod 640 /etc/sudoers.d/99-flair
sudo visudo -c

Related

  • #9500 — visudo from a root shell has no editor (/usr/bin/vi missing)
  • #9503 — GUI editors detach under sudo visudo, edits silently dropped
  • #11461 — same env-keeping problem for vipw/vigr
  • #11495 — the hardening change that introduced the doubling

Not asking for a specific fix — the -- hardening in #11495 should stay; it just needs to coexist with callers that already pass a separator. Happy to test a patch.

burninc0de avatar Oct 27 '26 08:10 burninc0de

Bisected the version: this landed in 4.0.5.

v4.0.4  bin/omarchy-launch-editor:  exec "$editor" "$@"        # good
v4.0.5  bin/omarchy-launch-editor:  exec "$editor" -- "$@"     # broken
v4.0.6  same
v4.5.0-rc2 / quattro: same

Matches the local pacman log: 4.0.4 → 4.0.5 on 2026-10-18, 4.0.6 on 2026-10-20. sudo was installed 2026-08-19 and has not been upgraded since, so visudo's separator is unchanged — the wrapper is the only variable.

Still present in quattro and v4.5.0-rc2.

burninc0de avatar Oct 27 '26 08:10 burninc0de

Codex (reasoning effort not exposed by this session) read the report, follow-up, and current editor launcher. The configured classifier, deepseek-v4p1-flash, returned no classification answer, so the required agreement on classification is missing. No reproduction or tests ran, and no issue review by a second model was performed. Classification needs to be settled before verification can continue.

omarchybot avatar Nov 18 '26 17:11 omarchybot