Todd C. Miller
132936f8f0
Make it possible to call the sudoers policy check function multiple times.
...
We need to reset the Defaults values to their original state.
2021-08-09 15:50:25 -06:00
Todd C. Miller
08b0b626f1
Fix a potential use-after-free in conversation function.
...
The prompt passed in to sudo_pam_verify() will be freed later by
check_user_interactive() so we need to reset the stashed value.
From Pavel Heimlich. Bug #967 .
2021-03-03 08:19:44 -07:00
Pavel Březina
3b7977a42c
pam: pass KRB5CCNAME to pam_authenticate environment if available
...
If a PAM module wants to authenticate user using GSSAPI, the authentication
is broken if non-default ccache name is used in KRB5CCNAME environment
variable.
One way to mitigate this would be to add this to env_keep, but this also
makes the variable available in the executed command which may not
be always desirable.
This patch sets KRB5CCNAME for pam_authenticate only, if it is available
and not yet set.
2021-01-22 07:28:14 -07:00
Todd C. Miller
4e11bc0e26
Suppress PVS Studio false positives.
2021-01-06 14:27:09 -07:00
Todd C. Miller
e0c2635fb3
Apply Google inclusive language guidelines.
...
Also replace backwards with backward.
2020-10-30 10:15:30 -06:00
Todd C. Miller
88dcdcd11d
Fix -Wshadow warnings.
2020-09-25 15:09:45 -06:00
Todd C. Miller
874c2b27c6
Use a simple string compare on systems without crypt(3).
...
This is only used on systems without PAM, BSD authentication or AIX
authentication. Bug #940 .
2020-09-18 08:18:07 -06:00
Todd C. Miller
fb64210f75
Be consistent and use __hpux not __hpux__ like the rest of sudo.
2020-09-04 15:28:56 -06:00
Todd C. Miller
961a4afe67
Fix some warnings from pvs-studio
2020-08-12 13:45:09 -06:00
Todd C. Miller
ce97ca28db
Use OpenBSD-compatible freezero() in place of explicit_bzero() + free()
2020-08-10 19:24:33 -06:00
Todd C. Miller
cef6e3687e
Switch from memset_s() -> explicit_bzero().
...
memset_s() (and all of Annex K) is likely to be removed from the
a future version of the standard.
2020-08-10 19:24:32 -06:00
Todd C. Miller
03ad96e445
Use the fallthrough attribute instead of /* FALLTHROUGH */ comments.
2020-08-01 13:10:50 -06:00
Todd C. Miller
b519481912
Defer logging of the successful command until approval plugins have run.
...
This adds audit plugin support to the sudoers module, currently
only used for accept events. As a result, the sudoers file is now
initially parsed as an audit plugin.
2020-06-02 09:07:46 -06:00
Todd C. Miller
446ae3f507
Include string.h unconditionally and only use strings.h for strn?casecmp()
...
In the pre-POSIX days BSD had strings.h, not string.h.
Now strings.h is only used for non-ANSI string functions.
2020-05-18 07:59:24 -06:00
Todd C. Miller
9b8cb1a57a
Do not try to delete creds we did not set.
...
If pam_setcred() fails when opening the PAM session, we don't want
to call it with PAM_DELETE_CRED when closing the session.
2020-04-02 09:32:41 -06:00
Todd C. Miller
ec3fdd3aa8
Add a force flag to sudo_auth_cleanup() to force immediate cleanup.
...
This is used for PAM authentication to make sure pam_end() is called
via sudo_auth_cleanup() when the user authenticates successfully but
sudoers denies the command. Debian bug #669687
2020-04-01 14:41:38 -06:00
Todd C. Miller
e1df9d1dc3
Add pam_ruser and pam_rhost sudoers flags.
2020-03-01 13:37:00 -07:00
Todd C. Miller
486ee2b71f
debug_decl and debug_decl_vars now require a semicolon at the end.
2019-12-22 08:48:16 -07:00
Todd C. Miller
3ec23ad5e1
Minor style cleanups.
...
Remove extraneous break after return statement.
Convert two old K&R function declarations.
2019-12-13 19:27:38 -07:00
Todd C. Miller
5138ed9bec
Add sudo_pam_strerror(), like pam_strerror() but never returns NULL.
...
It also uses strerror(errno) for PAM_SYSTEM_ERR.
2019-08-29 17:30:13 -06:00
Todd C. Miller
60862b4d07
If pam_start() fails, display the PAM error using pam_strerror().
...
It is legal to pass pam_strerror() a NULL handle.
2019-08-29 08:31:21 -06:00
Todd C. Miller
972670bfca
Use the SUDO_CONV_PREFER_TTY flag during authentication.
...
This prevents the password and PAM prompts from being redirected.
Bug #895
2019-08-26 19:30:11 -06:00
Todd C. Miller
dae484213e
Allow the user to change their password if expired on AIX.
...
Bug #883
2019-05-27 06:35:48 -06:00
Todd C. Miller
07ed5b86f2
When using AIX auth, don't display the AIX password incorrect message.
...
Avoids a "3004-300 You entered an invalid login name or password"
message in addition to sudo's own "Sorry, try again" message.
2019-05-26 16:29:08 -06:00
Todd C. Miller
30a5ee9c5d
Remove second catopen() which is never called.
2019-05-06 10:04:07 -06:00
Todd C. Miller
976550084e
Add pam_acct_mgmt setting to enable/disable PAM account validation.
2019-04-29 19:44:13 -06:00
Todd C. Miller
1e1ef61902
Add SPDX-License-Identifier to files.
2019-04-29 07:21:51 -06:00
Todd C. Miller
96ac6adae5
Filter out last login messages on HP-UX unless running a shell.
...
HP-UX in trusted mode will display last login messages as part of
the PAM account management module by libpam_comsec. There is no
way to suppress these messages from the PAM configuration in trusted
mode so we need to filter them in the conversation function. In
regular mode, similar (but different) messages may be produced by
libpam_hpsec.
2019-04-28 07:26:45 -06:00
Todd C. Miller
de65d70929
Add a proper getdelim(3) replacement and use it instead of getline(3).
2019-04-08 10:37:30 -06:00
Todd C. Miller
f0910c01da
Restrict the PAM_TTY kludge to Solaris and Linux-PAM.
...
Setting PAM_TTY to the empty string causes problems with some modules
on HP-UX so restrict it to systems where it is fixes known issues.
2019-04-08 08:50:03 -06:00
Todd C. Miller
e2675d8f1e
Use PAM_SILENT to prevent pam_lastlog from printing last login
...
information on RedHat except when explicitly running a shell.
Adapted from a patch from Nir Soffer. Bug #867
2019-01-07 09:50:40 -07:00
Todd C. Miller
5242773489
In sudo_pam_approval(), for the exempt case, only overwrite pam
...
status when the passwd is expired or needs to be updated.
2018-12-08 08:10:04 -07:00
Todd C. Miller
4125808a85
The fix for bug #843 was incomplete and caused pam_end() to be called early.
...
sudo_pam_approval() must not set the global pam status to an error
value if it returns AUTH_SUCCESS. Otherwise, sudo_pam_cleanup()
will call pam_end() before sudo_pam_begin_session(). This resulted
in a NULL PAM handle being used in sudo_pam_begin_session().
2018-12-07 09:51:34 -07:00
Todd C. Miller
6c3d20cb41
Convert PVS-Studio comment to ANSI C.
2018-10-26 08:39:09 -06:00
Todd C. Miller
019279a4b8
Fix some mangled text in the license block.
2018-10-26 08:19:41 -06:00
Todd C. Miller
64e5d34c57
Add comments in .c files so PVS-Studio will check them.
2018-10-21 08:46:05 -06:00
Todd C. Miller
394524fd5d
Ignore PAM_NEW_AUTHTOK_REQD and PAM_AUTHTOK_EXPIRED errors from
...
pam_acct_mgmt() if authentication is disabled for the user.
Bug #843
2018-07-26 12:31:29 -06:00
Todd C. Miller
43003d29d8
Use arc4random for mkstemp() and insults.
2018-05-24 21:04:23 -06:00
Todd C. Miller
4c0c225062
Store passwd_timeout and timestamp_timeout as a struct timespec
...
instead of as a float. Remove timeout argument to auth_getpass()
as it was never used.
2018-01-22 12:18:48 -07:00
Todd C. Miller
594c2d4efd
Add an approval function to the sudo auth API which is run after
...
the user's password has been verified. The approval function is
run even if no password is required. This is currently only used
for PAM (use pam_acct_mgmt) and BSD auth (auth_approval).
2018-01-16 10:27:58 -07:00
Todd C. Miller
48fba3c2cc
update my email to Todd.Miller@sudo.ws
2017-12-03 17:53:40 -07:00
Todd C. Miller
8e021c39fa
Fix a logic error in 96651906de42 which prevented sudo from using
...
the PAM-supplied prompt. Bug #799
2017-09-05 09:30:19 -06:00
Todd C. Miller
43cbcbc24d
When deciding which prompt to use (PAM's or sudo's) treat the PAM
...
prompt "username's Password:" as equivalent to "Password:".
Some PAM modules (on AIX at least) use this prompt.
2017-07-20 16:06:47 -06:00
Todd C. Miller
7db97c7835
Avoid a clang analyzer false positive.
2017-05-12 10:02:18 -06:00
Todd C. Miller
d979898e71
Remove use of non-standard sigaction_t
2017-05-12 10:02:18 -06:00
Todd C. Miller
b63df21ba5
Fix declaration of sudo_krb5_verify() in the case where krb5_verify_user()
...
is not present. Bug #777
2017-03-10 11:52:49 -07:00
Todd C. Miller
0cde3f5de4
Fix sign compare warning.
2016-11-17 10:27:26 -07:00
Todd C. Miller
9d11b725c5
Remove Ultrix support, modern sudo can't run on Ultrix anyway.
2016-11-14 14:33:43 -07:00
Todd C. Miller
3f022419ae
Be consistent with the naming of the variable used to store the
...
function return value. Previously, some code used "rval", some
used "ret". This standardizes on "ret" and uses "rc" for temporary
return codes.
2016-09-08 16:38:08 -06:00
Todd C. Miller
a24f4b8248
Return PAM_CONV_ERR from the conversation function if getpass returns
...
NULL or the user pressed ^C.
2016-06-01 14:48:31 -06:00