Skip to main content

Module askpass

Module askpass 

Source
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:

  • sudo always honors SUDO_ASKPASS even under env_reset, and -A selects 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. Askpass is an RAII guard that wipes both files on drop.
  • yay must run as the user, never under sudo (it refuses root for AUR builds); its internal sudo pacman is what consumes the askpass helper via --sudoflags=-A.

Structs§

Askpass
RAII askpass helper.