Blame SOURCES/0002-Rsyslog-support-multiple-actions-in-filters-and-sele.patch

b33a64
From 612010470f4217b447b5ed5fe964fce1d895566a Mon Sep 17 00:00:00 2001
b33a64
From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= <raphael.pinson@camptocamp.com>
b33a64
Date: Tue, 12 Nov 2019 13:33:26 +0100
b33a64
Subject: [PATCH] Rsyslog: support multiple actions in filters and selectors
b33a64
 (#653)
b33a64
b33a64
(cherry picked from commit 5181105bae84dc7819a00886f068ad0bb4e6d05a)
b33a64
---
b33a64
 lenses/rsyslog.aug            | 11 ++++++++---
b33a64
 lenses/tests/test_rsyslog.aug | 37 +++++++++++++++++++++++++++++++++++
b33a64
 2 files changed, 45 insertions(+), 3 deletions(-)
b33a64
b33a64
diff --git a/lenses/rsyslog.aug b/lenses/rsyslog.aug
b33a64
index 7b9f7dc9..29ff9b10 100644
b33a64
--- a/lenses/rsyslog.aug
b33a64
+++ b/lenses/rsyslog.aug
b33a64
@@ -65,11 +65,17 @@ let hostname = [ label "hostname" .
b33a64
       ( Syslog.plus | [ Build.xchgs "-" "reverse" ] ) .
b33a64
       Syslog.hostnames . Util.eol .  Syslog.entries ]
b33a64
 
b33a64
+(* View: actions *)
b33a64
+let actions =
b33a64
+     let prop_act  = [ label "action" . action ]
b33a64
+  in let act_sep = del /[ \t]*\n&[ \t]*/ "\n& "
b33a64
+  in Build.opt_list prop_act act_sep
b33a64
+
b33a64
 (* View: entry
b33a64
    An entry contains selectors and an action
b33a64
 *)
b33a64
 let entry = [ label "entry" . Syslog.selectors . Syslog.sep_tab .
b33a64
-              [ label "action" . action ] . Util.eol ]
b33a64
+              actions . Util.eol ]
b33a64
 
b33a64
 (* View: prop_filter
b33a64
    Parses property-based filters, which start with ":" and the property name *)
b33a64
@@ -78,9 +84,8 @@ let prop_filter =
b33a64
   in let prop_name = [ Util.del_str ":" . label "property" . store Rx.word ]
b33a64
   in let prop_oper = [ label "operation" . store /[A-Za-z!-]+/ ]
b33a64
   in let prop_val  = [ label "value" . Quote.do_dquote (store /[^\n"]*/) ]
b33a64
-  in let prop_act  = [ label "action" . action ]
b33a64
   in [ label "filter" . prop_name . sep . prop_oper . sep . prop_val .
b33a64
-       Sep.space . prop_act . Util.eol ]
b33a64
+       Sep.space . actions . Util.eol ]
b33a64
 
b33a64
 let entries = ( Syslog.empty | Util.comment | entry | macro | config_object | prop_filter )*
b33a64
 
b33a64
diff --git a/lenses/tests/test_rsyslog.aug b/lenses/tests/test_rsyslog.aug
b33a64
index 9011a2b3..e83613a2 100644
b33a64
--- a/lenses/tests/test_rsyslog.aug
b33a64
+++ b/lenses/tests/test_rsyslog.aug
b33a64
@@ -222,3 +222,40 @@ test Rsyslog.lns get "*.* ?DynamicFile\n" =
b33a64
       { "dynamic" = "DynamicFile" }
b33a64
     }
b33a64
   }
b33a64
+
b33a64
+(* Multiple actions in filters and selectors *)
b33a64
+test Rsyslog.lns get ":msg, startswith, \"iptables:\" -/var/log/iptables.log
b33a64
+& ~
b33a64
+# Save boot messages also to boot.log
b33a64
+local7.*                                                /var/log/boot.log
b33a64
+local3.err                                              /var/log/nfsen/nfsenlog
b33a64
+& /var/log/also.log
b33a64
+\n" =
b33a64
+  { "filter"
b33a64
+    { "property" = "msg" }
b33a64
+    { "operation" = "startswith" }
b33a64
+    { "value" = "iptables:" }
b33a64
+    { "action"
b33a64
+      { "no_sync" }
b33a64
+      { "file" = "/var/log/iptables.log" } }
b33a64
+    { "action"
b33a64
+      { "discard" } }
b33a64
+  }
b33a64
+  { "#comment" = "Save boot messages also to boot.log" }
b33a64
+  { "entry"
b33a64
+    { "selector"
b33a64
+      { "facility" = "local7" }
b33a64
+      { "level" = "*" } }
b33a64
+    { "action"
b33a64
+      { "file" = "/var/log/boot.log" } }
b33a64
+  }
b33a64
+  { "entry"
b33a64
+    { "selector"
b33a64
+      { "facility" = "local3" }
b33a64
+      { "level" = "err" } }
b33a64
+    { "action"
b33a64
+      { "file" = "/var/log/nfsen/nfsenlog" } }
b33a64
+    { "action"
b33a64
+      { "file" = "/var/log/also.log" } } }
b33a64
+  {  }
b33a64
+
b33a64
-- 
2ac116
2.29.2
b33a64