Bug 853 - malformed json created by cvtsudoers when using -e
malformed json created by cvtsudoers when using -e
Status: RESOLVED FIXED
Product: Sudo
Classification: Unclassified
Component: Sudoers
1.8.25
PC Linux
: low low
Assigned To: Todd C. Miller
: 920 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2018-09-20 14:23 MDT by Jim Westfall
Modified: 2020-04-02 11:30 MDT (History)
1 user (show)

See Also:


Attachments
Patch to fix errant commas in JSON output when expanding aliases (434 bytes, patch)
2018-09-20 14:37 MDT, Todd C. Miller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Westfall 2018-09-20 14:23:56 MDT
$ cvtsudoers -V
cvtsudoers version 1.8.25p1
cvtsudoers grammar version 46

$ cat sudoer-bad-json
Cmnd_Alias      CMDA=/path/to/cmda
Cmnd_Alias      CMDB=/path/to/cmdb
%user           ALL=CMDA,CMDB

$ cvtsudoers -e -f json sudoer-bad-json 
{
    "User_Specs": [
        {
            "User_List": [
                { "usergroup": "user" }
            ],
            "Host_List": [
                { "hostname": "ALL" }
            ],
            "Cmnd_Specs": [
                {
                    "Commands": [
                        { "command": "/path/to/cmda" },
,                        { "command": "/path/to/cmdb" }
                    ]
                }
            ]
        }
    ]
}


note the rogue common at the beginning of the 2nd command line
Comment 1 Todd C. Miller 2018-09-20 14:37:35 MDT
Created attachment 516 [details]
Patch to fix errant commas in JSON output when expanding aliases

The following patch should fix the problem.  I'm still testing to make sure there are no other side-effects.
Comment 2 Jim Westfall 2018-09-20 14:42:34 MDT
patch fixes the issue and doesn't cause any other json formatting issues on our sudoers file.
Comment 3 Todd C. Miller 2018-11-16 11:13:44 MST
Fixed in sudo 1.8.26.
Comment 4 Todd C. Miller 2020-04-02 11:30:33 MDT
*** Bug 920 has been marked as a duplicate of this bug. ***