Added deprecated flag to variables
authorAlan T. DeKok <aland@freeradius.org>
Wed, 18 May 2011 12:32:53 +0000 (14:32 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 18 May 2011 12:34:19 +0000 (14:34 +0200)
So that people will ugprade their configuration

src/include/conffile.h
src/main/conffile.c
src/main/mainconfig.c
src/main/radconf2xml.c
src/main/radmin.c
src/main/radwho.c

index ee899a9..9baca4f 100644 (file)
@@ -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;
index 0e57dda..2d827fc 100644 (file)
@@ -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:
                /*
index cb9bdbf..d6986b2 100644 (file)
@@ -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;
index 7e06c14..6b425a0 100644 (file)
@@ -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)
 {
index d67f50d..1c927ab 100644 (file)
@@ -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;
index fec34c9..e381f23 100644 (file)
@@ -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;