_sudo: use sudo -n when no sudo password is configured #10

Open
opened 2026-10-05 11:45:12 +00:00 by christianmanivong · 0 comments
Owner

_sudo() sends a plain sudo <cmd> when no sudo_password is set. If sudo then wants a password, its prompt does not match netmiko's expect_string. The call hangs until read_timeout (100 s by default) and then raises.

_run_service_command (#9) already uses sudo -n in that case: it fails at once with "a password is required". Doing the same in _sudo() would give every other caller the same behaviour: package install/uninstall, updates, crontabs, VPN tunnels. That would make the two sudo -n true pre-checks in _action_apt_update_upgrade and _action_fix_snmp unnecessary.

`_sudo()` sends a plain `sudo <cmd>` when no `sudo_password` is set. If sudo then wants a password, its prompt does not match netmiko's `expect_string`. The call hangs until `read_timeout` (100 s by default) and then raises. `_run_service_command` (#9) already uses `sudo -n` in that case: it fails at once with "a password is required". Doing the same in `_sudo()` would give every other caller the same behaviour: package install/uninstall, updates, crontabs, VPN tunnels. That would make the two `sudo -n true` pre-checks in `_action_apt_update_upgrade` and `_action_fix_snmp` unnecessary.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-linux#10