From: Alan T. DeKok Date: Wed, 18 May 2011 12:32:53 +0000 (+0200) Subject: Added deprecated flag to variables X-Git-Tag: release_3_0_0_beta0~821 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=785d718c9c5edd7565e0c54f915b5a3f6a6ce202;p=thirdparty%2Ffreeradius-server.git Added deprecated flag to variables So that people will ugprade their configuration --- diff --git a/src/include/conffile.h b/src/include/conffile.h index ee899a9205a..9baca4f8f68 100644 --- a/src/include/conffile.h +++ b/src/include/conffile.h @@ -35,6 +35,7 @@ typedef struct conf_data CONF_DATA; #define PW_TYPE_BOOLEAN 101 #define PW_TYPE_SUBSECTION 102 #define PW_TYPE_FILENAME 103 +#define PW_TYPE_DEPRECATED (1 << 10) typedef struct CONF_PARSER { const char *name; diff --git a/src/main/conffile.c b/src/main/conffile.c index 0e57ddaa116..2d827fcec9f 100644 --- a/src/main/conffile.c +++ b/src/main/conffile.c @@ -92,6 +92,7 @@ struct conf_data { void (*free)(void *); /* free user data function */ }; +extern int check_config; static int cf_data_add_internal(CONF_SECTION *cs, const char *name, void *data, void (*data_free)(void *), @@ -300,10 +301,13 @@ void cf_section_parse_free(CONF_SECTION *cs, void *base) * Free up dynamically allocated string pointers. */ for (i = 0; variables[i].name != NULL; i++) { + int type; char **p; - if ((variables[i].type != PW_TYPE_STRING_PTR) && - (variables[i].type != PW_TYPE_FILENAME)) { + type = variables[i].type & ~PW_TYPE_DEPRECATED; + + if ((type != PW_TYPE_STRING_PTR) && + (type != PW_TYPE_FILENAME)) { continue; } @@ -847,13 +851,16 @@ static const char *cf_expand_variables(const char *cf, int *lineno, int cf_item_parse(CONF_SECTION *cs, const char *name, int type, void *data, const char *dflt) { - int rcode = 0; + int deprecated, rcode = 0; char **q; const char *value; fr_ipaddr_t ipaddr; const CONF_PAIR *cp = NULL; char ipbuf[128]; + deprecated = (type & PW_TYPE_DEPRECATED); + type &= ~PW_TYPE_DEPRECATED; + if (cs) cp = cf_pair_find(cs, name); if (cp) { value = cp->value; @@ -870,6 +877,13 @@ int cf_item_parse(CONF_SECTION *cs, const char *name, return 0; } + if (deprecated) { + cf_log_err(cf_sectiontoitem(cs), "\"%s\" is deprecated. Please replace it with the up-to-date configuration", name); + if (check_config) { + return -1; + } + } + switch (type) { case PW_TYPE_BOOLEAN: /* diff --git a/src/main/mainconfig.c b/src/main/mainconfig.c index cb9bdbf57a9..d6986b2bd31 100644 --- a/src/main/mainconfig.c +++ b/src/main/mainconfig.c @@ -246,10 +246,10 @@ static const CONF_PARSER server_config[] = { * DON'T exist in radiusd.conf, then the previously parsed * values for "log { foo = bar}" will be used. */ - { "log_auth", PW_TYPE_BOOLEAN, 0, &mainconfig.log_auth, NULL }, - { "log_auth_badpass", PW_TYPE_BOOLEAN, 0, &mainconfig.log_auth_badpass, NULL }, - { "log_auth_goodpass", PW_TYPE_BOOLEAN, 0, &mainconfig.log_auth_goodpass, NULL }, - { "log_stripped_names", PW_TYPE_BOOLEAN, 0, &log_stripped_names, NULL }, + { "log_auth", PW_TYPE_BOOLEAN | PW_TYPE_DEPRECATED, 0, &mainconfig.log_auth, NULL }, + { "log_auth_badpass", PW_TYPE_BOOLEAN | PW_TYPE_DEPRECATED, 0, &mainconfig.log_auth_badpass, NULL }, + { "log_auth_goodpass", PW_TYPE_BOOLEAN | PW_TYPE_DEPRECATED, 0, &mainconfig.log_auth_goodpass, NULL }, + { "log_stripped_names", PW_TYPE_BOOLEAN | PW_TYPE_DEPRECATED, 0, &log_stripped_names, NULL }, { "security", PW_TYPE_SUBSECTION, 0, NULL, (const void *) security_config }, @@ -274,11 +274,11 @@ static const CONF_PARSER bootstrap_config[] = { * For backwards compatibility. */ #ifdef HAVE_SETUID - { "user", PW_TYPE_STRING_PTR, 0, &uid_name, NULL }, - { "group", PW_TYPE_STRING_PTR, 0, &gid_name, NULL }, + { "user", PW_TYPE_STRING_PTR | PW_TYPE_DEPRECATED, 0, &uid_name, NULL }, + { "group", PW_TYPE_STRING_PTR | PW_TYPE_DEPRECATED, 0, &gid_name, NULL }, #endif - { "chroot", PW_TYPE_STRING_PTR, 0, &chroot_dir, NULL }, - { "allow_core_dumps", PW_TYPE_BOOLEAN, 0, &allow_core_dumps, NULL }, + { "chroot", PW_TYPE_STRING_PTR | PW_TYPE_DEPRECATED, 0, &chroot_dir, NULL }, + { "allow_core_dumps", PW_TYPE_BOOLEAN | PW_TYPE_DEPRECATED, 0, &allow_core_dumps, NULL }, { NULL, -1, 0, NULL, NULL } }; @@ -913,7 +913,9 @@ int read_mainconfig(int reload) * This allows us to figure out where, relative to * radiusd.conf, the other configuration files exist. */ - cf_section_parse(cs, NULL, server_config); + if (cf_section_parse(cs, NULL, server_config) < 0) { + return -1; + } if (mainconfig.max_request_time == 0) mainconfig.max_request_time = 100; if (mainconfig.reject_delay > 5) mainconfig.reject_delay = 5; diff --git a/src/main/radconf2xml.c b/src/main/radconf2xml.c index 7e06c144ccc..6b425a0a461 100644 --- a/src/main/radconf2xml.c +++ b/src/main/radconf2xml.c @@ -51,6 +51,7 @@ int radius_xlat(UNUSED char *out, UNUSED int outlen, UNUSED const char *fmt, { return -1; } +int check_config = FALSE; static int usage(void) { diff --git a/src/main/radmin.c b/src/main/radmin.c index d67f50dc791..1c927ab25a9 100644 --- a/src/main/radmin.c +++ b/src/main/radmin.c @@ -89,6 +89,7 @@ int radius_xlat(UNUSED char *out, UNUSED int outlen, UNUSED const char *fmt, { return -1; } +int check_config = FALSE; static FILE *outputfp = NULL; static int echo = FALSE; diff --git a/src/main/radwho.c b/src/main/radwho.c index fec34c98b93..e381f23057a 100644 --- a/src/main/radwho.c +++ b/src/main/radwho.c @@ -66,6 +66,7 @@ int debug_flag = 0; const char *progname = "radwho"; const char *radlog_dir = NULL; const char *radutmp_file = NULL; +int check_config = FALSE; char *radius_dir = NULL; const char *radacct_dir = NULL;