-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sysctl keys can contain some more non-alphanumeric characters #755
Sysctl keys can contain some more non-alphanumeric characters #755
Conversation
@raphink Note to failing tests. I currently hardly doubt that both failing tests |
Can I ask - which OS are you using? When I try to use the wildcard on Linux (Fedora, CentOS), I get:
and the values in sysctl remain unchanged. |
@georgehansper this bug concretely it is for openSUSE (TW) but the new sysctl defaults are from upstream (see https://bugzilla.suse.com/show_bug.cgi?id=1197443#c7) It seems that these new settings or format are for /usr/lib/systemd/systemd-sysctl (see https://man7.org/linux/man-pages/man5/sysctl.d.5.html) the configuration is read at boot by systemd-sysctl.service but these options are not supported by sysctl command. |
in addition to what was already stated by @teclator ... In suse the old sysctl is part of procps package which was marked as deprecated. All sysctl files should use new systemd powered syntax (e.g. wildcards) |
I'm looking over sysctl.d(5) and notice that the forward-slash character is also valid Can you please add the I can't see any mention of the colon |
should be easy enough, thanks for tip.
it is kind of implicit. You can have double colon e.g. in network interface name (e.g. for virtual interfaces; again it might be distribution specific convention as in theory kernel has almost no requirements on network interface names). See referenced issue in the description for an example. So, whatever option which can include an interface name, can contain also double colon. |
@mchf Could there be a problem with |
@mvidner That's a good point.
Since the |
it definitely is ... however it has to be somehow doable as we can expect '/' to be part of e.g. file paths which might be present across various config files. Also there might be a difference (for augeas) in having '/' in a key or in a value. so, i'll keep trying for a while ;-) |
Did you want to add the If not, we can address the |
I tried but ended with |
If I make an additional modification to diff --git a/lenses/sysctl.aug b/lenses/sysctl.aug
index 7ee0c736..f6245e37 100644
--- a/lenses/sysctl.aug
+++ b/lenses/sysctl.aug
@@ -38,7 +38,7 @@ let comment = Util.comment_generic /[ \t]*[#;][ \t]*/ "# "
let entry =
let some_value = Sep.space_equal . store Simplevars.to_comment_re
(* Rx.word extended by * and : *)
- in let word = /[*:A-Za-z0-9_.-]+/
+ in let word = /[*:\/A-Za-z0-9_.-]+/
(* Avoid ambiguity in tree by making a subtree here *)
in let empty_value = [del /[ \t]*=/ "="] . store ""
in [ Util.indent . key word And create a file
This produces the following tree in augeas
which can be used with set/get etc
Backslash quoting like this tends to be tricky within some scripting environments like bash, but not too difficult when calling the API directly from python or ruby or C. |
sorry, I did a mistake when copy pasting my regexp. So, i have
the test |
I was also getting this error from augparse initially:
But the problem was due to me failing to quote the The following changes to diff --git a/lenses/tests/test_sysctl.aug b/lenses/tests/test_sysctl.aug
index daec3dc8..0ab36177 100644
--- a/lenses/tests/test_sysctl.aug
+++ b/lenses/tests/test_sysctl.aug
@@ -9,6 +9,7 @@ module Test_sysctl =
let default_sysctl = "# Kernel sysctl configuration file
# Controls IP packet forwarding
net.ipv4.ip_forward = 0
+net/ipv4/ip_nonlocal_bind = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = \t0
@@ -30,6 +31,7 @@ test Sysctl.lns get default_sysctl =
{ "#comment" = "Kernel sysctl configuration file" }
{ "#comment" = "Controls IP packet forwarding"}
{ "net.ipv4.ip_forward" = "0" }
+ { "net/ipv4/ip_nonlocal_bind" = "0" }
{ }
{ "net.ipv4.conf.default.rp_filter" = "1" }
{ "net.ipv4.conf.default.accept_source_route" = "0" }
@@ -48,12 +50,14 @@ test Sysctl.lns get spec_chars_sysctl =
(* Test: Sysctl.lns *)
test Sysctl.lns put default_sysctl after
set "net.ipv4.ip_forward" "1" ;
+ set "net\/ipv4\/ip_nonlocal_bind" "1" ;
rm "net.ipv4.conf.default.rp_filter" ;
rm "net.ipv4.conf.default.accept_source_route" ;
rm "kernel.sysrq"
= "# Kernel sysctl configuration file
# Controls IP packet forwarding
net.ipv4.ip_forward = 1
+net/ipv4/ip_nonlocal_bind = 1
; Semicolon comments are also allowed Note the litteral |
I think, my issue is little bit different. As far as I can understand it, the problem is that modified regexp matches
It happens when I run augparse agains original test_sysctl.aug (without slashes) even modified one (with slashes). Moreover, I think that content of the test cannot have any impact on the issue as it fails in lens syntax check and the lens is not loaded at all. Because these messages follows
I don't understand why you are not experiencing this issue. So, may be there is a problem in my augparse / augeas version ? Btw note that augparse reports the regexp as |
First of all, thanks all for working on this! This has been bugging us for a long time, I am really glad there are more people helping out to solve this bug!
|
Thanks @georgehansper, that test worked.
Just a suggestion, to reduce confusion, is it possible to use something that will happen in real life scenario in the test case?
where bond0.15 is a network interface for VLAN15 on bond0. |
Just to add, it might also be better to use this PR as is and address |
like net.ipv4.conf.*.rp_filter = 2
6ddfca2
to
90732ba
Compare
I've rebased the patch on top of current master. |
That's looking great. One last thing, the 'Changes' tab says:
which is reverting .gnulib to a previous version. On your branch, can merge in the latest version from github, eg.
Check the result using:
Expected output:
If that's OK, a simple If not, the simplest way to fix the submodule in your branch is to:
Again, a Let me know if this does not work as expected. |
Simplier solution didn't work ... in fact it was what I did before rebasing the patch. So, I went longer way and hopefully everything is fine now. Thanks for step by step solution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All checks passing.
The update to man/augtool.1 is not really part of this change. It is just a side-effect of the make command.
Thanks @georgehansper for merging this! One more request - is it possible to tag a version, so that puppet-agent can bump their requirements and get this patch? There might be a few more things before we can get sysctl handling '/' keys, but we are progressing! |
Tries to address #684 by supporting
*
and:
in the key names.See Example 4 in sysctl.d man page
Lines like
net.ipv4.conf.*.rp_filter = 2
are valid in sysctl