From e48dac775cd5161f59dda43ef323df75ab5784dc Mon Sep 17 00:00:00 2001 From: angt Date: Thu, 24 Dec 2015 17:29:41 +0100 Subject: [PATCH] The statefile option needs an absolute path and a fifo --- src/main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main.c b/src/main.c index 4d5e746..0c31359 100644 --- a/src/main.c +++ b/src/main.c @@ -6,6 +6,7 @@ #include #include #include +#include #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;