FS#58899 - [systemd] sysctl hook doesn't load /etc/sysctl.d entries

Attached to Project: Arch Linux
Opened by Rob Hoelz (hoelzro) - Wednesday, 06 June 2018, 21:59 GMT
Last edited by Christian Hesse (eworm) - Tuesday, 12 June 2018, 20:30 GMT
Task Type General Gripe
Category Packages: Core
Status Closed
Assigned To Jan Alexander Steffens (heftig)
Dave Reisner (falconindy)
Christian Hesse (eworm)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:

There is a post-install and post-upgrade hook in the systemd package that loads sysctl.d conf files from /usr/lib; this hook does not load .conf files
from under /etc/sysctl.d, though. This means that sysctls set in systemd that are explicitly overridden by the user (eg. kernel.sysrq) are reset to systemd's
values.

I don't know if this was a deliberate choice made by the systemd package maintainer; it's just something that bit me today and I wanted to bring their attention to it. If the choice was indeed deliberate, I can always write my own alpm hook to work around this.

Additional info:
* systemd version: 238.133-1

Steps to reproduce:

* override kernel.sysrq in an /etc/sysctl.d file to a value other than 16
* reboot to make sure the settings take effect
* verify that kernel.sysrq's value reflects the overridden value under /etc/sysctl.d
* update the systemd package
* sysctl -a will show kernel.sysrq is set to 16, which is systemd's default
This task depends upon

Closed by  Christian Hesse (eworm)
Tuesday, 12 June 2018, 20:30 GMT
Reason for closing:  Fixed
Additional comments about closing:  systemd 238.133-4
Comment by Tommy Schmitt (spinka) - Friday, 08 June 2018, 21:13 GMT
You probably misconfigured something because it works for me.
Comment by Rob Hoelz (hoelzro) - Monday, 11 June 2018, 17:47 GMT
Tommy, do you have files with the same names under /usr/lib/ and under /etc? I've discovered that /etc/sysctl.d entries will override corresponding entries under /usr/lib/sysctl.d, but I'm not comfortable copying the current version of 50-default.conf into my /etc/ to tweak a single sysrq. If that's not the case with you (eg. you have non-overlapping /etc/sysctl.d entries applied via the pacman hook), I'll try and reproduce the behavior in a fresh VM to see if it is indeed something with my configuration.
Comment by Rob Hoelz (hoelzro) - Monday, 11 June 2018, 22:55 GMT
Ok, I did the following to reproduce the issue:

* Downloaded the latest Arch Linux ISO (2018.06.01)
* Installed Arch in a VM
* Ran "sysctl -a | grep sysrq" - output was "kernel.sysrq = 16"
* Created "/etc/sysctl.d/90-override.conf" with the content "kernel.sysrq = 1"
* Rebooted
* Ran "sysctl -a | grep sysrq" again - output was "kernel.sysrq = 1" this time
* Manually reinstalled systemd via "pacman -S systemd"
* Ran "sysctl -a | grep sysrq" - output was "kernel.sysrq = 16" again
Comment by Tommy Schmitt (spinka) - Tuesday, 12 June 2018, 13:52 GMT
Sorry, you are right. Re-installing systemd resets its sysctl settings back to default by pacman hook. I missed that part from your description.

I think it can be fixed by removing 'each_conf' from https://git.archlinux.org/svntogit/packages.git/tree/trunk/systemd-hook?h=packages/systemd#n33 . This way it will invoke 'systemd-sysctl' without specific file arguments thus it will honor /etc/sysctl.d/ settings.

The same problem probably occurs with tmpfiles.d and sysusers.d.
Comment by Christian Hesse (eworm) - Tuesday, 12 June 2018, 19:52 GMT
Adding heftig to assignees as he added the hooks. Your thought?

The each_conf function calls the executable with the basename of config file. So overwriting 50-default.conf with file with identical name works, overwriting values from a file with different name does not.
Running systemd-sysctl without arguments should fix this, it is run at boot anyway. (Same for the other cases, though we do not have an issue there I think.)

Loading...