Don't print an error if we are doing authentication.

This commit is contained in:
christos 2005-04-05 18:24:17 +00:00
parent 96cf4771d1
commit b4eda329f4

View File

@ -1,4 +1,4 @@
/* $NetBSD: pam_group.c,v 1.6 2005/03/31 15:11:54 thorpej Exp $ */
/* $NetBSD: pam_group.c,v 1.7 2005/04/05 18:24:17 christos Exp $ */
/*-
* Copyright (c) 2003 Networks Associates Technology, Inc.
@ -38,7 +38,7 @@
#ifdef __FreeBSD__
__FBSDID("$FreeBSD: src/lib/libpam/modules/pam_group/pam_group.c,v 1.4 2003/12/11 13:55:15 des Exp $");
#else
__RCSID("$NetBSD: pam_group.c,v 1.6 2005/03/31 15:11:54 thorpej Exp $");
__RCSID("$NetBSD: pam_group.c,v 1.7 2005/04/05 18:24:17 christos Exp $");
#endif
#include <sys/types.h>
@ -71,7 +71,7 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused,
char *const *list;
struct passwd *pwd, pwres;
struct group *grp;
int pam_err;
int pam_err, auth;
char *promptresp = NULL;
char pwbuf[1024];
@ -88,6 +88,8 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused,
|| ruser == NULL || (pwd = getpwnam(ruser)) == NULL)
return (PAM_AUTH_ERR);
auth = openpam_get_option(pamh, "authenticate") != NULL;
/* get regulating group */
if ((group = openpam_get_option(pamh, "group")) == NULL)
group = "wheel";
@ -108,14 +110,17 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused,
not_found:
if (openpam_get_option(pamh, "deny"))
return (PAM_SUCCESS);
pam_err = pam_prompt(pamh, PAM_ERROR_MSG, &promptresp,
"%s: You are not listed in the correct secondary group"
" (%s) to %s %s.", getprogname(), group, getprogname(), user);
if (pam_err == PAM_SUCCESS && promptresp)
free(promptresp);
if (!auth) {
pam_err = pam_prompt(pamh, PAM_ERROR_MSG, &promptresp,
"%s: You are not listed in the correct secondary group"
" (%s) to %s %s.", getprogname(), group, getprogname(),
user);
if (pam_err == PAM_SUCCESS && promptresp)
free(promptresp);
}
return (PAM_AUTH_ERR);
found:
if (openpam_get_option(pamh, "authenticate"))
if (auth)
if ((pam_err = authenticate(pamh, pwd, flags)) != PAM_SUCCESS)
return pam_err;