The statefile option needs an absolute path and a fifo
This commit is contained in:
18
src/main.c
18
src/main.c
@@ -6,6 +6,7 @@
|
|||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/fcntl.h>
|
#include <sys/fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#ifndef __FAVOR_BSD
|
#ifndef __FAVOR_BSD
|
||||||
#define __FAVOR_BSD
|
#define __FAVOR_BSD
|
||||||
@@ -787,6 +788,11 @@ int main (int argc, char **argv)
|
|||||||
retry_count = 0;
|
retry_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (statefile && statefile[0]!='/') {
|
||||||
|
gt_log("statefile must be an absolute path\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (sodium_init()==-1) {
|
if (sodium_init()==-1) {
|
||||||
gt_log("libsodium initialization has failed!\n");
|
gt_log("libsodium initialization has failed!\n");
|
||||||
return 1;
|
return 1;
|
||||||
@@ -868,6 +874,18 @@ int main (int argc, char **argv)
|
|||||||
perror("open statefile");
|
perror("open statefile");
|
||||||
return 1;
|
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;
|
long retry = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user