2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 01:49:11 +00:00

When exporting sudoers in JSON format, use the same type of Options

object for both Defaults and Cmnd_Specs.
This commit is contained in:
Todd C. Miller 2014-02-24 09:31:14 -07:00
parent c382071381
commit 58341a8bfc
2 changed files with 14 additions and 11 deletions

3
NEWS
View File

@ -43,6 +43,9 @@ What's new in Sudo 1.8.10?
directory at boot time on AIX and HP-UX systems. These systems
either lack /var/run or do not clear it on boot.
* The JSON format used by "visudo -x" now uses the same type of
Options object for both Defaults and Cmnd_Specs.
What's new in Sudo 1.8.9p5?
* Fixed a compilation error on AIX when LDAP support is enabled.

View File

@ -779,7 +779,7 @@ print_cmndspec_json(FILE *fp, struct cmndspec *cs, struct cmndspec **nextp,
if (cs->tags.nopasswd != UNSPEC || cs->tags.noexec != UNSPEC ||
cs->tags.setenv != UNSPEC || cs->tags.log_input != UNSPEC ||
cs->tags.log_output != UNSPEC) {
fprintf(fp, "%*s\"Options\": {\n", indent, "");
fprintf(fp, "%*s\"Options\": [\n", indent, "");
indent += 4;
if (cs->tags.nopasswd != UNSPEC) {
value.type = JSON_BOOL;
@ -787,39 +787,39 @@ print_cmndspec_json(FILE *fp, struct cmndspec *cs, struct cmndspec **nextp,
last_one = cs->tags.noexec == UNSPEC &&
cs->tags.setenv == UNSPEC && cs->tags.log_input == UNSPEC &&
cs->tags.log_output == UNSPEC;
print_pair_json(fp, NULL, "authenticate", &value,
last_one ? "\n" : ",\n", indent);
print_pair_json(fp, "{ ", "authenticate", &value,
last_one ? " }\n" : " },\n", indent);
}
if (cs->tags.noexec != UNSPEC) {
value.type = JSON_BOOL;
value.u.boolean = cs->tags.noexec;
last_one = cs->tags.setenv == UNSPEC &&
cs->tags.log_input == UNSPEC && cs->tags.log_output == UNSPEC;
print_pair_json(fp, NULL, "noexec", &value,
last_one ? "\n" : ",\n", indent);
print_pair_json(fp, "{ ", "noexec", &value,
last_one ? " }\n" : " },\n", indent);
}
if (cs->tags.setenv != UNSPEC) {
value.type = JSON_BOOL;
value.u.boolean = cs->tags.setenv;
last_one = cs->tags.log_input == UNSPEC &&
cs->tags.log_output == UNSPEC;
print_pair_json(fp, NULL, "setenv", &value,
last_one ? "\n" : ",\n", indent);
print_pair_json(fp, "{ ", "setenv", &value,
last_one ? " }\n" : " },\n", indent);
}
if (cs->tags.log_input != UNSPEC) {
value.type = JSON_BOOL;
value.u.boolean = cs->tags.log_input;
last_one = cs->tags.log_output == UNSPEC;
print_pair_json(fp, NULL, "log_input", &value,
last_one ? "\n" : ",\n", indent);
print_pair_json(fp, "{ ", "log_input", &value,
last_one ? " }\n" : " },\n", indent);
}
if (cs->tags.log_output != UNSPEC) {
value.type = JSON_BOOL;
value.u.boolean = cs->tags.log_output;
print_pair_json(fp, NULL, "log_output", &value, "\n", indent);
print_pair_json(fp, "{ ", "log_output", &value, " }\n", indent);
}
indent -= 4;
fprintf(fp, "%*s},\n", indent, "");
fprintf(fp, "%*s],\n", indent, "");
}
#ifdef HAVE_SELINUX