Browse Source

Fixed fuckups

master
Bandie 3 years ago
parent
commit
99976bf2a6
Signed by: Bandie GPG Key ID: C1E133BC65A822DD
2 changed files with 17 additions and 24 deletions
  1. +1
    -2
      Makefile
  2. +16
    -22
      src/grub2-se-verifyserv.c

+ 1
- 2
Makefile View File

@ -21,5 +21,4 @@ uninstall:
clean:
rm bin/grub2-se-verifyserv
rmdir bin

+ 16
- 22
src/grub2-se-verifyserv.c View File

@ -59,7 +59,6 @@ int main(int argc, char *argv[]){
int verbose = 0;
int statval;
// Argument handling
for(int i=0; i<argc; i++){
if(!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")){
@ -77,7 +76,6 @@ int main(int argc, char *argv[]){
while(1){
if(fork() == 0){
// Exec program silently by default
if(!verbose){
int fd = open("/dev/null", O_WRONLY | O_CREAT, 0666);
@ -92,8 +90,8 @@ int main(int argc, char *argv[]){
else{
if(execlp(PROGRAM, PROGRAM, NULL) < 0)
exec_failed();
}
}
}
else {
@ -101,27 +99,23 @@ int main(int argc, char *argv[]){
printf("Waiting for %d...\n", getpid());
wait(&statval);
if(WIFEXITED(statval)){
if(verbose)
printf("Exit: %d\n", statval);
if(statval == STATUS_OK){
// If exit is STATUS_OK, write file with nothing in it
FILE *f = fopen(VRFFILE, "w");
if(f == NULL){
printf("ERROR opening file");
return 1;
}
fclose(f);
}
else if(statval == 256){
if(verbose)
printf("Exit: %d\n", statval);
if(statval == STATUS_OK){
// If exit is STATUS_OK, write file with nothing in it
FILE *f = fopen(VRFFILE, "w");
if(f == NULL){
printf("ERROR opening file");
return 1;
}
else
// If exit != 0
if(access(VRFFILE, F_OK) != -1) //File exists?
unlink(VRFFILE);
fclose(f);
}
else
// If exit != 0
if(access(VRFFILE, F_OK) != -1) //File exists?
unlink(VRFFILE);
}
sleep(SLEEP);


Loading…
Cancel
Save