diff options
Diffstat (limited to 'auth-pam.c')
| -rw-r--r-- | auth-pam.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/auth-pam.c b/auth-pam.c index bde0a8f561f2..d3f400bc3034 100644 --- a/auth-pam.c +++ b/auth-pam.c @@ -197,7 +197,7 @@ pthread_create(sp_pthread_t *thread, const void *attr, switch ((pid = fork())) { case -1: error("fork(): %s", strerror(errno)); - return (-1); + return errno; case 0: close(ctx->pam_psock); ctx->pam_psock = -1; @@ -258,7 +258,7 @@ static char ** pam_getenvlist(pam_handle_t *pamh) { /* - * XXX - If necessary, we can still support envrionment passing + * XXX - If necessary, we can still support environment passing * for platforms without pam_getenvlist by searching for known * env vars (e.g. KRB5CCNAME) from the PAM environment. */ @@ -266,6 +266,14 @@ pam_getenvlist(pam_handle_t *pamh) } #endif +#ifndef HAVE_PAM_PUTENV +static int +pam_putenv(pam_handle_t *pamh, const char *name_value) +{ + return PAM_SUCCESS; +} +#endif /* HAVE_PAM_PUTENV */ + /* * Some platforms, notably Solaris, do not enforce password complexity * rules during pam_chauthtok() if the real uid of the calling process @@ -360,13 +368,11 @@ import_environments(struct sshbuf *b) for (i = 0; i < num_env; i++) { if ((r = sshbuf_get_cstring(b, &env, NULL)) != 0) fatal("%s: buffer error: %s", __func__, ssh_err(r)); -#ifdef HAVE_PAM_PUTENV /* Errors are not fatal here */ if ((r = pam_putenv(sshpam_handle, env)) != PAM_SUCCESS) { error("PAM: pam_putenv: %s", pam_strerror(sshpam_handle, r)); } -#endif /* XXX leak env? */ } #endif @@ -535,7 +541,7 @@ sshpam_thread(void *ctxtp) for (i = 0; environ[i] != NULL; i++) { /* Count */ if (i > INT_MAX) - fatal("%s: too many enviornment strings", __func__); + fatal("%s: too many environment strings", __func__); } if ((r = sshbuf_put_u32(buffer, i)) != 0) fatal("%s: buffer error: %s", __func__, ssh_err(r)); @@ -548,7 +554,7 @@ sshpam_thread(void *ctxtp) for (i = 0; env_from_pam != NULL && env_from_pam[i] != NULL; i++) { /* Count */ if (i > INT_MAX) - fatal("%s: too many PAM enviornment strings", __func__); + fatal("%s: too many PAM environment strings", __func__); } if ((r = sshbuf_put_u32(buffer, i)) != 0) fatal("%s: buffer error: %s", __func__, ssh_err(r)); @@ -770,7 +776,7 @@ static void * sshpam_init_ctx(Authctxt *authctxt) { struct pam_ctxt *ctxt; - int socks[2]; + int result, socks[2]; debug3("PAM: %s entering", __func__); /* @@ -797,9 +803,10 @@ sshpam_init_ctx(Authctxt *authctxt) } ctxt->pam_psock = socks[0]; ctxt->pam_csock = socks[1]; - if (pthread_create(&ctxt->pam_thread, NULL, sshpam_thread, ctxt) == -1) { + result = pthread_create(&ctxt->pam_thread, NULL, sshpam_thread, ctxt); + if (result != 0) { error("PAM: failed to start authentication thread: %s", - strerror(errno)); + strerror(result)); close(socks[0]); close(socks[1]); free(ctxt); @@ -844,6 +851,7 @@ sshpam_query(void *ctx, char **name, char **info, plen += mlen; **echo_on = (type == PAM_PROMPT_ECHO_ON); free(msg); + sshbuf_free(buffer); return (0); case PAM_ERROR_MSG: case PAM_TEXT_INFO: @@ -872,6 +880,7 @@ sshpam_query(void *ctx, char **name, char **info, **echo_on = 0; ctxt->pam_done = -1; free(msg); + sshbuf_free(buffer); return 0; } /* FALLTHROUGH */ @@ -898,6 +907,7 @@ sshpam_query(void *ctx, char **name, char **info, **echo_on = 0; ctxt->pam_done = 1; free(msg); + sshbuf_free(buffer); return (0); } error("PAM: %s for %s%.100s from %.100s", msg, @@ -909,9 +919,11 @@ sshpam_query(void *ctx, char **name, char **info, **echo_on = 0; free(msg); ctxt->pam_done = -1; + sshbuf_free(buffer); return (-1); } } + sshbuf_free(buffer); return (-1); } @@ -1205,7 +1217,6 @@ int do_pam_putenv(char *name, char *value) { int ret = 1; -#ifdef HAVE_PAM_PUTENV char *compound; size_t len; @@ -1215,7 +1226,6 @@ do_pam_putenv(char *name, char *value) snprintf(compound, len, "%s=%s", name, value); ret = pam_putenv(sshpam_handle, compound); free(compound); -#endif return (ret); } |
