Created
November 28, 2018 13:03
-
-
Save raphink/6f268c9e65e8f7fbaf6be8790a9b7857 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
Module: Semanage | |
Parses /etc/selinux/semanage.conf | |
Author: | |
Pino Toscano <[email protected]> | |
About: License | |
This file is licenced under the LGPL v2+, like the rest of Augeas. | |
About: Lens Usage | |
To be documented | |
About: Configuration files | |
This lens applies to /etc/selinux/semanage.conf. See <filter>. | |
About: Examples | |
The <Test_Semanage> file contains various examples and tests. | |
*) | |
module Semanage = | |
autoload xfm | |
let comment = IniFile.comment "#" "#" | |
let sep = IniFile.sep "=" "=" | |
let empty = IniFile.empty | |
let eol = IniFile.eol | |
let entry_re = /[A-Za-z0-9_.-][A-Za-z0-9 _.-]*[A-Za-z0-9_.-]/ | |
let entry = IniFile.entry entry_re sep comment | |
let title = IniFile.title_label "@group" (IniFile.record_re - /^end$/) | |
let record = [ title . entry+ . Util.del_str "[end]" . eol ] | |
let lns = (entry | empty | record)* | |
(* Variable: filter *) | |
let filter = incl "/etc/selinux/semanage.conf" | |
let xfm = transform lns filter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
Module: Test_Semanage | |
Provides unit tests and examples for the <Semanage> lens. | |
*) | |
module Test_Semanage = | |
(* Variable: phony_conf *) | |
let phony_conf = "# this is a comment | |
mykey = myvalue # eol comment | |
anotherkey = another value | |
" | |
(* Test: Semanage.lns *) | |
test Semanage.lns get phony_conf = | |
{ "#comment" = "this is a comment" } | |
{ } | |
{ "mykey" = "myvalue" | |
{ "#comment" = "eol comment" } } | |
{ "anotherkey" = "another value" } | |
(* Test: Semanage.lns | |
Quotes are OK in variables that do not begin with a quote *) | |
test Semanage.lns get "UserParameter=custom.vfs.dev.read.ops[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$4}'\n" = | |
{ "UserParameter" = "custom.vfs.dev.read.ops[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$4}'" } | |
(* Test: Semanage.lns | |
Support empty values *) | |
test Semanage.lns get "foo =\n" = | |
{ "foo" } | |
(* Variable: conf *) | |
let conf = "module-store = direct | |
#policy-version = 19 | |
expand-check=0 | |
usepasswd=False | |
bzip-small=true | |
bzip-blocksize=5 | |
ignoredirs=/root | |
[sefcontext_compile] | |
path = /usr/sbin/sefcontext_compile | |
args = -r $@ | |
[end] | |
testout = valueout | |
[verify module] | |
test=value | |
[end] | |
" | |
(* Test: Semanage.lns *) | |
test Semanage.lns get conf = | |
{ "module-store" = "direct" } | |
{ } | |
{ "#comment" = "policy-version = 19" } | |
{ } | |
{ "expand-check" = "0" } | |
{ } | |
{ "usepasswd" = "False" } | |
{ "bzip-small" = "true" } | |
{ "bzip-blocksize" = "5" } | |
{ "ignoredirs" = "/root" } | |
{ } | |
{ "@group" = "sefcontext_compile" | |
{ "path" = "/usr/sbin/sefcontext_compile" } | |
{ "args" = "-r $@" } } | |
{ } | |
{ "testout" = "valueout" } | |
{ } | |
{ "@group" = "verify module" | |
{ "test" = "value" } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment