aboutsummaryrefslogtreecommitdiffstats
path: root/main/augeas/0001-new-lens-Strongswan.patch
blob: 50c9f7b4c7bfe7e2f924bf36c67e2eea7252bdff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
From f098555c34789313dfc0c8b587883c3d33b4fe03 Mon Sep 17 00:00:00 2001
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Date: Sun, 4 Feb 2018 23:35:46 +0200
Subject: [PATCH] new lens: Strongswan

---
 lenses/strongswan.aug            | 41 +++++++++++++++++++++++++
 lenses/tests/test_strongswan.aug | 65 ++++++++++++++++++++++++++++++++++++++++
 tests/Makefile.am                |  1 +
 3 files changed, 107 insertions(+)
 create mode 100644 lenses/strongswan.aug
 create mode 100644 lenses/tests/test_strongswan.aug

diff --git a/lenses/strongswan.aug b/lenses/strongswan.aug
new file mode 100644
index 00000000..69d112bd
--- /dev/null
+++ b/lenses/strongswan.aug
@@ -0,0 +1,41 @@
+(*
+Module: Strongswan
+  Lens for parsing strongSwan configuration files
+
+Authors:
+  Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
+
+About: Reference
+  strongswan.conf(5)
+
+About: License
+  This file is licensed under the LGPL v2+
+*)
+
+module Strongswan =
+
+autoload xfm
+
+let ws = del /[\n\t ]*(#[\t ]*\n[\n\t ]*)*/
+
+let rec conf =
+	   let name (sep:string) =
+	   	key (/[^\/.\{\}#\n\t ]+/ - /include/) . Util.del_ws_spc .
+		Util.del_str sep
+	in let val = store /[^\n\t ].*/ . Util.del_str "\n" . ws ""
+	in let sval = Util.del_ws_spc . val
+in (
+	[ Util.del_str "#" . label "#comment" . Util.del_opt_ws " " . val ] |
+	[ key "include" . sval ] |
+	[ name "=" . sval ] |
+	[ name "{" . ws "\n" . conf . Util.del_str "}" . ws "\n" ]
+)*
+
+let lns = ws "" . conf
+
+let xfm = transform lns (
+	incl "/etc/strongswan.d/*.conf" .
+	incl "/etc/strongswan.d/**/*.conf" .
+	incl "/etc/swanctl/conf.d/*.conf" .
+	incl "/etc/swanctl/swanctl.conf"
+)
diff --git a/lenses/tests/test_strongswan.aug b/lenses/tests/test_strongswan.aug
new file mode 100644
index 00000000..55fe9052
--- /dev/null
+++ b/lenses/tests/test_strongswan.aug
@@ -0,0 +1,65 @@
+(*
+	Some of the configuration snippets have been copied from the strongSwan
+	source tree.
+*)
+
+module Test_Strongswan =
+
+(* conf/strongswan.conf *)
+let default = "
+# strongswan.conf - strongSwan configuration file
+#
+# Refer to the strongswan.conf(5) manpage for details
+#
+# Configuration changes should be made in the included files
+
+charon {
+	load_modular = yes
+	plugins {
+		include strongswan.d/charon/*.conf
+	}
+}
+
+include strongswan.d/*.conf
+"
+
+test Strongswan.lns get default =
+  { "#comment" = "strongswan.conf - strongSwan configuration file" }
+  { "#comment" = "Refer to the strongswan.conf(5) manpage for details" }
+  { "#comment" = "Configuration changes should be made in the included files" }
+  { "charon"
+    { "load_modular" = "yes" }
+    { "plugins" { "include" = "strongswan.d/charon/*.conf" } }
+  }
+  { "include" = "strongswan.d/*.conf" }
+
+(* conf/strongswan.conf.5.head.in *)
+let man_example = "
+	a = b
+	section-one {
+		somevalue = asdf
+		subsection {
+			othervalue = xxx
+		}
+		# yei, a comment
+		yetanother = zz
+	}
+	section-two {
+		x = 12
+	}
+"
+
+test Strongswan.lns get man_example =
+  { "a" = "b" }
+  { "section-one"
+    { "somevalue" = "asdf" }
+    { "subsection" { "othervalue" = "xxx" } }
+    { "#comment" = "yei, a comment" }
+    { "yetanother" = "zz" }
+  }
+  { "section-two" { "x" = "12" } }
+
+test Strongswan.lns get "foo { bar = baz\n } quux {}\t#quuux\n" =
+  { "foo" { "bar" = "baz" } }
+  { "quux" }
+  { "#comment" = "quuux" }
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8e035e91..11827fb0 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -205,6 +205,7 @@ lens_tests =			\
   lens-sshd.sh			\
   lens-sssd.sh			\
   lens-star.sh          \
+  lens-strongswan.sh \
   lens-stunnel.sh			\
   lens-subversion.sh		\
   lens-sysconfig.sh		\
-- 
2.16.1