Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,8 @@ plugins/sudoers/regress/cvtsudoers/test42.out.ok
plugins/sudoers/regress/cvtsudoers/test42.sh
plugins/sudoers/regress/cvtsudoers/test43.out.ok
plugins/sudoers/regress/cvtsudoers/test43.sh
plugins/sudoers/regress/cvtsudoers/test44.out.ok
plugins/sudoers/regress/cvtsudoers/test44.sh
plugins/sudoers/regress/cvtsudoers/test5.out.ok
plugins/sudoers/regress/cvtsudoers/test5.sh
plugins/sudoers/regress/cvtsudoers/test6.out.ok
Expand Down
8 changes: 4 additions & 4 deletions plugins/sudoers/cvtsudoers_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ print_options_csv(FILE *fp, struct defaults_list *options, bool need_comma)
opt->op == '+' ? "+=" : opt->op == '-' ? "-=" : "=", opt->val);
} else {
/* Boolean flag. */
fprintf(fp, "%s%s%s%s", need_comma ? "," : "", opt->var,
fprintf(fp, "%s%s%s", need_comma ? "," : "",
opt->op == false ? "!" : "", opt->var);
}
need_comma = true;
Expand Down Expand Up @@ -420,7 +420,7 @@ print_aliases_csv(FILE *fp, const struct sudoers_parse_tree *parse_tree)
{
debug_decl(print_aliases_csv, SUDOERS_DEBUG_UTIL);

if (TAILQ_EMPTY(&parse_tree->defaults))
if (no_aliases(parse_tree))
debug_return_bool(true);

/* Heading line. */
Expand Down Expand Up @@ -545,12 +545,12 @@ print_cmndspec_csv(FILE *fp, const struct sudoers_parse_tree *parse_tree,
}
if (tag.log_input != UNSPEC) {
fprintf(fp, "%s%s", need_comma ? "," : "",
tag.follow ? "log_input" : "!log_input");
tag.log_input ? "log_input" : "!log_input");
need_comma = true;
}
if (tag.log_output != UNSPEC) {
fprintf(fp, "%s%s", need_comma ? "," : "",
tag.follow ? "log_output" : "!log_output");
tag.log_output ? "log_output" : "!log_output");
need_comma = true;
}
}
Expand Down
9 changes: 9 additions & 0 deletions plugins/sudoers/regress/cvtsudoers/test44.out.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
alias_type,alias_name,members
User_Alias,ADMINS,alice

rule,user,host,runusers,rungroups,options,command
rule,ADMINS,ALL,root,,"!log_input",/bin/ls
rule,bob,ALL,root,,"!log_output",/bin/cat
rule,carol,ALL,root,,"log_input",/bin/date
rule,user,host,runusers,rungroups,options,command
rule,alice,ALL,,,"env_reset,!requiretty",/bin/ls
26 changes: 26 additions & 0 deletions plugins/sudoers/regress/cvtsudoers/test44.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
#
# Test CSV output of log tags, boolean options and aliases
# when there are no Defaults settings.
#

: ${CVTSUDOERS=cvtsudoers}

$CVTSUDOERS -c "" -f csv <<EOF
User_Alias ADMINS = alice
ADMINS ALL = (root) NOLOG_INPUT: /bin/ls
bob ALL = (root) NOLOG_OUTPUT: /bin/cat
carol ALL = (root) LOG_INPUT: /bin/date
EOF

$CVTSUDOERS -c "" -i ldif -b "ou=SUDOers,dc=sudo,dc=ws" -f csv <<EOF
dn: cn=role1,ou=SUDOers,dc=sudo,dc=ws
objectClass: sudoRole
cn: role1
sudoUser: alice
sudoHost: ALL
sudoCommand: /bin/ls
sudoOption: env_reset
sudoOption: !requiretty

EOF
Loading