From 6ddfca24cd333ec93938b3de85c2658da19ca8c8 Mon Sep 17 00:00:00 2001
From: Michal Filka <mfilka@suse.cz>
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(-)

Index: augeas-1.2.0/lenses/sysctl.aug
===================================================================
--- augeas-1.2.0.orig/lenses/sysctl.aug
+++ augeas-1.2.0/lenses/sysctl.aug
@@ -32,8 +32,20 @@ let filter = incl "/etc/sysctl.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
Index: augeas-1.2.0/lenses/tests/test_sysctl.aug
===================================================================
--- augeas-1.2.0.orig/lenses/tests/test_sysctl.aug
+++ augeas-1.2.0/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" }
@@ -32,6 +39,13 @@ test Sysctl.lns get default_sysctl =
     { "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" ;
     rm "net.ipv4.conf.default.rp_filter" ;
@@ -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:             *)
Index: augeas-1.2.0/man/augtool.1
===================================================================
--- augeas-1.2.0.orig/man/augtool.1
+++ augeas-1.2.0/man/augtool.1
@@ -1,4 +1,4 @@
-.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16)
+.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35)
 .\"
 .\" Standard preamble:
 .\" ========================================================================
@@ -44,20 +44,23 @@
 .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.
-.ie \nF \{\
-.    de IX
-.    tm Index:\\$1\t\\n%\t"\\$2"
+.\"
+.\" Avoid warning from groff about undefined register 'F'.
+.de IX
 ..
-.    nr % 0
-.    rr F
-.\}
-.el \{\
+.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
+.    \}
 .\}
 .\"
 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
@@ -124,7 +127,7 @@
 .\" ========================================================================
 .\"
 .IX Title "AUGTOOL 1"
-.TH AUGTOOL 1 "2013-05-17" "Augeas 1.0.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
