From 58ffab1dfa221123b95862496a550e1564899369 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 23 May 2016 11:29:17 -0600 Subject: [PATCH] There's no need to escape forward slashes in JSON output. While it is legal to escape a forward slash, it is not required. --- plugins/sudoers/regress/sudoers/test1.json.ok | 16 +++++++-------- .../sudoers/regress/sudoers/test14.json.ok | 8 ++++---- .../sudoers/regress/sudoers/test15.json.ok | 2 +- .../sudoers/regress/sudoers/test16.json.ok | 2 +- plugins/sudoers/regress/sudoers/test2.json.ok | 20 +++++++++---------- plugins/sudoers/visudo_json.c | 1 - 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/plugins/sudoers/regress/sudoers/test1.json.ok b/plugins/sudoers/regress/sudoers/test1.json.ok index 58875dcee..e4ecaabc8 100644 --- a/plugins/sudoers/regress/sudoers/test1.json.ok +++ b/plugins/sudoers/regress/sudoers/test1.json.ok @@ -14,7 +14,7 @@ { "log_output": true } ], "Commands": [ - { "command": "\/usr\/bin\/su -" } + { "command": "/usr/bin/su -" } ] } ] @@ -33,7 +33,7 @@ { "log_output": false } ], "Commands": [ - { "command": "\/usr\/bin\/id" } + { "command": "/usr/bin/id" } ] } ] @@ -53,7 +53,7 @@ { "setenv": true } ], "Commands": [ - { "command": "\/usr\/bin\/vi" } + { "command": "/usr/bin/vi" } ] } ] @@ -73,7 +73,7 @@ { "setenv": false } ], "Commands": [ - { "command": "\/usr\/bin\/echo" } + { "command": "/usr/bin/echo" } ] } ] @@ -91,7 +91,7 @@ { "send_mail": true } ], "Commands": [ - { "command": "\/bin\/sh" } + { "command": "/bin/sh" } ] } ] @@ -109,7 +109,7 @@ { "send_mail": false } ], "Commands": [ - { "command": "\/usr\/bin\/id" } + { "command": "/usr/bin/id" } ] } ] @@ -127,7 +127,7 @@ { "sudoedit_follow": true } ], "Commands": [ - { "command": "sudoedit \/etc\/motd" } + { "command": "sudoedit /etc/motd" } ] } ] @@ -145,7 +145,7 @@ { "sudoedit_follow": false } ], "Commands": [ - { "command": "sudoedit \/home\/*\/*" } + { "command": "sudoedit /home/*/*" } ] } ] diff --git a/plugins/sudoers/regress/sudoers/test14.json.ok b/plugins/sudoers/regress/sudoers/test14.json.ok index 3bebcafcc..2cc3f5689 100644 --- a/plugins/sudoers/regress/sudoers/test14.json.ok +++ b/plugins/sudoers/regress/sudoers/test14.json.ok @@ -2,14 +2,14 @@ "Command_Aliases": { "LS": [ { - "command": "\/bin\/ls", + "command": "/bin/ls", "sha224": "d06a2617c98d377c250edd470fd5e576327748d82915d6e33b5f8db1" } ], "SH": [ { - "command": "\/bin\/sh", - "sha256": "hOtoe\/iK6SlGg7w4BfZBBdSsXjUmTJ5+ts51yjh7vkM=" + "command": "/bin/sh", + "sha256": "hOtoe/iK6SlGg7w4BfZBBdSsXjUmTJ5+ts51yjh7vkM=" } ] }, @@ -27,7 +27,7 @@ { "cmndalias": "LS" }, { "cmndalias": "SH" }, { - "command": "\/bin\/kill", + "command": "/bin/kill", "sha512": "srzYEQ2aqzm+it3f74opTMkIImZRLxBARVpb0g9RSouJYdLt7DTRMEY4Ry9NyaOiDoUIplpNjqYH0JMYPVdFnw" } ] diff --git a/plugins/sudoers/regress/sudoers/test15.json.ok b/plugins/sudoers/regress/sudoers/test15.json.ok index da0e9e540..4f9a6fd19 100644 --- a/plugins/sudoers/regress/sudoers/test15.json.ok +++ b/plugins/sudoers/regress/sudoers/test15.json.ok @@ -10,7 +10,7 @@ "Cmnd_Specs": [ { "Commands": [ - { "command": "sudoedit \/etc\/motd" } + { "command": "sudoedit /etc/motd" } ] } ] diff --git a/plugins/sudoers/regress/sudoers/test16.json.ok b/plugins/sudoers/regress/sudoers/test16.json.ok index 2f7ecda82..9a0f18331 100644 --- a/plugins/sudoers/regress/sudoers/test16.json.ok +++ b/plugins/sudoers/regress/sudoers/test16.json.ok @@ -1,7 +1,7 @@ { "Command_Aliases": { "EDIT": [ - { "command": "sudoedit \/etc\/motd" } + { "command": "sudoedit /etc/motd" } ] }, "User_Specs": [ diff --git a/plugins/sudoers/regress/sudoers/test2.json.ok b/plugins/sudoers/regress/sudoers/test2.json.ok index 773cd7edb..0e3ceee44 100644 --- a/plugins/sudoers/regress/sudoers/test2.json.ok +++ b/plugins/sudoers/regress/sudoers/test2.json.ok @@ -78,13 +78,13 @@ { "username": "foo" } ], "UA10": [ - { "nonunixgroup": "C\/non\"UNIX\"0 c" } + { "nonunixgroup": "C/non\"UNIX\"0 c" } ], "UA11": [ - { "nonunixgroup": "C\/non_UNIX_0 c" } + { "nonunixgroup": "C/non_UNIX_0 c" } ], "UA12": [ - { "nonunixgroup": "C\/non\\'UNIX_3 c" } + { "nonunixgroup": "C/non\\'UNIX_3 c" } ], "UA2": [ { "username": "foo.bar" } @@ -105,10 +105,10 @@ { "usergroup": "baz.biz" } ], "UA8": [ - { "nonunixgroup": "C\/non UNIX 0 c" } + { "nonunixgroup": "C/non UNIX 0 c" } ], "UA9": [ - { "nonunixgroup": "C\/non\\'UNIX\\'1 c" } + { "nonunixgroup": "C/non\\'UNIX\\'1 c" } ] }, "Runas_Aliases": { @@ -275,7 +275,7 @@ }, { "User_List": [ - { "nonunixgroup": "C\/non UNIX 0 c" } + { "nonunixgroup": "C/non UNIX 0 c" } ], "Host_List": [ { "hostname": "hostc" } @@ -296,7 +296,7 @@ }, { "User_List": [ - { "nonunixgroup": "C\/non\\'UNIX\\'1 c" } + { "nonunixgroup": "C/non\\'UNIX\\'1 c" } ], "Host_List": [ { "hostname": "hostd" } @@ -317,7 +317,7 @@ }, { "User_List": [ - { "nonunixgroup": "C\/non\"UNIX\"0 c" } + { "nonunixgroup": "C/non\"UNIX\"0 c" } ], "Host_List": [ { "hostname": "hoste" } @@ -338,7 +338,7 @@ }, { "User_List": [ - { "nonunixgroup": "C\/non_UNIX_0 c" } + { "nonunixgroup": "C/non_UNIX_0 c" } ], "Host_List": [ { "hostname": "hostf" } @@ -359,7 +359,7 @@ }, { "User_List": [ - { "nonunixgroup": "C\/non\\'UNIX_3 c" } + { "nonunixgroup": "C/non\\'UNIX_3 c" } ], "Host_List": [ { "hostname": "hostg" } diff --git a/plugins/sudoers/visudo_json.c b/plugins/sudoers/visudo_json.c index 3f8118602..5e83ccf80 100644 --- a/plugins/sudoers/visudo_json.c +++ b/plugins/sudoers/visudo_json.c @@ -106,7 +106,6 @@ print_string_json_unquoted(FILE *fp, const char *str) switch (ch) { case '"': case '\\': - case '/': putc('\\', fp); break; case '\b': -- 2.40.0