Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 520314

Summary: sys-process/procps-3.3.9 with >=sys-apps/openrc-0.13: /etc/init.d/sysctl: sysctl --system ignores /etc/sysctl.conf
Product: Gentoo Linux Reporter: Sergey Popov <pinkbyte>
Component: [OLD] Core systemAssignee: Gentoo's Team for Core System packages <base-system>
Status: RESOLVED FIXED    
Severity: normal CC: dwfreed, james05+gentoo, openrc
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: http://bugs.debian.org/732920
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Fix for logic error in sysctl.c

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