Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 484796 - sys-apps/baselayout: consider replacing /etc/sysctl.conf with /etc/sysctl.d/99-*.conf
Summary: sys-apps/baselayout: consider replacing /etc/sysctl.conf with /etc/sysctl.d/9...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: Normal normal with 1 vote (vote)
Assignee: William Hubbs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-13 17:12 UTC by Michał Górny
Modified: 2017-02-28 15:22 UTC (History)
8 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
0001-sysctl.linux.in-use-the-system-option.patch (0001-sysctl.linux.in-use-the-system-option.patch,1.19 KB, patch)
2014-08-07 03:09 UTC, William Hubbs
Details | Diff
fix for busybox sysctl (0001-sysctl.Linux.in-fix-for-busybox-sysctl.patch,971 bytes, patch)
2015-04-28 11:07 UTC, Natanael Copa
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-09-13 17:12:19 UTC
OpenRC supports both /etc/sysctl.conf and /etc/sysctl.d/*.conf, with the latter taking precedence.

systemd supported both up to -206, with the former taking precedence. As of -207, systemd no longer supports /etc/sysctl.conf and suggests symlinking that file to /etc/sysctl.d/99-sysctl.conf.

Considering that the order is a bit inconsistent here and sysctl.d is commonly supported, how about making baselayout install sysctl.d/99-*.conf instead of /etc/sysctl.conf?
Comment 1 Doug Goldstein gentoo-dev 2013-09-14 00:00:10 UTC
Honestly, its getting a bit old that every random version of systemd is breaking backwards compat with something just for the sake of change. Why don't we have systemd create a symlink to /etc/sysctl.conf and be done with it?
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-09-14 07:45:28 UTC
Just wondering. There's still the issue that OpenRC reads /etc/sysctl.conf before sysctl.d.
Comment 3 Mike Gilbert gentoo-dev 2013-09-14 18:07:40 UTC
If any changes are to be made to /etc/init.d/sysctl, I would suggest calling sysctl --system, or emulating its behavior for backward compat.

From sysctl(8):

       --system
              Load settings from all system configuration files.
              /run/sysctl.d/*.conf
              /etc/sysctl.d/*.conf
              /usr/local/lib/sysctl.d/*.conf
              /usr/lib/sysctl.d/*.conf
              /lib/sysctl.d/*.conf
              /etc/sysctl.conf
Comment 4 Ulenrich 2013-10-17 17:33:57 UTC
> getting a bit old that every random version of systemd is breaking backwards

It is an attempt of upstream Systemd to get sanity regarding precedence. 
@Mike Gilberts excerpt of the man shows the problem lies in sequence. 

Surely you would like to have resultend sysctl values from /etc - not just distribution /usr/lib values.

And thus linking /etc/sysctl.conf into /etc/sysctl.d:
What number preceding?
Comment 5 William Hubbs gentoo-dev 2014-08-07 02:50:38 UTC
(In reply to Mike Gilbert from comment #3)
> If any changes are to be made to /etc/init.d/sysctl, I would suggest calling
> sysctl --system, or emulating its behavior for backward compat.

This I could probably do in OpenRc easily enough without affecting baselayout.

Is this the way we should go?
Comment 6 William Hubbs gentoo-dev 2014-08-07 03:09:28 UTC
Created attachment 382426 [details, diff]
0001-sysctl.linux.in-use-the-system-option.patch

This is the way I would propose fixing this issue in OpenRc.
Any thoughts?
Comment 7 Mike Gilbert gentoo-dev 2014-08-07 06:06:08 UTC
(In reply to William Hubbs from comment #6)

Seems fine to me, though I have not tested it.
Comment 8 William Hubbs gentoo-dev 2014-08-09 17:48:39 UTC
This is pushed in OpenRC in commit d29db70, which will be  included in
OpenRC-0.13.

Now, I have a question for the rest of the baselayout maintainers.

Should we move /etc/sysctl.conf to /etc/sysctl.d/00baselayout.conf in
the next baselayout release?
Comment 9 Robert Trace 2015-02-27 03:53:28 UTC
(In reply to William Hubbs from comment #8)
> This is pushed in OpenRC in commit d29db70, which will be  included in
> OpenRC-0.13.

FYI, this changed the parse order of the config files.  Previously openrc read:

/etc/sysctl.conf
/etc/sysctl.d/*.conf

By using --system, the order is inverted:

/etc/sysctl.d/*.conf
/etc/sysctl.conf

(plus whatever /run, /lib directories).

This broke my configuration since I had expected the first behavior and was using files in sysctl.d as overrides to whatever defaults were installed by portage in /etc/sysctl.conf.

Now my overrides are overridden by the defaults.
Comment 10 Joakim Tjernlund 2015-03-31 12:46:39 UTC
(In reply to Robert Trace from comment #9)
> (In reply to William Hubbs from comment #8)
> > This is pushed in OpenRC in commit d29db70, which will be  included in
> > OpenRC-0.13.
> 
> FYI, this changed the parse order of the config files.  Previously openrc
> read:
> 
> /etc/sysctl.conf
> /etc/sysctl.d/*.conf
> 
> By using --system, the order is inverted:
> 
> /etc/sysctl.d/*.conf
> /etc/sysctl.conf
> 
> (plus whatever /run, /lib directories).
> 
> This broke my configuration since I had expected the first behavior and was
> using files in sysctl.d as overrides to whatever defaults were installed by
> portage in /etc/sysctl.conf.
> 
> Now my overrides are overridden by the defaults.

Me too!

Any solution on the horizon?
Comment 11 Mike Gilbert gentoo-dev 2015-03-31 13:02:11 UTC
(In reply to William Hubbs from comment #8)
> Now, I have a question for the rest of the baselayout maintainers.
> 
> Should we move /etc/sysctl.conf to /etc/sysctl.d/00baselayout.conf in
> the next baselayout release?

I'm not a maintainer, but this seems like a reasonable course of action to me.
Comment 12 Natanael Copa 2015-04-28 11:07:07 UTC
Created attachment 402152 [details, diff]
fix for busybox sysctl

the sysctl --system option is not supported by busybox sysctl. The attached patch has a suggestion that should do same thing and make it easy to reorder the preference.
Comment 13 Jaco Kroon 2017-01-04 13:18:25 UTC
Hi all,

There may still be reason to ressurrect this.  /usr/sbin/sysctl on my system at least is owned by procps.  The init script /etc/init.d/sysctl however belongs to openrc.  I'm not using systemd.

Looking at the init script there are two variants, the BSD variant, which runs when RC_UNAME is *BSD|GNU.  The BSD variant seems confusing to say the least, so I'm going to assume it's required and sane/correct.

From the sysctl man page:

       --system
              Load settings from all system configuration files.
              /run/sysctl.d/*.conf
              /etc/sysctl.d/*.conf
              /usr/local/lib/sysctl.d/*.conf
              /usr/lib/sysctl.d/*.conf
              /lib/sysctl.d/*.conf
              /etc/sysctl.conf

I can also confirm that that's the order.

The default /etc/sysctl.conf contains some settings I'd like to override by dropping files into /etc/sysctl.d/*.conf.  /run sits on ramdisk so we should probably avoid dropping things there, and seeing that users will likely only ever drop files in /etc/sysctl.d/ (or edit /etc/sysctl.conf) the order of loading makes no sense whatsoever to me personally (I'd reverse the order exactly, first system defaults, then /*/lib/sysctl.d overrides, then /etc/sysctl.d/ ones - administrator, and lastly /run/sysctl.d/ - sits on ram disk, volatile).

Motivation should be simple:  Enable the user to avoid ever having to edit /etc/sysctl.conf - we install a large number of systems and generally prefer just dropping files into the right locations as part of a custom package rather than having to modify config files wherever possible.

Given the constraints (modifying procps might be the right thing to do, but I'm not so sure and would create inconsistency, and as per other complaints to just change things for the sake of changing it is counter-productive, I agree, especially when it's just patching upstream software for the sake of it).

As per earlier comments the problem with --system is precedence.  The proposed fix for busybox might be the way to go.  But that would change (and quite possibly break things for existing systems).  Another route to go, is to remove /etc/sysctl.conf completely and instead use ONLY files in /etc/sysctl.d/ - the problem then becomes - do we install the current sysctl.conf as 00-system-defualts.conf (logically sane) or 99-system-defaults.conf (emulating current behaviour).

I'd appreciate some additional insights into this, and discussion towards a better solution, my proposal would be:

1.  install the system default as /etc/sysctl.d/00-system-defaults.conf
2.  If during installation (pkg_pre/postinst?) if /etc/sysctl.conf exists (and not /etc/sysctl.d/99-sysctl.conf), move it to /etc/sysctl.d/99-sysctl.conf - possibly replacing it with an empty file warning to rather edit files under /etc/sysctl.d/.

Seeing that /etc/sysctl.conf belongs to sys-apps/baselayout this would require changes to baselayout.  As a side effect, if a user does insist on creating a /etc/sysctl.conf hereafter that would take precedence over the newly created structure in /etc/sysctl.d/ which is probably fair, even though in a normal context where .d folders are processed post-main counter-intuitive.