From f5037a4a370b891e14971228c1d491184c7fe8bd Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Wed, 16 Mar 2011 02:50:25 +0000 Subject: [PATCH 1/1] Add -c option to specify keyd config file on command line Matches the parameter the onak binary takes and allows use of something other than the compiled in default config file path. --- keyd.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/keyd.c b/keyd.c index 33af8ea..05f9fe9 100644 --- a/keyd.c +++ b/keyd.c @@ -2,11 +2,12 @@ * keyd.c - key retrieval daemon * * Jonathan McDowell - * + * * Copyright 2004 Project Purple */ #include +#include #include #include #include @@ -341,8 +342,20 @@ int main(int argc, char *argv[]) int fd = -1; fd_set rfds; char sockname[1024]; + char *configfile = NULL; + int optchar; - readconfig(NULL); + while ((optchar = getopt(argc, argv, "c:")) != -1 ) { + switch (optchar) { + case 'c': + configfile = strdup(optarg); + break; + } + } + + readconfig(configfile); + free(configfile); + configfile = NULL; initlogthing("keyd", config.logfile); catchsignals(); @@ -369,6 +382,6 @@ int main(int argc, char *argv[]) cleanuplogthing(); cleanupconfig(); - + return(EXIT_SUCCESS); } -- 2.39.5