mirror of
https://github.com/cathugger/mkp224o.git
synced 2025-12-05 21:27:13 -06:00
prevent termination during key write
This commit is contained in:
17
yaml.c
17
yaml.c
@@ -1,3 +1,6 @@
|
||||
#ifdef __linux__
|
||||
#define _POSIX_C_SOURCE 200112L
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
@@ -7,6 +10,10 @@
|
||||
#include <time.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#include "types.h"
|
||||
#include "yaml.h"
|
||||
#include "ioutil.h"
|
||||
@@ -229,6 +236,13 @@ int yamlin_parseandcreate(FILE *fin,char *sname,const char *hostname)
|
||||
break;
|
||||
}
|
||||
if (hashost && haspub && hassec) {
|
||||
#ifndef _WIN32
|
||||
sigset_t nset,oset;
|
||||
sigemptyset(&nset);
|
||||
sigaddset(&nset,SIGINT);
|
||||
sigaddset(&nset,SIGTERM);
|
||||
sigprocmask(SIG_BLOCK,&nset,&oset);
|
||||
#endif
|
||||
if (createdir(sname,1) != 0) {
|
||||
fprintf(stderr,"ERROR: could not create directory for key output\n");
|
||||
return 1;
|
||||
@@ -251,6 +265,9 @@ int yamlin_parseandcreate(FILE *fin,char *sname,const char *hostname)
|
||||
fwrite(&sname[printstartpos],printlen,1,fout);
|
||||
fflush(fout);
|
||||
}
|
||||
#ifndef _WIN32
|
||||
sigprocmask(SIG_SETMASK,&oset,0);
|
||||
#endif
|
||||
if (hostname)
|
||||
return 0; // finished
|
||||
skipthis = 1;
|
||||
|
||||
Reference in New Issue
Block a user