Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 520314 - sys-process/procps-3.3.9 with >=sys-apps/openrc-0.13: /etc/init.d/sysctl: sysctl --system ignores /etc/sysctl.conf
Summary: sys-process/procps-3.3.9 with >=sys-apps/openrc-0.13: /etc/init.d/sysctl: sys...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
: 520292 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-08-20 12:27 UTC by Sergey Popov
Modified: 2014-08-20 15:16 UTC (History)
3 users (show)

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


Attachments
Fix for logic error in sysctl.c (sysctl_logic_fix.diff,363 bytes, patch)
2014-08-20 13:11 UTC, Tobias Klausmann (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Popov gentoo-dev 2014-08-20 12:27:47 UTC
See $SUMMARY

man sysctl says:

       --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

But in fact it does not work as expected:

bgp ~ # sysctl --system
* Applying /etc/sysctl.d/libvirtd.conf ...
fs.aio-max-nr = 1048576

sysctl -p works, but only for /etc/sysctl.conf, /etc/sysctl.d is not obeyed

The bug is pure unstable thingie, stable is not affected, cause stable openrc use for loop in /etc/init.d/sysctl to load all options both from /etc/sysctl.conf and /etc/sysctl.d
Comment 1 dwfreed 2014-08-20 13:09:20 UTC
This was broken in cdca71e94506fbb921ab2c626be3ad05c4287498 in upstream procps, and "fixed" in 7f6efed9bb85d1e212e06985ea3e06720f6ca949.  The fix contains a logic error of its own.  Instead of:

if (stat(DEFAULT_PRELOAD, &ts) < 0 || S_ISREG(ts.st_mode)) {

It should be:

if (stat(DEFAULT_PRELOAD, &ts) == 0 && S_ISREG(ts.st_mode)) {
Comment 2 Tobias Klausmann (RETIRED) gentoo-dev 2014-08-20 13:11:32 UTC
Created attachment 383198 [details, diff]
Fix for logic error in sysctl.c
Comment 3 Tobias Klausmann (RETIRED) gentoo-dev 2014-08-20 13:11:50 UTC
Using the just-attached patch:

Before:

# strace -e trace=file sysctl --system
execve("/sbin/sysctl", ["sysctl", "--system"], [/* 44 vars */]) = 0
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/run/sysctl.d", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/sysctl.d", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/local/lib/sysctl.d", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sysctl.d", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/sysctl.d", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/etc/sysctl.conf", {st_mode=S_IFREG|0644, st_size=1595, ...}) = 0
+++ exited with 0 +++
# 

After:

# strace -e trace=file ./sysctl --system
execve("./sysctl", ["./sysctl", "--system"], [/* 45 vars */]) = 0
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
[...]
openat(AT_FDCWD, "/run/sysctl.d", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/sysctl.d", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/local/lib/sysctl.d", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sysctl.d", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/sysctl.d", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/etc/sysctl.conf", {st_mode=S_IFREG|0644, st_size=1595, ...}) = 0
* Applying /etc/sysctl.conf ...
open("/etc/sysctl.conf", O_RDONLY)      = 3
[...]

And the file is loaded.
Comment 4 Samuli Suominen (RETIRED) gentoo-dev 2014-08-20 14:39:39 UTC
(In reply to Tobias Klausmann from comment #2)
> Created attachment 383198 [details, diff] [details, diff]
> Fix for logic error in sysctl.c

in portage, as procps-3.3.9-r2
Comment 5 William Hubbs gentoo-dev 2014-08-20 15:16:18 UTC
*** Bug 520292 has been marked as a duplicate of this bug. ***