sysctl: configure kernel parameters in the order they occur in each sysctl configurat...
authorHATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
Sat, 24 Sep 2016 12:56:07 +0000 (21:56 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 24 Sep 2016 12:56:07 +0000 (08:56 -0400)
commit886cf982d3018f7451f0548dadbc05bd2d583bb6
treef87133bd8c271c022e42e6729ba58314ccc90334
parent48a8d337a62cfa444769dfb8b1a7857fd8fb50e6
sysctl: configure kernel parameters in the order they occur in each sysctl configuration files (#4205)

Currently, systemd-sysctl command configures kernel parameters in each sysctl
configuration files in random order due to characteristics of iterator of
Hashmap.

However, kernel parameters need to be configured in the order they occur in
each sysctl configuration files.

- For example, consider fs.suid_coredump and kernel.core_pattern. If
  fs.suid_coredump=2 is configured before kernel.core_pattern= whose default
  value is "core", then kernel outputs the following message:

      Unsafe core_pattern used with suid_dumpable=2. Pipe handler or fully qualified core dump path required.

  Note that the security issue mentioned in this message has already been fixed
  on recent kernels, so this is just a warning message on such kernels. But
  it's still confusing to users that this message is output on some boot and
  not output on another boot.

- I don't know but there could be other kernel parameters that are significant
  in the order they are configured.

- The legacy sysctl command configures kernel parameters in the order they
  occur in each sysctl configuration files. Although I didn't find any official
  specification explaining this behavior of sysctl command, I don't think there
  is any meaningful reason to change this behavior, in particular, to the
  random one.

This commit does the change by simply using OrderedHashmap instead of Hashmap.
src/sysctl/sysctl.c