]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Ignore packaging system upgrade produced config files
authorNick Porter <nick@portercomputing.co.uk>
Wed, 30 Apr 2025 13:47:28 +0000 (14:47 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Wed, 30 Apr 2025 13:48:01 +0000 (14:48 +0100)
Both deb and rpm packaging systems will detect changed config files and
create extra files, which if we load them will create conflicts.

src/lib/server/cf_file.c

index ebda4639845d2a6caf8e935bfa3295a350f4c33e..7271ecbf541d083f687b4a94ca4406b5e6cea4f3 100644 (file)
@@ -1090,6 +1090,7 @@ static int process_include(cf_stack_t *stack, CONF_SECTION *parent, char const *
                 */
                while ((dp = readdir(dir)) != NULL) {
                        char const *p;
+                       size_t len;
 
                        if (dp->d_name[0] == '.') continue;
 
@@ -1106,6 +1107,19 @@ static int process_include(cf_stack_t *stack, CONF_SECTION *parent, char const *
                        }
                        if (*p != '\0') continue;
 
+                       /*
+                        *      Ignore config files generated by deb / rpm packaging updates.
+                        */
+                       len = strlen(dp->d_name);
+                       if ((len > 10) && (strncmp(&dp->d_name[len - 10], ".dpkg-dist", 10) == 0)) {
+                       pkg_file:
+                               WARN("Ignoring packaging system produced file %s%s", frame->directory, dp->d_name);
+                               continue;
+                       }
+                       if ((len > 9) && (strncmp(&dp->d_name[len - 9], ".dpkg-old", 9) == 0)) goto pkg_file;
+                       if ((len > 7) && (strncmp(&dp->d_name[len - 7], ".rpmnew", 9) == 0)) goto pkg_file;
+                       if ((len > 8) && (strncmp(&dp->d_name[len - 8], ".rpmsave", 10) == 0)) goto pkg_file;
+
                        snprintf(stack->buff[1], stack->bufsize, "%s%s",
                                 frame->directory, dp->d_name);