Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vtysh: Try to be perscriptive about pam failures #4608

Merged
merged 1 commit into from
Jun 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
vtysh: Try to be perscriptive about pam failures
When using pam for authentication, the code just silently
fails and gives no indication to the end user what has gone
wrong.  Try to increase messaging about what has gone wrong
by outputting some more data.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
donaldsharp committed Jun 26, 2019
commit 60bc8d619ccc42565a2b5bf1541014b4bfcaeb7a
25 changes: 5 additions & 20 deletions vtysh/vtysh_user.c
Original file line number Diff line number Diff line change
@@ -62,35 +62,20 @@ static int vtysh_pam(const char *user)

/* Start PAM. */
ret = pam_start(FRR_PAM_NAME, user, &conv, &pamh);
/* printf ("ret %d\n", ret); */

/* Is user really user? */
if (ret == PAM_SUCCESS)
ret = pam_authenticate(pamh, 0);
/* printf ("ret %d\n", ret); */

#if 0
/* Permitted access? */
if (ret == PAM_SUCCESS)
ret = pam_acct_mgmt (pamh, 0);
printf ("ret %d\n", ret);

if (ret == PAM_AUTHINFO_UNAVAIL)
ret = PAM_SUCCESS;
#endif /* 0 */

/* This is where we have been authorized or not. */
#ifdef DEBUG
if (ret == PAM_SUCCESS)
printf("Authenticated\n");
else
printf("Not Authenticated\n");
#endif /* DEBUG */
if (ret != PAM_SUCCESS)
fprintf(stderr, "vtysh_pam: Failure to initialize pam: %s(%d)",
pam_strerror(pamh, ret), ret);

/* close Linux-PAM */
if (pam_end(pamh, ret) != PAM_SUCCESS) {
pamh = NULL;
fprintf(stderr, "vtysh_pam: failed to release authenticator\n");
fprintf(stderr, "vtysh_pam: failed to release authenticator: %s(%d)\n",
pam_strerror(pamh, ret), ret);
exit(1);
}