Bug 853

Summary: malformed json created by cvtsudoers when using -e
Product: Sudo Reporter: Jim Westfall <jwestfall>
Component: SudoersAssignee: Todd C. Miller <Todd.Miller>
Status: RESOLVED FIXED    
Severity: low CC: mario.garcia.ortiz
Priority: low    
Version: 1.8.25   
Hardware: PC   
OS: Linux   
Attachments: Patch to fix errant commas in JSON output when expanding aliases

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. ***