From 6ddfca24cd333ec93938b3de85c2658da19ca8c8 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Thu, 24 Mar 2022 11:18:10 +0100 Subject: [PATCH] Sysctl keys can contain some more non-alphanumeric charackters like net.ipv4.conf.*.rp_filter = 2 --- .gnulib | 2 +- lenses/sysctl.aug | 14 +++++++++++++- lenses/tests/test_sysctl.aug | 24 ++++++++++++++++++++++++ man/augtool.1 | 26 +++++++++++--------------- 4 files changed, 49 insertions(+), 17 deletions(-) --- a/lenses/sysctl.aug +++ b/lenses/sysctl.aug @@ -33,8 +33,20 @@ let filter = incl "/boot/loader.conf" (* View: comment *) let comment = Util.comment_generic /[ \t]*[#;][ \t]*/ "# " +(* View: entry + basically a Simplevars.entry but key has to allow some special chars as '*' *) +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_.-]+/ + (* Avoid ambiguity in tree by making a subtree here *) + in let empty_value = [del /[ \t]*=/ "="] . store "" + in [ Util.indent . key word + . (some_value? | empty_value) + . (Util.eol | Util.comment_eol) ] + (* View: lns The sysctl lens *) -let lns = (Util.empty | comment | Simplevars.entry)* +let lns = (Util.empty | comment | entry)* let xfm = transform lns filter diff --git a/lenses/tests/test_sysctl.aug b/lenses/tests/test_sysctl.aug index 42f31c0f..daec3dc8 100644 --- a/lenses/tests/test_sysctl.aug +++ b/lenses/tests/test_sysctl.aug @@ -18,6 +18,13 @@ kernel.sysrq = 0 net.ipv4.tcp_mem = \t393216 524288 786432 " +(* Variable: spec_chars_sysctl *) +let spec_chars_sysctl = "# Kernel sysctl configuration file +# Controls IP packet forwarding +net.ipv4.conf.*.rp_filter = 2 +net.ipv4.conf.ib0:0.arp_filter = 1 +" + (* Test: Sysctl.lns *) test Sysctl.lns get default_sysctl = { "#comment" = "Kernel sysctl configuration file" } @@ -31,6 +38,13 @@ test Sysctl.lns get default_sysctl = { "#comment" = "Semicolon comments are also allowed" } { "net.ipv4.tcp_mem" = "393216 524288 786432" } +(* Test: Sysctl.lns *) +test Sysctl.lns get spec_chars_sysctl = + { "#comment" = "Kernel sysctl configuration file" } + { "#comment" = "Controls IP packet forwarding"} + { "net.ipv4.conf.*.rp_filter" = "2" } + { "net.ipv4.conf.ib0:0.arp_filter" = "1" } + (* Test: Sysctl.lns *) test Sysctl.lns put default_sysctl after set "net.ipv4.ip_forward" "1" ; @@ -46,6 +60,16 @@ net.ipv4.ip_forward = 1 net.ipv4.tcp_mem = \t393216 524288 786432 " +(* Test: Sysctl.lns *) +test Sysctl.lns put spec_chars_sysctl after + set "net.ipv4.conf.*.rp_filter" "0" ; + set "net.ipv4.conf.ib0:0.arp_filter" "0" + = "# Kernel sysctl configuration file +# Controls IP packet forwarding +net.ipv4.conf.*.rp_filter = 0 +net.ipv4.conf.ib0:0.arp_filter = 0 +" + (* Local Variables: *) (* mode: caml *) (* End: *) diff --git a/man/augtool.1 b/man/augtool.1 index c58cbc1a..7279654c 100644 --- a/man/augtool.1 +++ b/man/augtool.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.31) +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== @@ -46,7 +46,7 @@ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" -.\" If the F register is turned on, we'll generate index entries on stderr for +.\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. @@ -54,20 +54,16 @@ .\" Avoid warning from groff about undefined register 'F'. .de IX .. -.nr rF 0 -.if \n(.g .if rF .nr rF 1 -.if (\n(rF:(\n(.g==0)) \{ -. if \nF \{ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" .. -. if !\nF==2 \{ -. nr % 0 -. nr F 2 -. \} +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 . \} .\} -.rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. @@ -133,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "AUGTOOL 1" -.TH AUGTOOL 1 "2016-08-05" "Augeas 1.5.0" "Augeas" +.TH AUGTOOL 1 "2021-05-26" "Augeas 1.13.0" "Augeas" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -275,7 +271,7 @@ Parse \s-1NODE\s0 using \s-1LENS\s0 and store the resulting tree at \s-1PATH.\s0 Add a transform for \s-1FILE\s0 using \s-1LENS.\s0 The \s-1LENS\s0 may be a module name or a full lens name. If a module name is given, then \*(L"lns\*(R" will be the lens assumed. The \s-1FILTER\s0 must be either \*(L"incl\*(R" or \*(L"excl\*(R". If the filter is -\&\*(L"incl\*(R", the \s-1FILE\s0 will be parsed by the \s-1LENS. \s0 If the filter is \*(L"excl\*(R", +\&\*(L"incl\*(R", the \s-1FILE\s0 will be parsed by the \s-1LENS.\s0 If the filter is \*(L"excl\*(R", the \s-1FILE\s0 will be excluded from the \s-1LENS. FILE\s0 may contain wildcards. .IP "\fBload-file\fR <\s-1FILE\s0>" 4 .IX Item "load-file "