Push non-interactive mode checking down into the auth methods.

For "sudo -n" we only want to reject a command if user input is
actually required.  In the case of PAM at least, we may not need
to interact with the user.  Bug #956, GitHub issue #83
This commit is contained in:
Todd C. Miller
2022-01-04 18:57:36 -07:00
parent 296d876b76
commit 521ef37aea
14 changed files with 72 additions and 21 deletions

View File

@@ -45,6 +45,10 @@ Possible values of sudo_auth.flags:
to determine whether to return a fatal or nonfatal
error.
FLAG_NONINTERACTIVE If set, this indicates that the user invoked
sudo with the -n option and no user interaction
is allowed.
The member functions can return the following values:
AUTH_SUCCESS Function succeeded. For a ``verify'' function
this means the user correctly authenticated.
@@ -59,6 +63,14 @@ The member functions can return the following values:
When verify_user() gets AUTH_FATAL from an auth
function it does an exit(1).
AUTH_INTR An attempt to read the password read was interrupted.
Usually this means the user entered ^C at the
password prompt.
AUTH_NONINTERACTIVE Function failed because user interaction was
required but sudo was run in non-interactive
mode.
The functions in the struct are as follows:
int init(struct passwd *pw, sudo_auth *auth)