summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2015-10-15 11:36:00 +0200
committerSimon Rettberg2015-10-15 11:36:00 +0200
commit0257cf7ba624830840f9634e35ab9a507b85ef31 (patch)
treefddec3b504cc384a2d94e812d04e2aac427cf4c6
parentUpdate connection timeout properly (diff)
downloadldadp-0257cf7ba624830840f9634e35ab9a507b85ef31.tar.gz
ldadp-0257cf7ba624830840f9634e35ab9a507b85ef31.tar.xz
ldadp-0257cf7ba624830840f9634e35ab9a507b85ef31.zip
Bail out if config file is not readable
-rw-r--r--ldadp.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ldadp.c b/ldadp.c
index a47fba0..b1a5a73 100644
--- a/ldadp.c
+++ b/ldadp.c
@@ -15,7 +15,7 @@
#include <unistd.h>
static void listen_callback(void *data, int haveIn, int haveOut, int doCleanup);
-static void loadConfig(char *file);
+static BOOL loadConfig(char *file);
static int localPort = 1234;
static char *certFile = NULL, *keyFile = NULL;
@@ -34,7 +34,7 @@ int main(int argc, char **argv)
argv++;
argc--;
}
- loadConfig(argv[1]);
+ if (!loadConfig(argv[1])) bail("Cannot read config file %s", argv[1]);
if (localPort < 1 || localPort > 65535) bail("Invalid port given in config");
proxy_init();
char listen_addr[4] = {0, 0, 0, 0};
@@ -138,8 +138,8 @@ static int loadConfig_handler(void *stuff, const char *section, const char *key,
return 1;
}
-static void loadConfig(char *file)
+static BOOL loadConfig(char *file)
{
- ini_parse(file, &loadConfig_handler, NULL);
+ return ini_parse(file, &loadConfig_handler, NULL) >= 0;
}