Files
Ilia Ross 466f499e65 Fix openSUSE logrotate vendor overlay handling
This PR updates the Log File Rotation module for openSUSE Leap 16's split `/usr/etc` and `/etc` configuration model.

- Select the local main configuration when present, otherwise use the vendor configuration.

- Recursively merge vendor and local drop-ins using the same precedence as `logrotate-all`.

- Display vendor configurations while keeping `/usr/etc` read-only.

- Copy vendor files into matching `/etc` overrides before editing or deleting them.

- Preserve empty overrides so deleted vendor rotations remain disabled.

- Use the openSUSE wrapper for scheduled rotation and the effective configuration set for forced rotation.

- Keep behavior unchanged on distributions that do not enable the vendor overlay.

Includes regression coverage for selection, precedence, copy-on-write, deletion, scheduling, backups, and protection against direct vendor writes.

Closes [#2682](https://github.com/webmin/webmin/issues/2682).
2026-08-03 02:36:05 +02:00

45 lines
1.1 KiB
Perl
Executable File

#!/usr/local/bin/perl
# Delete a bunch of logrotate sections
require './logrotate-lib.pl';
&ReadParse();
# Validate inputs
&error_setup($text{'delete_err'});
@d = split(/\0/, $in{'d'});
@d || &error($text{'delete_enone'});
# Delete the sections
$parent = &get_config_parent();
$conf = $parent->{'members'};
# Copy each selected vendor file to the local override tree before changing
# it. Reload the parsed configuration after copying so all line references
# point at the writable files.
%vendor_files = map { $conf->[$_]->{'file'}, 1 }
grep { &is_vendor_config_file($conf->[$_]->{'file'}) } @d;
if (%vendor_files) {
foreach $f (keys %vendor_files) {
&ensure_local_config_override($f);
}
$parent = &get_config_parent();
$conf = $parent->{'members'};
}
foreach $d (sort { $b <=> $a } @d) {
$log = $conf->[$d];
&lock_file($log->{'file'});
&save_directive($parent, $log, undef);
push(@files, $log->{'file'});
}
&flush_file_lines();
# Write out config
foreach $f (&unique(@files)) {
&delete_if_empty($f);
&unlock_file($f);
}
&webmin_log("delete", "logs", scalar(@d));
&redirect("");