Use GT_RUNDIR for local sockets

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
Adrien Gallouët
2018-03-14 07:06:25 +00:00
parent 66cdcf2ee3
commit b0a589b792
5 changed files with 9 additions and 5 deletions

View File

@@ -192,7 +192,7 @@ gt_bind(int argc, char **argv)
} }
} }
int ctl_fd = ctl_create("/run/" PACKAGE_NAME, tun_name); int ctl_fd = ctl_create(GT_RUNDIR, tun_name);
if (ctl_fd == -1) { if (ctl_fd == -1) {
perror("ctl_create"); perror("ctl_create");

View File

@@ -21,6 +21,10 @@
#define PACKAGE_VERSION "0.0.0" #define PACKAGE_VERSION "0.0.0"
#endif #endif
#ifndef GT_RUNDIR
#define GT_RUNDIR "/run/" PACKAGE_NAME
#endif
#define COUNT(x) (sizeof(x)/sizeof(x[0])) #define COUNT(x) (sizeof(x)/sizeof(x[0]))
#define ALIGN_SIZE (1<<4) #define ALIGN_SIZE (1<<4)

View File

@@ -83,7 +83,7 @@ gt_path(int argc, char **argv)
if (argz(pathz, argc, argv)) if (argz(pathz, argc, argv))
return 1; return 1;
int fd = ctl_connect("/run/" PACKAGE_NAME, dev); int fd = ctl_connect(GT_RUNDIR, dev);
if (fd == -1) { if (fd == -1) {
perror("path"); perror("path");

View File

@@ -127,7 +127,7 @@ gt_set(int argc, char **argv)
if (argz(pathz, argc, argv)) if (argz(pathz, argc, argv))
return 1; return 1;
int fd = ctl_connect("/run/" PACKAGE_NAME, dev); int fd = ctl_connect(GT_RUNDIR, dev);
if (fd == -1) { if (fd == -1) {
perror("set"); perror("set");

View File

@@ -56,7 +56,7 @@ gt_show_dev_status(int fd, const char *dev)
static int static int
gt_show_dev(const char *dev) gt_show_dev(const char *dev)
{ {
int fd = ctl_connect("/run/" PACKAGE_NAME, dev); int fd = ctl_connect(GT_RUNDIR, dev);
if (fd == -1) { if (fd == -1) {
perror(dev); perror(dev);
@@ -93,7 +93,7 @@ gt_show(int argc, char **argv)
return 0; return 0;
} }
DIR *dp = opendir("/run/" PACKAGE_NAME); DIR *dp = opendir(GT_RUNDIR);
if (!dp) { if (!dp) {
if (errno == ENOENT) if (errno == ENOENT)