Skip to content

Commit

Permalink
Merge pull request #13608 from donaldsharp/pam_wrong
Browse files Browse the repository at this point in the history
vtysh: Give actual pam error messages
  • Loading branch information
ton31337 authored May 27, 2023
2 parents 618a9f0 + 8495b42 commit 607c84f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions vtysh/vtysh_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static struct pam_conv conv = {PAM_CONV_FUNC, NULL};

static int vtysh_pam(const char *user)
{
int ret;
int ret, second_ret;
pam_handle_t *pamh = NULL;

/* Start PAM. */
Expand All @@ -56,15 +56,18 @@ static int vtysh_pam(const char *user)
fprintf(stderr, "vtysh_pam: Failure to initialize pam: %s(%d)",
pam_strerror(pamh, ret), ret);

if (pam_acct_mgmt(pamh, 0) != PAM_SUCCESS)
second_ret = pam_acct_mgmt(pamh, 0);
if (second_ret != PAM_SUCCESS)
fprintf(stderr, "%s: Failed in account validation: %s(%d)",
__func__, pam_strerror(pamh, ret), ret);
__func__, pam_strerror(pamh, second_ret), second_ret);

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

Expand Down

0 comments on commit 607c84f

Please sign in to comment.