fix(desktop): use sudo callback without interactive env
This commit is contained in:
@@ -777,7 +777,8 @@ def _transform_sudo_command(command: str | None) -> tuple[str | None, str | None
|
||||
the password in the command string themselves; see their execute()
|
||||
methods for how they handle the non-None sudo_stdin case.
|
||||
|
||||
If SUDO_PASSWORD is not set and in interactive mode (HERMES_INTERACTIVE=1):
|
||||
If SUDO_PASSWORD is not set and an interactive UI is available
|
||||
(HERMES_INTERACTIVE=1 or a registered sudo password callback):
|
||||
Prompts user for password with 45s timeout, caches for session.
|
||||
|
||||
If SUDO_PASSWORD is not set and NOT interactive:
|
||||
@@ -805,7 +806,11 @@ def _transform_sudo_command(command: str | None) -> tuple[str | None, str | None
|
||||
if not has_configured_password and not sudo_password and _sudo_nopasswd_works():
|
||||
return command, None
|
||||
|
||||
if not has_configured_password and not sudo_password and env_var_enabled("HERMES_INTERACTIVE"):
|
||||
has_sudo_prompt_callback = _get_sudo_password_callback() is not None
|
||||
should_prompt_for_sudo = (
|
||||
env_var_enabled("HERMES_INTERACTIVE") or has_sudo_prompt_callback
|
||||
)
|
||||
if not has_configured_password and not sudo_password and should_prompt_for_sudo:
|
||||
sudo_password = _prompt_for_sudo_password(timeout_seconds=45)
|
||||
if sudo_password:
|
||||
_set_cached_sudo_password(sudo_password)
|
||||
|
||||
Reference in New Issue
Block a user