mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-05 21:03:40 +00:00
nixos/logrotate: Fix the config file check phase regex for create/createolddir
The check phase for the config file has to replace any instances of user and group with the current ones, since logrotate checks whether they actually exist. However, the create/createolddir substitution expressions didn't take all different parameter formats into account. Mainly, if the mode was specified, but not user and group, the result would be something like create 0644nixbld nixbld since it relies on matching a space at the end of the mode specification. To fix this, always append a space before the substituted user and group. Also, simplify the formatting by using extended regex and check for word boundaries after create/createolddir to exclude any incorrect or unsupported suffixes.
This commit is contained in:
@@ -91,9 +91,9 @@ let
|
||||
# files required to exist also won't be present, so missingok is forced.
|
||||
user=$(${pkgs.buildPackages.coreutils}/bin/id -un)
|
||||
group=$(${pkgs.buildPackages.coreutils}/bin/id -gn)
|
||||
sed -e "s/\bsu\s.*/su $user $group/" \
|
||||
-e "s/\b\(create\s\+[0-9]*\s*\|createolddir\s\+[0-9]*\s\+\).*/\1$user $group/" \
|
||||
-e "1imissingok" -e "s/\bnomissingok\b//" \
|
||||
sed -E -e "s/\bsu\s.*/su $user $group/" \
|
||||
-e "s/\b((create|createolddir)\b(\s+[0-9]+)?).*/\1 $user $group/" \
|
||||
-e "1imissingok" -e "s/\bnomissingok\b//" \
|
||||
$out > logrotate.conf
|
||||
# Since this makes for very verbose builds only show real error.
|
||||
# There is no way to control log level, but logrotate hardcodes
|
||||
|
||||
@@ -66,8 +66,10 @@ in
|
||||
checkConf = {
|
||||
su = "root utmp";
|
||||
createolddir = "0750 root utmp";
|
||||
"createolddir " = "0750";
|
||||
create = "root utmp";
|
||||
"create " = "0750 root utmp";
|
||||
"create " = "0750";
|
||||
};
|
||||
# multiple paths should be aggregated
|
||||
multipath = {
|
||||
|
||||
Reference in New Issue
Block a user