Skip to content

Commit

Permalink
Merge pull request #1766 from jrha/indentation-sudo
Browse files Browse the repository at this point in the history
ncm-sudo: Cleanup pan templates
  • Loading branch information
jrha authored Dec 2, 2024
2 parents 4f7ffd3 + 0556319 commit 5cb9943
Show file tree
Hide file tree
Showing 22 changed files with 175 additions and 154 deletions.
10 changes: 5 additions & 5 deletions ncm-sudo/src/main/pan/components/sudo/validation.pan
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ function sudo_check_aliases_list = {
function sudo_check_default_options_list = {
if (exists(ARGV[0][ARGV[1]])) {
foreach(idx; v; ARGV[0][ARGV[1]]) {
if ((exists (v["user"]) && (exists (v["run_as"]) ||
exists (v["host"]))) ||
(exists (v["run_as"]) && exists (v["host"]))) {
error ("Only one of user, run_as or host may be " +
"specified for default options");
if (
(exists (v["user"]) && (exists (v["run_as"]) || exists (v["host"]))) ||
(exists (v["run_as"]) && exists (v["host"]))
) {
error ("Only one of user, run_as or host may be specified for default options");
};
};
};
Expand Down
12 changes: 8 additions & 4 deletions ncm-sudo/src/test/resources/1line.pan
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ object template 1line;

prefix "/software/components/sudo";

"privilege_lines/0" = dict("user", "u",
"privilege_lines/0" = dict(
"user", "u",
"run_as", "r",
"host", "h",
"cmd", "c",
"options", "opts");
"options", "opts",
);

"privilege_lines/1" = dict("user", "u",
"privilege_lines/1" = dict(
"user", "u",
"run_as", "r",
"host", "h",
"cmd", "c");
"cmd", "c",
);
6 changes: 3 additions & 3 deletions ncm-sudo/src/test/resources/all_aliases.pan
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ object template all_aliases;

prefix "/software/components/sudo";

"user_aliases" = dict (
"USER", list ("u")
);
"user_aliases" = dict(
"USER", list("u"),
);
"cmd_aliases" = dict("CMD", list("c"));
"run_as_aliases" = dict("RUN", list("r"));
"host_aliases" = dict("HOST", list("h", "h2"));
6 changes: 4 additions & 2 deletions ncm-sudo/src/test/resources/new_opts.pan
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ object template new_opts;

prefix "/software/components/sudo";

"privilege_lines/0" = dict("user", "u",
"privilege_lines/0" = dict(
"user", "u",
"run_as", "r",
"host", "h",
"cmd", "c",
"options", "NOPASSWD:EXEC:");
"options", "NOPASSWD:EXEC:",
);
11 changes: 6 additions & 5 deletions ncm-sudo/src/test/resources/test0aliases.pan
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
# No aliases defined, just one silly command.
object template test0aliases;

"/software/components/sudo/privilege_lines" = list (
dict ( "user", "ALL",
"/software/components/sudo/privilege_lines" = list(
dict(
"user", "ALL",
"run_as", "ALL",
"host", "ALL",
"cmd", "ALL"
)
);
"cmd", "ALL",
),
);
"/software/components/sudo/active" = true;
"/software/components/sudo/dispatch" = true;
15 changes: 8 additions & 7 deletions ncm-sudo/src/test/resources/test1aliases.pan
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
object template test1aliases;


"/software/components/sudo/privilege_lines" = list (
dict ( "user", "ALL",
"/software/components/sudo/privilege_lines" = list(
dict(
"user", "ALL",
"run_as", "ALL",
"host", "ALL",
"cmd", "ALL"
)
);
),
);

"/software/components/sudo/user_aliases" = dict (
"FOO", list ("bar")
);
"/software/components/sudo/user_aliases" = dict(
"FOO", list("bar"),
);
"/software/components/sudo/active" = true;
"/software/components/sudo/dispatch" = true;
17 changes: 9 additions & 8 deletions ncm-sudo/src/test/resources/test1aliases_cmd.pan
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
object template test1aliases_cmd;


"/software/components/sudo/privilege_lines" = list (
dict ( "user", "ALL",
"/software/components/sudo/privilege_lines" = list(
dict(
"user", "ALL",
"run_as", "ALL",
"host", "ALL",
"cmd", "ALL"
)
);
"cmd", "ALL",
),
);

"/software/components/sudo/cmd_aliases" = dict (
"FOO", list ("bar")
);
"/software/components/sudo/cmd_aliases" = dict(
"FOO", list("bar"),
);
"/software/components/sudo/active" = true;
"/software/components/sudo/dispatch" = true;
17 changes: 9 additions & 8 deletions ncm-sudo/src/test/resources/test1aliases_cmderr.pan
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
object template test1aliases_cmderr;


"/software/components/sudo/privilege_lines" = list (
dict ( "user", "ALL",
"/software/components/sudo/privilege_lines" = list(
dict(
"user", "ALL",
"run_as", "ALL",
"host", "ALL",
"cmd", "ALL"
)
);
"cmd", "ALL",
),
);

"/software/components/sudo/cmd_aliases" = dict (
"foo", list ("bar")
);
"/software/components/sudo/cmd_aliases" = dict(
"foo", list("bar"),
);
"/software/components/sudo/active" = true;
"/software/components/sudo/dispatch" = true;
15 changes: 8 additions & 7 deletions ncm-sudo/src/test/resources/test1aliases_runas.pan
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
object template test1aliases_runas;


"/software/components/sudo/privilege_lines" = list (
dict ( "user", "ALL",
"/software/components/sudo/privilege_lines" = list(
dict(
"user", "ALL",
"run_as", "ALL",
"host", "ALL",
"cmd", "ALL"
)
);
),
);

"/software/components/sudo/run_as_aliases" = dict (
"FOO", list ("bar")
);
"/software/components/sudo/run_as_aliases" = dict(
"FOO", list("bar"),
);
"/software/components/sudo/active" = true;
"/software/components/sudo/dispatch" = true;
15 changes: 8 additions & 7 deletions ncm-sudo/src/test/resources/test1aliases_runaserr.pan
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ include pro_declaration_types;
include pro_declaration_component_sudo;
include pro_declaration_functions_sudo;

"/software/components/sudo/privilege_lines" = list (
dict ( "user", "ALL",
"/software/components/sudo/privilege_lines" = list(
dict(
"user", "ALL",
"run_as", "ALL",
"host", "ALL",
"cmd", "ALL"
)
);
),
);

"/software/components/sudo/run_as_aliases" = dict (
"foo", list ("bar")
);
"/software/components/sudo/run_as_aliases" = dict(
"foo", list("bar")
);
"/software/components/sudo/active" = true;
"/software/components/sudo/dispatch" = true;
17 changes: 9 additions & 8 deletions ncm-sudo/src/test/resources/test1aliaseserr.pan
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ include pro_declaration_types;
include pro_declaration_component_sudo;
include pro_declaration_functions_sudo;

"/software/components/sudo/privilege_lines" = list (
dict ( "user", "ALL",
"/software/components/sudo/privilege_lines" = list(
dict(
"user", "ALL",
"run_as", "ALL",
"host", "ALL",
"cmd", "ALL"
)
);
"cmd", "ALL",
),
);

"/software/components/sudo/user_aliases" = dict (
"foo", list ("bar")
);
"/software/components/sudo/user_aliases" = dict(
"foo", list("bar"),
);
"/software/components/sudo/active" = true;
"/software/components/sudo/dispatch" = true;
15 changes: 8 additions & 7 deletions ncm-sudo/src/test/resources/test1option.pan
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ include pro_declaration_types;
include pro_declaration_component_sudo;
include pro_declaration_functions_sudo;

"/software/components/sudo/privilege_lines" = list (
dict ( "user", "mejias",
"/software/components/sudo/privilege_lines" = list(
dict(
"user", "mejias",
"run_as", "munoz",
"host", "localhost",
"cmd", "/bin/ls",
"options", "NOPASSWD"
)
);
),
);

"/software/components/sudo/user_aliases" = dict (
"FOO", list ("bar")
);
"/software/components/sudo/user_aliases" = dict(
"FOO", list("bar"),
);
"/software/components/sudo/active" = true;
"/software/components/sudo/dispatch" = true;
17 changes: 9 additions & 8 deletions ncm-sudo/src/test/resources/test2options.pan
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ include pro_declaration_types;
include pro_declaration_component_sudo;
include pro_declaration_functions_sudo;

"/software/components/sudo/privilege_lines" = list (
dict ( "user", "mejias",
"/software/components/sudo/privilege_lines" = list(
dict(
"user", "mejias",
"run_as", "munoz",
"host", "localhost",
"cmd", "/bin/ls",
"options", "PASSWD"
)
);
"options", "PASSWD",
),
);

"/software/components/sudo/user_aliases" = dict (
"FOO", list ("bar")
);
"/software/components/sudo/user_aliases" = dict(
"FOO", list("bar"),
);
"/software/components/sudo/active" = true;
"/software/components/sudo/dispatch" = true;
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ include pro_declaration_functions_sudo;
"/software/components/sudo/active" = true;
"/software/components/sudo/dispatch" = true;

"/software/components/sudo/general_options/" = list(
"/software/components/sudo/general_options" = list(
dict(
"user", "mejias",
"options", dict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ include pro_declaration_functions_sudo;
"/software/components/sudo/active" = true;
"/software/components/sudo/dispatch" = true;

"/software/components/sudo/general_options/" = list(
"/software/components/sudo/general_options" = list(
dict(
"user", "mejias",
"options", dict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ include pro_declaration_functions_sudo;
"/software/components/sudo/active" = true;
"/software/components/sudo/dispatch" = true;

"/software/components/sudo/general_options/" = list(
"/software/components/sudo/general_options" = list(
dict(
"user", "mejias",
"options", dict(
Expand Down
27 changes: 14 additions & 13 deletions ncm-sudo/src/test/resources/test_general_options_errru.pan
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,26 @@ include pro_declaration_types;
include pro_declaration_component_sudo;
include pro_declaration_functions_sudo;

"/software/components/sudo/privilege_lines" = list (
dict ( "user", "mejias",
"/software/components/sudo/privilege_lines" = list(
dict(
"user", "mejias",
"run_as", "munoz",
"host", "localhost",
"cmd", "/bin/ls",
"options", "NOPASSWD"
)
);
"options", "NOPASSWD",
),
);

"/software/components/sudo/user_aliases" = dict (
"FOO", list ("bar")
);
"/software/components/sudo/user_aliases" = dict(
"FOO", list("bar"),
);
"/software/components/sudo/active" = true;
"/software/components/sudo/dispatch" = true;

"/software/components/sudo/general_options/" = list (
dict (
"/software/components/sudo/general_options" = list(
dict(
"user", "munoz",
"host", "192.168.0.1",
"options", dict ("insults", true)
)
);
"options", dict("insults", true),
),
);
27 changes: 14 additions & 13 deletions ncm-sudo/src/test/resources/test_general_options_valid.pan
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@ include pro_declaration_types;
include pro_declaration_component_sudo;
include pro_declaration_functions_sudo;

"/software/components/sudo/privilege_lines" = list (
dict ( "user", "mejias",
"/software/components/sudo/privilege_lines" = list(
dict(
"user", "mejias",
"run_as", "munoz",
"host", "localhost",
"cmd", "/bin/ls",
"options", "NOPASSWD"
)
);
"options", "NOPASSWD",
),
);

"/software/components/sudo/user_aliases" = dict (
"FOO", list ("bar")
);
"/software/components/sudo/user_aliases" = dict(
"FOO", list("bar"),
);
"/software/components/sudo/active" = true;
"/software/components/sudo/dispatch" = true;

"/software/components/sudo/general_options/" = list (
dict (
"options", dict ("insults", true)
)
);
"/software/components/sudo/general_options" = list(
dict(
"options", dict("insults", true),
),
);
Loading

0 comments on commit 5cb9943

Please sign in to comment.