Expand description
SUDO_ASKPASS helper for non-interactive privileged operations.
sudo -n (non-interactive) fails whenever a password is required and no
NOPASSWD policy / cached timestamp covers it — which is the common case on a
normal desktop. That breaks every privileged step (/opt/rocm removal,
package-manager purge, and — on Arch — yay’s internal sudo pacman).
This module writes the caller-supplied password to a mode-0600 file owned
by the current user, next to a mode-0700 askpass script that cats it,
inside a private temp directory. Assign the script path to SUDO_ASKPASS
and run sudo -A … (or, for yay, yay --sudoflags=-A …): sudo reads the
password from the helper with no TTY and no interactive prompt.
Notes:
sudoalways honorsSUDO_ASKPASSeven underenv_reset, and-Aselects the askpass path over a terminal prompt.- The password is never placed in a shell command line (no quoting risk);
it lives only in a root-unreadable, user-owned file for the operation’s
duration.
Askpassis an RAII guard that wipes both files on drop. yaymust run as the user, never undersudo(it refuses root for AUR builds); its internalsudo pacmanis what consumes the askpass helper via--sudoflags=-A.
Structs§
- Askpass
- RAII askpass helper.