/* FILENAME : pam_panic.c DESCRIPTION : The pam_panic PAM module shall protect people who have value data on their computer. It provides a panic function. AUTHOR : Bandie DATE : 2018-03-27T02:34:08+02:00 LICENSE : GNU-GPLv3 */ #include #include #include #include #include #include #include #include #include #include #include "config.h" #include "pam_panic_reject.h" #include "pam_panic_authdevice.h" #include "pam_panic_password.h" #ifdef REBOOT #ifdef POWEROFF #ifdef CRYPTSETUP int makeRegex(pam_handle_t *pamh, regex_t *regex){ char *pattern = "^[A-Fa-f0-9]\\{8\\}\\-[A-Fa-f0-9]\\{4\\}\\-[A-Fa-f0-9]\\{4\\}\\-[A-Fa-f0-9]\\{4\\}\\-[A-Fa-f0-9]\\{12\\}$"; if(regcomp(regex, pattern, 0)){ pam_syslog(pamh, LOG_CRIT, "ERROR: Problem with regcomp."); return 1; } return 0; } void argSplit(char **some_arg, char **some_temp, const char *arg){ strncpy(*some_arg, arg, 128); *some_temp = strtok(*some_arg, "="); *some_temp = strtok(NULL, "="); } void constrPath(char **dst, char **src){ sprintf(*dst, "/dev/disk/by-partuuid/%s", *src); } PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char *argv[]){ // Devices char *allowed_arg = malloc(128 * sizeof(char)); char *rejected_arg = malloc(128 * sizeof(char)); char *serious_arg = malloc(128 * sizeof(char)); char *allowed_temp = NULL; char *rejected_temp = NULL; char *serious_temp = NULL; char *allowed = malloc(60 * sizeof(char)); char *rejected = malloc(60 * sizeof(char)); char *serious_dev = malloc(60 * sizeof(char)); // Switches int8_t bSerious = 0; int8_t bReboot = 0; int8_t bPoweroff = 0; int8_t bPassword = 0; // Regex for checking arguments regex_t regex; if(makeRegex(pamh, ®ex)) return (PAM_IGNORE); // Argument handling for(int i=0; i