X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;ds=sidebyside;f=src%2Ftincctl.c;h=3af0f1f883406d7a3d925bda961630a307dfef17;hb=1aa8ac8c41ab8580fce1956086d7e6c7e84a09ee;hp=46073b3aaad7db9651c077a7dbc5734caaa47d9d;hpb=c6a15e27d934e90a1f3a26438dddb395bdc9de19;p=tinc diff --git a/src/tincctl.c b/src/tincctl.c index 46073b3a..3af0f1f8 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -44,6 +44,7 @@ #include "sandbox.h" #include "pidfile.h" #include "console.h" +#include "fs.h" #ifndef MSG_NOSIGNAL #define MSG_NOSIGNAL 0 @@ -79,7 +80,7 @@ char *scriptextension = defaultextension; static char *prompt; char *device = NULL; char *iface = NULL; -int debug_level = -1; +debug_t debug_level = -1; typedef enum option_t { OPT_BAD_OPTION = '?', @@ -494,6 +495,10 @@ bool recvline(int fd, char *line, size_t len) { } while(!(newline = memchr(buffer, '\n', blen))) { + if(!wait_socket_recv(fd)) { + return false; + } + ssize_t nrecv = recv(fd, buffer + blen, sizeof(buffer) - blen, 0); if(nrecv == -1 && sockerrno == EINTR) { @@ -2189,49 +2194,6 @@ int check_port(const char *name) { return 0; } -static bool makedir(const char *path, mode_t mode) { - if(mkdir(path, mode) && errno != EEXIST) { - fprintf(stderr, "Could not create directory %s: %s\n", path, strerror(errno)); - return false; - } - - return true; -} - -bool makedirs(tincd_dir_t dirs) { - if(dirs & DIR_CONFBASE && !makedir(confbase, 0777)) { - return false; - } - - if(dirs & DIR_CONFDIR && !confbase_given && !makedir(confdir, 0755)) { - return false; - } - - if(dirs & DIR_HOSTS && !makedir(hosts_dir, 0777)) { - return false; - } - - char path[PATH_MAX]; - - if(dirs & DIR_INVITATIONS) { - snprintf(path, sizeof(path), "%s" SLASH "invitations", confbase); - - if(!makedir(path, 0700)) { - return false; - } - } - - if(dirs & DIR_CACHE) { - snprintf(path, sizeof(path), "%s" SLASH "%s", confbase, "cache"); - - if(!makedir(path, 0755)) { - return false; - } - } - - return true; -} - static int cmd_init(int argc, char *argv[]) { if(!access(tinc_conf, F_OK)) { fprintf(stderr, "Configuration file %s already exists!\n", tinc_conf);