1
0
mirror of https://github.com/Yubico/yubico-pam.git synced 2025-02-17 21:54:15 +01:00

do_chalendge needs drop privs twice at reading and writing

This commit is contained in:
madRat 2015-09-11 16:50:51 +03:00
parent 1036873b95
commit 3d22ed0c15

View File

@ -588,9 +588,11 @@ do_challenge_response(pam_handle_t *pamh, struct cfg *cfg, const char *username)
/* point to the fresh privs structure.. */
privs = privs2;
/* Drop privileges before creating new challenge file. */
if (pam_modutil_drop_priv(pamh, &privs, p)) {
DBG (("could not drop privileges"));
goto out;
if (!cfg->chalresp_path) {
if (pam_modutil_drop_priv(pamh, &privs, p)) {
DBG (("could not drop privileges"));
goto out;
}
}
/* Write out the new file */
@ -624,19 +626,15 @@ do_challenge_response(pam_handle_t *pamh, struct cfg *cfg, const char *username)
goto restpriv_out;
}
if (pam_modutil_regain_priv(pamh, &privs)) {
DBG (("could not restore privileges"));
goto out;
}
DBG(("Challenge-response success!"));
errstr = NULL;
errno = 0;
goto out;
restpriv_out:
if (pam_modutil_regain_priv(pamh, &privs)) {
DBG (("could not restore privileges"));
if (!cfg->chalresp_path) {
if (pam_modutil_regain_priv(pamh, &privs)) {
DBG (("could not restore privileges"));
}
}
out: