sysctl manpage does not mention that configuration files are ordered by basename while loading with --system
The manpage says the following:
--system
Load settings from all system configuration files. Files are read from directories
in the following list in given order from top to bottom. Once a file of a given filename
is loaded, any file of the same name in subsequent directories is ignored.
/etc/sysctl.d/*.conf
/run/sysctl.d/*.conf
/usr/local/lib/sysctl.d/*.conf
/usr/lib/sysctl.d/*.conf
/lib/sysctl.d/*.conf
/etc/sysctl.conf
I read this as if all files in /etc/sysctl.d
should precede the files in /usr/lib/sysctl.d
, but it turns out that this is not the case.
When system configuration files are loaded by sysctl --system
, the files are ordered by basename:
user@host:~$ sysctl --version
sysctl from procps-ng 3.3.17
user@host:~$ sysctl --system 2>/dev/null
* Applying /usr/lib/sysctl.d/10-arch.conf ...
* Applying /etc/sysctl.d/20-test.conf ...
* Applying /usr/lib/sysctl.d/50-coredump.conf ...
* Applying /usr/lib/sysctl.d/50-default.conf ...
* Applying /usr/lib/sysctl.d/50-pid-max.conf ...
* Applying /usr/lib/sysctl.d/60-libvirtd.conf ...
* Applying /etc/sysctl.d/forward.conf ...
* Applying /etc/sysctl.d/sysrq.conf ...
This agrees perfectly with the code fragment that loads the files:
https://gitlab.com/procps-ng/procps/-/blob/master/sysctl.c#L637-686
But it's not entirely clear from the documentation. Can it be reworded so it is easier to understand the loading algorithm?