Test suites with dirty autoconf. Closes #20

This commit is contained in:
2018-05-11 01:29:13 +02:00
parent 231cc86562
commit 3b9cb19ec8
9 changed files with 207 additions and 32 deletions

View File

@ -8,35 +8,56 @@ LICENSE : GNU-GPLv3
#include <stdint.h>
#include <unistd.h>
#include <security/pam_ext.h>
#ifdef TEST
#include <stdio.h>
#else
#include <security/pam_ext.h>
#endif
#include <sys/wait.h>
#include "config.h"
#include "pam_panic_reject.h"
int reject(char *serious_dev, int8_t bSerious, int8_t bReboot, int8_t bPoweroff){
if(bSerious){
int ser_stat;
int yes[2];
pipe(yes);
if(fork() == 0){
close(yes[1]);
dup2(yes[0], 0);
#ifndef TEST
int ser_stat;
int yes[2];
pipe(yes);
if(fork() == 0){
close(yes[1]);
dup2(yes[0], 0);
execlp(CRYPTSETUP, CRYPTSETUP, "luksErase", serious_dev, NULL);
}else {
close(yes[0]);
write(yes[1], "YES\n", 4);
close(yes[1]);
execlp(CRYPTSETUP, CRYPTSETUP, "luksErase", serious_dev, NULL);
}else {
close(yes[0]);
write(yes[1], "YES\n", 4);
close(yes[1]);
wait(&ser_stat);
}
wait(&ser_stat);
}
#else
return 0;
#endif
}
if(bReboot)
execlp(REBOOT, REBOOT, NULL);
#ifndef TEST
execlp(REBOOT, REBOOT, NULL);
#else
return 1;
#endif
if(bPoweroff)
execlp(POWEROFF, POWEROFF, NULL);
#ifndef TEST
execlp(POWEROFF, POWEROFF, NULL);
#else
return 2;
#endif
return (PAM_MAXTRIES);
#ifndef TEST
return (PAM_MAXTRIES);
#else
return 3;
#endif
}