check_passwordless_sudo_available

Function check_passwordless_sudo_available 

Source
pub fn check_passwordless_sudo_available() -> Result<bool, String>
Expand description

What: Check if passwordless sudo is available for the current user.

Inputs:

  • None (checks system configuration).

Output:

  • Ok(true) if passwordless sudo is available, Ok(false) if not, or Err(String) on error.

§Errors

  • Returns Err if the check cannot be executed (e.g., sudo not installed).

Details:

  • Uses sudo -n true to test if sudo can run without password.
  • -n: Non-interactive mode (fails if password required).
  • true: Simple command that always succeeds if sudo works.
  • Returns Ok(false) if sudo is not available or requires a password.
  • Testing: Only when PACSEA_INTEGRATION_TEST=1 is set (test harness), the env var PACSEA_TEST_SUDO_PASSWORDLESS is honored: “1” = available, “0” = unavailable. In production (when PACSEA_INTEGRATION_TEST is not set), PACSEA_TEST_SUDO_PASSWORDLESS is ignored so the only way to enable passwordless sudo is via use_passwordless_sudo in settings.