miniupnpd: added DISABLE_CONFIG_FILE in options.h to disable miniupnpd.conf parsing

This commit is contained in:
Thomas Bernard 2012-06-29 21:39:34 +02:00
parent dcae1caf72
commit 0df9f7f62a
5 changed files with 35 additions and 10 deletions

View File

@ -1,4 +1,7 @@
$Id: Changelog.txt,v 1.290 2012/06/23 23:34:41 nanard Exp $ $Id: Changelog.txt,v 1.292 2012/06/29 19:26:07 nanard Exp $
2012/06/29:
added DISABLE_CONFIG_FILE in options.h to disable miniupnpd.conf parsing
2012/06/28: 2012/06/28:
Only activate -L option for PF and IPF Only activate -L option for PF and IPF

View File

@ -1,5 +1,5 @@
#! /bin/sh #! /bin/sh
# $Id: genconfig.sh,v 1.56 2012/05/31 09:32:39 nanard Exp $ # $Id: genconfig.sh,v 1.58 2012/06/29 19:29:55 nanard Exp $
# miniupnp daemon # miniupnp daemon
# http://miniupnp.free.fr or http://miniupnp.tuxfamily.org/ # http://miniupnp.free.fr or http://miniupnp.tuxfamily.org/
# (c) 2006-2012 Thomas Bernard # (c) 2006-2012 Thomas Bernard
@ -399,6 +399,10 @@ else
fi fi
echo "" >> ${CONFIGFILE} echo "" >> ${CONFIGFILE}
echo "/* disable reading and parsing of config file (miniupnpd.conf) */" >> ${CONFIGFILE}
echo "/*#define DISABLE_CONFIG_FILE*/" >> ${CONFIGFILE}
echo "" >> ${CONFIGFILE}
echo "#endif" >> ${CONFIGFILE} echo "#endif" >> ${CONFIGFILE}
exit 0 exit 0

View File

@ -1,4 +1,4 @@
/* $Id: miniupnpd.c,v 1.161 2012/05/21 15:50:03 nanard Exp $ */ /* $Id: miniupnpd.c,v 1.164 2012/06/29 19:33:37 nanard Exp $ */
/* MiniUPnP project /* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* (c) 2006-2012 Thomas Bernard * (c) 2006-2012 Thomas Bernard
@ -651,12 +651,14 @@ init(int argc, char * * argv, struct runtime_vars * v)
int i; int i;
int pid; int pid;
int debug_flag = 0; int debug_flag = 0;
int options_flag = 0;
int openlog_option; int openlog_option;
struct sigaction sa; struct sigaction sa;
/*const char * logfilename = 0;*/ /*const char * logfilename = 0;*/
const char * presurl = 0; const char * presurl = 0;
#ifndef DISABLE_CONFIG_FILE
int options_flag = 0;
const char * optionsfile = DEFAULT_CONFIG; const char * optionsfile = DEFAULT_CONFIG;
#endif /* DISABLE_CONFIG_FILE */
struct lan_addr_s * lan_addr; struct lan_addr_s * lan_addr;
struct lan_addr_s * lan_addr2; struct lan_addr_s * lan_addr2;
@ -666,6 +668,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
if(0 == strcmp(argv[i], "-h")) if(0 == strcmp(argv[i], "-h"))
goto print_usage; goto print_usage;
} }
#ifndef DISABLE_CONFIG_FILE
/* first check if "-f" option is used */ /* first check if "-f" option is used */
for(i=2; i<argc; i++) for(i=2; i<argc; i++)
{ {
@ -676,16 +679,17 @@ init(int argc, char * * argv, struct runtime_vars * v)
break; break;
} }
} }
#endif /* DISABLE_CONFIG_FILE */
/* set initial values */ /* set initial values */
SETFLAG(ENABLEUPNPMASK); SETFLAG(ENABLEUPNPMASK); /* UPnP is enabled by default */
LIST_INIT(&lan_addrs); LIST_INIT(&lan_addrs);
v->port = -1; v->port = -1;
v->notify_interval = 30; /* seconds between SSDP announces */ v->notify_interval = 30; /* seconds between SSDP announces */
v->clean_ruleset_threshold = 20; v->clean_ruleset_threshold = 20;
v->clean_ruleset_interval = 0; /* interval between ruleset check. 0=disabled */ v->clean_ruleset_interval = 0; /* interval between ruleset check. 0=disabled */
#ifndef DISABLE_CONFIG_FILE
/* read options file first since /* read options file first since
* command line arguments have final say */ * command line arguments have final say */
if(readoptionsfile(optionsfile) < 0) if(readoptionsfile(optionsfile) < 0)
@ -825,6 +829,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
} }
} }
} }
#endif /* DISABLE_CONFIG_FILE */
/* command line arguments processing */ /* command line arguments processing */
for(i=1; i<argc; i++) for(i=1; i<argc; i++)
@ -1142,7 +1147,11 @@ init(int argc, char * * argv, struct runtime_vars * v)
return 0; return 0;
print_usage: print_usage:
fprintf(stderr, "Usage:\n\t" fprintf(stderr, "Usage:\n\t"
"%s [-f config_file] [-i ext_ifname] [-o ext_ip]\n" "%s "
#ifndef DISABLE_CONFIG_FILE
"[-f config_file] "
#endif
"[-i ext_ifname] [-o ext_ip]\n"
#ifndef MULTIPLE_EXTERNAL_IP #ifndef MULTIPLE_EXTERNAL_IP
"\t\t[-a listening_ip]" "\t\t[-a listening_ip]"
#else #else
@ -1858,7 +1867,9 @@ shutdown:
#endif #endif
free(snotify); free(snotify);
closelog(); closelog();
#ifndef DISABLE_CONFIG_FILE
freeoptions(); freeoptions();
#endif
return 0; return 0;
} }

View File

@ -1,4 +1,4 @@
/* $Id: options.c,v 1.25 2012/04/30 13:38:21 nanard Exp $ */ /* $Id: options.c,v 1.26 2012/06/29 19:26:09 nanard Exp $ */
/* MiniUPnP project /* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* author: Ryan Wagoner * author: Ryan Wagoner
@ -11,10 +11,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#include <syslog.h> #include <syslog.h>
#include "config.h"
#include "options.h" #include "options.h"
#include "upnppermissions.h" #include "upnppermissions.h"
#include "upnpglobalvars.h" #include "upnpglobalvars.h"
#ifndef DISABLE_CONFIG_FILE
struct option * ary_options = NULL; struct option * ary_options = NULL;
static char * string_repo = NULL; static char * string_repo = NULL;
unsigned int num_options = 0; unsigned int num_options = 0;
@ -248,3 +250,5 @@ freeoptions(void)
} }
} }
#endif /* DISABLE_CONFIG_FILE */

View File

@ -1,4 +1,4 @@
/* $Id: options.h,v 1.20 2012/04/30 13:38:21 nanard Exp $ */ /* $Id: options.h,v 1.21 2012/06/29 19:26:09 nanard Exp $ */
/* MiniUPnP project /* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* author: Ryan Wagoner * author: Ryan Wagoner
@ -11,6 +11,7 @@
#include "config.h" #include "config.h"
#ifndef DISABLE_CONFIG_FILE
/* enum of option available in the miniupnpd.conf */ /* enum of option available in the miniupnpd.conf */
enum upnpconfigoptions { enum upnpconfigoptions {
UPNP_INVALID = 0, UPNP_INVALID = 0,
@ -71,5 +72,7 @@ struct option
extern struct option * ary_options; extern struct option * ary_options;
extern unsigned int num_options; extern unsigned int num_options;
#endif #endif /* DISABLE_CONFIG_FILE */
#endif /* __OPTIONS_H__ */