]> git.armaanb.net Git - opendoas.git/blobdiff - pam.c
s/authorization/authentication/g
[opendoas.git] / pam.c
diff --git a/pam.c b/pam.c
index ee02b0faab8fa43d7c48e28d2f9cf569e9d2b82f..a9e203658e1093b3d9b675e818205106d2672df2 100644 (file)
--- a/pam.c
+++ b/pam.c
 #include <errno.h>
 #include <limits.h>
 #include <pwd.h>
-#ifdef HAVE_READPASSPHRASE_H
+#ifdef HAVE_READPASSPHRASE
 #      include <readpassphrase.h>
 #else
-#      include "readpassphrase.h"
+#      include "sys-readpassphrase.h"
 #endif
 #include <signal.h>
 #include <stdio.h>
@@ -37,7 +37,8 @@
 
 #include <security/pam_appl.h>
 
-#include "includes.h"
+#include "openbsd.h"
+#include "doas.h"
 
 #ifndef HOST_NAME_MAX
 #define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
@@ -123,7 +124,7 @@ fail:
        for (i = 0; i < nmsgs; i++) {
                if (rsp[i].resp == NULL)
                        continue;
-               switch (style = msgs[i]->msg_style) {
+               switch (msgs[i]->msg_style) {
                case PAM_PROMPT_ECHO_OFF:
                case PAM_PROMPT_ECHO_ON:
                        explicit_bzero(rsp[i].resp, strlen(rsp[i].resp));
@@ -131,6 +132,7 @@ fail:
                }
                rsp[i].resp = NULL;
        }
+       free(rsp);
 
        return PAM_CONV_ERR;
 }
@@ -243,7 +245,7 @@ pamauth(const char *user, const char *myname, int interactive, int nopass, int p
 #endif
 
        if (!user || !myname)
-               errx(1, "Authorization failed");
+               errx(1, "Authentication failed");
 
        ret = pam_start(PAM_SERVICE_NAME, myname, &conv, &pamh);
        if (ret != PAM_SUCCESS)
@@ -275,7 +277,7 @@ pamauth(const char *user, const char *myname, int interactive, int nopass, int p
 
        if (!nopass) {
                if (!interactive)
-                       errx(1, "Authorization required");
+                       errx(1, "Authentication required");
 
                /* doas style prompt for pam */
                char host[HOST_NAME_MAX + 1];
@@ -289,7 +291,7 @@ pamauth(const char *user, const char *myname, int interactive, int nopass, int p
                if (ret != PAM_SUCCESS) {
                        pamcleanup(ret, sess, cred);
                        syslog(LOG_AUTHPRIV | LOG_NOTICE, "failed auth for %s", myname);
-                       errx(1, "Authorization failed");
+                       errx(1, "Authentication failed");
                }
        }
 
@@ -302,7 +304,7 @@ pamauth(const char *user, const char *myname, int interactive, int nopass, int p
        if (ret != PAM_SUCCESS) {
                pamcleanup(ret, sess, cred);
                syslog(LOG_AUTHPRIV | LOG_NOTICE, "failed auth for %s", myname);
-               errx(1, "Authorization failed");
+               errx(1, "Authentication failed");
        }
 
        /* set PAM_USER to the user we want to be */
@@ -311,9 +313,9 @@ pamauth(const char *user, const char *myname, int interactive, int nopass, int p
                warn("pam_set_item(?, PAM_USER, \"%s\"): %s", user,
                    pam_strerror(pamh, ret));
 
-       ret = pam_setcred(pamh, PAM_ESTABLISH_CRED);
+       ret = pam_setcred(pamh, PAM_REINITIALIZE_CRED);
        if (ret != PAM_SUCCESS)
-               warn("pam_setcred(?, PAM_ESTABLISH_CRED): %s", pam_strerror(pamh, ret));
+               warn("pam_setcred(?, PAM_REINITIALIZE_CRED): %s", pam_strerror(pamh, ret));
        else
                cred = 1;