mirror of
https://github.com/mintycube/slock.git
synced 2024-10-22 14:05:51 +02:00
28 lines
717 B
C
28 lines
717 B
C
char passwd[256];
|
|
|
|
static int
|
|
pam_conv(int num_msg, const struct pam_message **msg,
|
|
struct pam_response **resp, void *appdata_ptr)
|
|
{
|
|
int retval = PAM_CONV_ERR;
|
|
for (int i=0; i<num_msg; i++) {
|
|
if (msg[i]->msg_style == PAM_PROMPT_ECHO_OFF &&
|
|
strncmp(msg[i]->msg, "Password: ", 10) == 0) {
|
|
struct pam_response *resp_msg = malloc(sizeof(struct pam_response));
|
|
if (!resp_msg)
|
|
die("malloc failed\n");
|
|
char *password = malloc(strlen(passwd) + 1);
|
|
if (!password)
|
|
die("malloc failed\n");
|
|
memset(password, 0, strlen(passwd) + 1);
|
|
strcpy(password, passwd);
|
|
resp_msg->resp_retcode = 0;
|
|
resp_msg->resp = password;
|
|
resp[i] = resp_msg;
|
|
retval = PAM_SUCCESS;
|
|
}
|
|
}
|
|
return retval;
|
|
}
|
|
|