The statefile option needs an absolute path and a fifo

This commit is contained in:
angt
2015-12-24 17:29:41 +01:00
parent 6282f36ac7
commit e48dac775c

View File

@@ -6,6 +6,7 @@
#include <poll.h>
#include <sys/time.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
#ifndef __FAVOR_BSD
#define __FAVOR_BSD
@@ -787,6 +788,11 @@ int main (int argc, char **argv)
retry_count = 0;
}
if (statefile && statefile[0]!='/') {
gt_log("statefile must be an absolute path\n");
return 1;
}
if (sodium_init()==-1) {
gt_log("libsodium initialization has failed!\n");
return 1;
@@ -868,6 +874,18 @@ int main (int argc, char **argv)
perror("open statefile");
return 1;
}
struct stat st = {0};
if (fstat(state_fd, &st)==-1) {
perror("stat statefile");
return 1;
}
if ((st.st_mode&S_IFMT)!=S_IFIFO) {
gt_log("`%s' is not a fifo\n", statefile);
return 1;
}
}
long retry = 0;