sysctl: make --prefix allow all kinds of sysctl paths

System Internals / systemd - David Herrmann [gmail.com] - 17 September 2014 02:11 UTC

Currently, we save arguments passed as --prefix directly and compare them later to absolute sysctl file-system paths. That is, you are required to specify arguments to --prefix with leading /proc/sys/. This is kinda uselesss. Furthermore, we replace dots by slashes in the name, which makes it impossible to match on specific sysfs paths that have dots in their name (like netdev names). The intention of this argument is clear, but it never worked as expected.

This patch modifies --prefix to accept any kind of sysctl paths. It supports paths prefixed with /proc/sys for compatibility (but drops the erroneous dot->slash conversion), but instead applies normalize_sysctl() which turns any name or path into a proper path. It then appends /proc/sys/ so we can properly use it in matches.

Thanks to Jan Synacek for catching this!

0e1f579 sysctl: make --prefix allow all kinds of sysctl paths
src/sysctl/sysctl.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)

Upstream: github.com


  • Share