From: Todd C. Miller Date: Mon, 19 Feb 2018 20:39:11 +0000 (-0700) Subject: Fix conversion of "ALL" in the JSON output format, which was being X-Git-Tag: SUDO_1_8_23^2~129 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3f204c5eb8b93e46c54a1bd3a2e8cb396b219db4;p=sudo Fix conversion of "ALL" in the JSON output format, which was being printed as an alias. --- diff --git a/plugins/sudoers/cvtsudoers_json.c b/plugins/sudoers/cvtsudoers_json.c index e1556f320..0460cb691 100644 --- a/plugins/sudoers/cvtsudoers_json.c +++ b/plugins/sudoers/cvtsudoers_json.c @@ -385,8 +385,14 @@ print_member_json(FILE *fp, struct member *m, enum word_type word_type, case COMMAND: print_command_json(fp, m, indent, last_one); debug_return; + case ALL: + value.u.string = "ALL"; + /* FALLTHROUGH */ case WORD: switch (word_type) { + case TYPE_COMMAND: + typestr = "command"; + break; case TYPE_HOSTNAME: typestr = "hostname"; break; @@ -412,9 +418,6 @@ print_member_json(FILE *fp, struct member *m, enum word_type word_type, sudo_fatalx("unexpected word type %d", word_type); } break; - case ALL: - value.u.string = "ALL"; - /* FALLTHROUGH */ case ALIAS: switch (word_type) { case TYPE_COMMAND: diff --git a/plugins/sudoers/regress/sudoers/test1.json.ok b/plugins/sudoers/regress/sudoers/test1.json.ok index e4ecaabc8..9523e4aaa 100644 --- a/plugins/sudoers/regress/sudoers/test1.json.ok +++ b/plugins/sudoers/regress/sudoers/test1.json.ok @@ -5,7 +5,7 @@ { "username": "user1" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -24,7 +24,7 @@ { "username": "user1" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -43,7 +43,7 @@ { "username": "user2" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -63,7 +63,7 @@ { "username": "user2" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -83,7 +83,7 @@ { "username": "user3" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -101,7 +101,7 @@ { "username": "user3" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -119,7 +119,7 @@ { "username": "user4" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -137,7 +137,7 @@ { "username": "user4" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { diff --git a/plugins/sudoers/regress/sudoers/test14.json.ok b/plugins/sudoers/regress/sudoers/test14.json.ok index 2cc3f5689..46f8b21ff 100644 --- a/plugins/sudoers/regress/sudoers/test14.json.ok +++ b/plugins/sudoers/regress/sudoers/test14.json.ok @@ -19,7 +19,7 @@ { "username": "millert" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { diff --git a/plugins/sudoers/regress/sudoers/test15.json.ok b/plugins/sudoers/regress/sudoers/test15.json.ok index 4f9a6fd19..ff1795a87 100644 --- a/plugins/sudoers/regress/sudoers/test15.json.ok +++ b/plugins/sudoers/regress/sudoers/test15.json.ok @@ -5,7 +5,7 @@ { "username": "user" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { diff --git a/plugins/sudoers/regress/sudoers/test16.json.ok b/plugins/sudoers/regress/sudoers/test16.json.ok index 9a0f18331..7c42654c6 100644 --- a/plugins/sudoers/regress/sudoers/test16.json.ok +++ b/plugins/sudoers/regress/sudoers/test16.json.ok @@ -10,7 +10,7 @@ { "username": "user" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { diff --git a/plugins/sudoers/regress/sudoers/test17.json.ok b/plugins/sudoers/regress/sudoers/test17.json.ok index bd599f0ac..2f39a37c3 100644 --- a/plugins/sudoers/regress/sudoers/test17.json.ok +++ b/plugins/sudoers/regress/sudoers/test17.json.ok @@ -12,7 +12,7 @@ { "username": "user0" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -32,7 +32,7 @@ { "username": "user1" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -50,7 +50,7 @@ { "username": "user2" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -68,7 +68,7 @@ { "username": "user3" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -86,7 +86,7 @@ { "username": "user4" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -104,7 +104,7 @@ { "username": "user5" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -122,7 +122,7 @@ { "username": "user6" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -140,7 +140,7 @@ { "username": "user7" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -158,7 +158,7 @@ { "username": "user8" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { diff --git a/plugins/sudoers/regress/sudoers/test19.json.ok b/plugins/sudoers/regress/sudoers/test19.json.ok index 1da8df4b0..c9a1bfdd3 100644 --- a/plugins/sudoers/regress/sudoers/test19.json.ok +++ b/plugins/sudoers/regress/sudoers/test19.json.ok @@ -5,7 +5,7 @@ { "username": "user0" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -25,7 +25,7 @@ { "username": "user1" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -44,7 +44,7 @@ { "username": "user2" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -62,7 +62,7 @@ { "username": "user3" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -80,7 +80,7 @@ { "username": "user4" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -98,7 +98,7 @@ { "username": "user5" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -116,7 +116,7 @@ { "username": "user6" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -134,7 +134,7 @@ { "username": "user7" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -152,7 +152,7 @@ { "username": "user8" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -170,7 +170,7 @@ { "username": "user9" } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { diff --git a/plugins/sudoers/regress/sudoers/test2.json.ok b/plugins/sudoers/regress/sudoers/test2.json.ok index 0e3ceee44..8e6656e40 100644 --- a/plugins/sudoers/regress/sudoers/test2.json.ok +++ b/plugins/sudoers/regress/sudoers/test2.json.ok @@ -142,7 +142,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ] @@ -163,7 +163,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ] @@ -184,7 +184,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ] @@ -205,7 +205,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ] @@ -226,7 +226,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ] @@ -247,7 +247,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ] @@ -268,7 +268,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ] @@ -289,7 +289,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ] @@ -310,7 +310,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ] @@ -331,7 +331,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ] @@ -352,7 +352,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ] @@ -373,7 +373,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ] @@ -394,7 +394,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ] diff --git a/plugins/sudoers/regress/sudoers/test6.json.ok b/plugins/sudoers/regress/sudoers/test6.json.ok index b965114f3..be1f80f58 100644 --- a/plugins/sudoers/regress/sudoers/test6.json.ok +++ b/plugins/sudoers/regress/sudoers/test6.json.ok @@ -39,7 +39,7 @@ { "userid": 0 } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -47,7 +47,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ] @@ -57,7 +57,7 @@ { "userid": 0 } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -71,7 +71,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ] @@ -81,7 +81,7 @@ { "userid": 0 } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -89,7 +89,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ] @@ -99,7 +99,7 @@ { "userid": 0 } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -113,7 +113,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ] @@ -123,7 +123,7 @@ { "usergid": 0 } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -131,7 +131,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ] @@ -141,7 +141,7 @@ { "usergid": 0 } ], "Host_List": [ - { "hostalias": "ALL" } + { "hostname": "ALL" } ], "Cmnd_Specs": [ { @@ -149,7 +149,7 @@ { "setenv": true } ], "Commands": [ - { "cmndalias": "ALL" } + { "command": "ALL" } ] } ]