slock

Kris's build of slock (slock-flexipatch)
git clone git clone https://git.krisyotam.com/krisyotam/slock.git
Log | Files | Refs | README | LICENSE

pamauth.c (717B)


      1 char passwd[256];
      2 
      3 static int
      4 pam_conv(int num_msg, const struct pam_message **msg,
      5 		struct pam_response **resp, void *appdata_ptr)
      6 {
      7 	int retval = PAM_CONV_ERR;
      8 	for (int i=0; i<num_msg; i++) {
      9 		if (msg[i]->msg_style == PAM_PROMPT_ECHO_OFF &&
     10 				strncmp(msg[i]->msg, "Password: ", 10) == 0) {
     11 			struct pam_response *resp_msg = malloc(sizeof(struct pam_response));
     12 			if (!resp_msg)
     13 				die("malloc failed\n");
     14 			char *password = malloc(strlen(passwd) + 1);
     15 			if (!password)
     16 				die("malloc failed\n");
     17 			memset(password, 0, strlen(passwd) + 1);
     18 			strcpy(password, passwd);
     19 			resp_msg->resp_retcode = 0;
     20 			resp_msg->resp = password;
     21 			resp[i] = resp_msg;
     22 			retval = PAM_SUCCESS;
     23 		}
     24 	}
     25 	return retval;
     26 }
     27