]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
complain about v3 processing sections being used in v4
authorAlan T. DeKok <aland@freeradius.org>
Tue, 21 Jan 2025 19:23:25 +0000 (14:23 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 21 Jan 2025 20:56:09 +0000 (15:56 -0500)
src/lib/server/virtual_servers.c

index b0c846459ca03d29d3812adb8c234af8413b7390..2b90d45d761d24d8b77a4e53e13855f2b24cf295 100644 (file)
@@ -981,6 +981,41 @@ int virtual_server_compile_sections(virtual_server_t const *vs, tmpl_rules_t con
 
        found = 0;
 
+       /*
+        *      Complain about v3 things being used in v4.
+        *
+        *      Don't complain when running in normal mode, because the server will just ignore the new
+        *      sections.  But the check_config stuff is generally run before the service starts, and we
+        *      definitely want to tell people when running in debug mode.
+        */
+       if (check_config || DEBUG_ENABLED) {
+               bool fail = false;
+
+               while ((subcs = cf_section_next(server, subcs)) != NULL) {
+                       char const *name;
+
+                       if (cf_section_name2(subcs) != NULL) continue;
+
+                       name = cf_section_name1(subcs);
+                       if ((strcmp(name, "authorize") == 0) ||
+                           (strcmp(name, "authenticate") == 0) ||
+                           (strcmp(name, "post-auth") == 0) ||
+                           (strcmp(name, "preacct") == 0) ||
+                           (strcmp(name, "accounting") == 0) ||
+                           (strcmp(name, "pre-proxy") == 0) ||
+                           (strcmp(name, "post-proxy") == 0)) {
+                               cf_log_err(subcs, "Version 3 processing section '%s' is not valid in version 4.",
+                                          name);
+                               fail = true;
+                       }
+               }
+
+               /*
+                *      Complain about _all_ of the sections, and not just the first one.
+                */
+               if (fail) return -1;
+       }
+
        /*
         *      The sections are in trees, so this isn't as bad as it
         *      looks.  It's not O(n^2), but O(n logn).  But it could