Skip to content

Ask for the sudo password on screen instead of requiring passwordless sudo - #1

Closed
Z3R0C1PH3R wants to merge 2 commits into
baltamir1978:mainfrom
Z3R0C1PH3R:sudo-password-prompt
Closed

Z3R0C1PH3R wants to merge 2 commits into
baltamir1978:mainfrom
Z3R0C1PH3R:sudo-password-prompt

Conversation

@Z3R0C1PH3R

Copy link
Copy Markdown
Contributor

When the device user needs a password for sudo, changing a system setting used to fail with "Needs passwordless sudo". Now ZeroPower asks for the password on screen and retries the change.

How it works

  • PowerControl::apply still tries sudo -n first, so passwordless setups behave exactly as before.
  • If sudo replies that a password is required, the settings list shows a Password required screen. It names the setting and the user, and has a masked field plus ENTER confirm / ESC cancel.
  • On ENTER the change is retried with env LC_ALL=C sudo -S -p "" zeropower-helper set ….
    • The password goes in through stdin: run_process now takes optional input. It is never on the command line, so it never shows in /proc.
    • It is never stored, and it is wiped from memory after use (SecretInput, wipe).
  • A wrong password re-opens the prompt with Wrong password, try again. A user who isn't allowed to use sudo gets This user can't use sudo.
  • sudo's own timestamp then lets the following changes go through without asking again for a few minutes, as in a terminal.

Typing the password

  • linux_input now understands Shift: capital letters, plus US shifted symbols on USB keyboards.
  • It also understands the Cardputer keypad's Sym layer, read from /usr/share/keymaps/tca8418_keypad_m5stack_keymap.map, with a built-in copy as fallback. Some of those codes collide with PC punctuation codes (51 is & there, not ,), so they only apply to the tca8418 device.
  • A key's release now maps to the same value as its press, even if Shift was released in between, so no key gets stuck.
  • T doesn't toggle the theme while the password field is open (BaseViewModel::set_text_entry).

Other

  • classify_sudo and SecretInput live in src/model/sudo_password.* and have tests in power_model_test.
  • In the simulator, ZEROPOWER_SIMULATE_SUDO=<password> makes the simulated system ask for it once.
  • The three leftover Spanish toasts are now in English: Hold ESC to exit, Saved to …, Screenshot failed: ….
  • README, CLAUDE.md and the store description are updated. I left the version number alone.

Tested

  • On a Cardputer Zero (Debian 13) where pi needs a password for sudo:
    • The first change showed the prompt. A wrong password re-prompted with the error; the right one applied the change.
    • The next changes (Bluetooth, HDMI desktop, GPU memory) applied without asking again.
    • The sudo log on the device confirms the sequence.
  • power_model_test passes. Built with the cp0-cross-package workflow in a Debian trixie container.

Made with Cursor

Z3R0C1PH3R and others added 2 commits November 24, 2026 23:45
Si `sudo -n` dice que hace falta contraseña, la lista de ajustes la pide encima
(«Password required») y repite el cambio con `sudo -S -p ""`. La contraseña va por
la entrada estándar (run_process admite ahora entrada), nunca en la línea de
órdenes; no se guarda y se borra de la memoria al acabar (SecretInput, wipe). Si
no vale, se vuelve a pedir con el aviso en rojo. Sudo la recuerda unos minutos.

- model/sudo_password: classify_sudo (mensajes de sudo con LC_ALL=C) y SecretInput,
  con pruebas en power_model_test.
- linux_input: Shift (mayúsculas y signos de un teclado de PC) y la capa Sym del
  Cardputer, leída de su mapa de teclas; al soltar sale la misma tecla que al pulsar.
- La T no cambia el tema mientras se escribe la contraseña.
- Simulador: ZEROPOWER_SIMULATE_SUDO=<clave> para probar la pantalla.
El resto de la interfaz ya estaba en inglés: «Mantén ESC para salir», «Guardada en» y
«No se pudo capturar» se habían quedado en español.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Z3R0C1PH3R

Copy link
Copy Markdown
Contributor Author

Closing for now: fixing some layout issues first. Will reopen when it's ready.

@Z3R0C1PH3R

Copy link
Copy Markdown
Contributor Author

Superseded by #2, which includes these changes plus the layout fixes.

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