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

Multiple errors on wrong password #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 12 additions & 3 deletions src/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "auth.h"

struct conv_data {
char authentication_err;
const char *pw;
int *err;
int *out;
Expand Down Expand Up @@ -58,15 +59,23 @@ static int conversation(
switch(msg[i]->msg_style) {
case PAM_PROMPT_ECHO_OFF:
case PAM_PROMPT_ECHO_ON:
if (data->authentication_err == 1) {
free(*resp);
*resp = NULL;
return PAM_ABORT;
}

resp[i]->resp = strdup(data->pw);
if(resp[i]->resp == NULL) {
g_warning("Failed allocation");
return PAM_ABORT;
}
break;
case PAM_ERROR_MSG:
send_msg(msg[i]->msg, data->err[1]);
break;
//send_msg(msg[i]->msg, data->err[1]);
g_warning("gtklock: Wrong password!");
data->authentication_err = 1;
break;
case PAM_TEXT_INFO:
send_msg(msg[i]->msg, data->out[1]);
break;
Expand All @@ -88,7 +97,7 @@ static void auth_child(const char *s, int *err, int *out) {
char *username = pwd->pw_name;
int pam_status;
struct pam_handle *handle;
struct conv_data data = { .pw = s, .err = err, .out = out };
struct conv_data data = { .authentication_err = 0, .pw = s, .err = err, .out = out };
struct pam_conv conv = { conversation, (void *)&data };
pam_status = pam_start("gtklock", username, &conv, &handle);
if(pam_status != PAM_SUCCESS) {
Expand Down