Blob Blame History Raw
From f56f8fd3bc9e94931c9f5690e6cb4f49e93e119b Mon Sep 17 00:00:00 2001
From: Dominic Cleal <dcleal@redhat.com>
Date: Wed, 9 Jul 2014 10:44:21 +0100
Subject: [PATCH] Rmt: new lens to parse /etc/default/rmt

Fixes RHBZ#1100549

(cherry picked from commit c59d33dc430a9db5be3c67b1d5730f185283f208)

Conflicts:
	NEWS
---
 doc/naturaldocs/conf/lenses/Menu.txt |  2 ++
 lenses/rmt.aug                       | 30 ++++++++++++++++++++++++++++
 lenses/shellvars.aug                 |  1 +
 lenses/tests/test_rmt.aug            | 38 ++++++++++++++++++++++++++++++++++++
 tests/Makefile.am                    |  1 +
 5 files changed, 72 insertions(+)
 create mode 100644 lenses/rmt.aug
 create mode 100644 lenses/tests/test_rmt.aug

diff --git a/doc/naturaldocs/conf/lenses/Menu.txt b/doc/naturaldocs/conf/lenses/Menu.txt
index 34e0bf6..2a9af26 100644
--- a/doc/naturaldocs/conf/lenses/Menu.txt
+++ b/doc/naturaldocs/conf/lenses/Menu.txt
@@ -141,6 +141,7 @@ Group: Specific Modules  {
    File: Redis  (redis.aug)
    File: Reprepro_Uploaders  (reprepro_uploaders.aug)
    File: Resolv  (resolv.aug)
+   File: Rmt  (rmt.aug)
    File: Rsyslog  (rsyslog.aug)
    File: Schroot  (schroot.aug)
    File: Services  (services.aug)
@@ -230,6 +231,7 @@ Group: Tests and Examples  {
    File: Test_Rabbitmq  (tests/test_rabbitmq.aug)
    File: Test_Redis  (tests/test_redis.aug)
    File: Test_Reprepro_Uploaders  (tests/test_reprepro_uploaders.aug)
+   File: Test_Rmt  (tests/test_rmt.aug)
    File: Test_Rsyslog  (tests/test_rsyslog.aug)
    File: Test_Simplelines  (tests/test_simplelines.aug)
    File: Test_Simplevars  (tests/test_simplevars.aug)
diff --git a/lenses/rmt.aug b/lenses/rmt.aug
new file mode 100644
index 0000000..36ed2d3
--- /dev/null
+++ b/lenses/rmt.aug
@@ -0,0 +1,30 @@
+(*
+Module: Rmt
+  Parses rmt's configuration file
+
+Author: Dominic Cleal <dcleal@redhat.com>
+
+About: Reference
+    This lens is based on rmt(1)
+
+About: License
+  This file is licensed under the LGPL v2+, like the rest of Augeas.
+*)
+
+module Rmt =
+  autoload xfm
+
+let sto_to_tab = store Rx.no_spaces
+
+let debug  = Build.key_value_line "DEBUG" Sep.equal ( store Rx.fspath )
+let user   = Build.key_value_line "USER" Sep.equal sto_to_tab
+let access = Build.key_value_line "ACCESS" Sep.equal
+               ( [ label "name" . sto_to_tab ] . Sep.tab .
+                 [ label "host" . sto_to_tab ] . Sep.tab .
+                 [ label "path" . sto_to_tab ] )
+
+let lns = ( debug | user | access | Util.comment | Util.empty )*
+
+let filter = incl "/etc/default/rmt"
+
+let xfm = transform lns filter
diff --git a/lenses/shellvars.aug b/lenses/shellvars.aug
index 784ce6e..815e4f1 100644
--- a/lenses/shellvars.aug
+++ b/lenses/shellvars.aug
@@ -217,6 +217,7 @@ module Shellvars =
 
   let filter_default = incl "/etc/default/*"
                      . excl "/etc/default/grub_installdevice*"
+                     . excl "/etc/default/rmt"
                      . excl "/etc/default/whoopsie"
   let filter_misc    = incl "/etc/arno-iptables-firewall/debconf.cfg"
                      . incl "/etc/cron-apt/config"
diff --git a/lenses/tests/test_rmt.aug b/lenses/tests/test_rmt.aug
new file mode 100644
index 0000000..4bb7d68
--- /dev/null
+++ b/lenses/tests/test_rmt.aug
@@ -0,0 +1,38 @@
+module Test_rmt =
+
+let conf = "#ident @(#)rmt.dfl	1.2 05/08/09 Copyr 2000 J. Schilling
+#
+# This file is /etc/default/rmt
+
+DEBUG=/tmp/RMT
+USER=*
+
+ACCESS=rtape	sparky	/dev/rmt/*
+ACCESS=*	*	/dev/rmt/*
+
+# Historically, Red Hat rmt was not so ^^ restrictive.
+ACCESS=*	*	*
+"
+
+test Rmt.lns get conf =
+  { "#comment" = "ident @(#)rmt.dfl	1.2 05/08/09 Copyr 2000 J. Schilling" }
+  { }
+  { "#comment" = "This file is /etc/default/rmt" }
+  { }
+  { "DEBUG" = "/tmp/RMT" }
+  { "USER" = "*" }
+  { }
+  { "ACCESS"
+    { "name" = "rtape" }
+    { "host" = "sparky" }
+    { "path" = "/dev/rmt/*" } }
+  { "ACCESS"
+    { "name" = "*" }
+    { "host" = "*" }
+    { "path" = "/dev/rmt/*" } }
+  { }
+  { "#comment" = "Historically, Red Hat rmt was not so ^^ restrictive." }
+  { "ACCESS"
+    { "name" = "*" }
+    { "host" = "*" }
+    { "path" = "*" } }
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1b79629..7b06472 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -151,6 +151,7 @@ lens_tests =			\
   lens-redis.sh		\
   lens-reprepro_uploaders.sh		\
   lens-resolv.sh		\
+  lens-rmt.sh			\
   lens-rsyncd.sh		\
   lens-rsyslog.sh		\
   lens-rx.sh			\