From: Marco Trevisan (TreviƱo) Date: Mon, 16 Oct 2023 19:15:45 +0000 (+0200) Subject: auth-pam: Add an enum to define the PAM done status X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e8a45e0eeb5c84f12ac04ea7cc2f831c91c263b;p=thirdparty%2Fopenssh-portable.git auth-pam: Add an enum to define the PAM done status Makes things more readable and easier to extend --- diff --git a/auth-pam.c b/auth-pam.c index 1a5604690..1aba2dc5b 100644 --- a/auth-pam.c +++ b/auth-pam.c @@ -132,11 +132,16 @@ typedef pid_t sp_pthread_t; #define pthread_join fake_pthread_join #endif +typedef int SshPamDone; +#define SshPamError -1 +#define SshPamNone 0 +#define SshPamAuthenticated 1 + struct pam_ctxt { sp_pthread_t pam_thread; int pam_psock; int pam_csock; - int pam_done; + SshPamDone pam_done; }; static void sshpam_free_ctx(void *); @@ -907,7 +912,7 @@ sshpam_query(void *ctx, char **name, char **info, **prompts = NULL; *num = 0; **echo_on = 0; - ctxt->pam_done = -1; + ctxt->pam_done = SshPamError; free(msg); sshbuf_free(buffer); return 0; @@ -934,7 +939,7 @@ sshpam_query(void *ctx, char **name, char **info, import_environments(buffer); *num = 0; **echo_on = 0; - ctxt->pam_done = 1; + ctxt->pam_done = SshPamAuthenticated; free(msg); sshbuf_free(buffer); return (0); @@ -947,7 +952,7 @@ sshpam_query(void *ctx, char **name, char **info, *num = 0; **echo_on = 0; free(msg); - ctxt->pam_done = -1; + ctxt->pam_done = SshPamError; sshbuf_free(buffer); return (-1); } @@ -991,10 +996,10 @@ sshpam_respond(void *ctx, u_int num, char **resp) debug2_f("PAM: entering, %u responses", num); switch (ctxt->pam_done) { - case 1: + case SshPamAuthenticated: sshpam_authenticated = 1; return (0); - case 0: + case SshPamNone: break; default: return (-1);