module

Krikri::PluginHelpers::SefcontextCommands

SefcontextCommands - command construction and semanage fcontext output parsing for community.general.sefcontext (see plugins/sefcontext.cr). Pure string plumbing mirroring the real module's seobject-backed logic (semanage_fcontext_exists / semanage_fcontext_modify / semanage_fcontext_delete), unit-testable without an SELinux policy store.

Constants

FILE_TYPE_FLAG = {"a" => nil, "b" => "b", "c" => "c", "d" => "d", "f" => "--", "l" => "l", "p" => "p", "s" => "s"}

semanage fcontext's own -f flag per ftype letter. 'a' is the default (no flag), and a regular file is spelled '--'.

FILE_TYPE_STR = {"a" => "all files", "b" => "block device", "c" => "character device", "d" => "directory", "f" => "regular file", "l" => "symbolic link", "p" => "named pipe", "s" => "socket"}

The real module's option_to_file_type_str: seobject's own record spelling for each ftype letter - the exact string semanage fcontext -l prints in its middle column.

Class methods

add_command(target : String, setype : String, ftype : String, seuser : String, serange : String) : Array(String)
Source
add_equal_command(target : String, substitute : String, modify : Bool) : Array(String)
Source
delete_command(target : String, ftype : String) : Array(String)
Source
modify_command(target : String, setype : String, ftype : String, seuser : String, serange : String) : Array(String)
Source
parse_equivalences(output : String) : Hash(String, String)

Parses semanage fcontext -C -l's equivalence lines: "target = substitute".

Source
parse_listing(output : String) : Array(Record)

Parses semanage fcontext -l output: three (or more) whitespace separated columns - target, file-type string, SELinux context - with a two-line header. The context may be "<<None>>" for the special no-context mapping; it is kept as the raw string.

Source

Nested types