Bug 920 - cvtsudoers produces invalid json when using the expand alias option (-e)
cvtsudoers produces invalid json when using the expand alias option (-e)
Status: RESOLVED DUPLICATE of bug 853
Product: Sudo
Classification: Unclassified
Component: Cvtsudoers
1.8.25
PC Linux
: low normal
Assigned To: Todd C. Miller
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-04-02 11:26 MDT by mario.garcia.ortiz
Modified: 2020-04-02 11:30 MDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mario.garcia.ortiz 2020-04-02 11:26:55 MDT
on RHEL when converting the sudoers file to a json and the option "-e" is used the produced json does not appear to be valid. 
as a result tools like python are not able to load the json file. 


Steps to reproduce: 
1. convert a sudoers file to json and use the -e option

cvtsudoers -f json -o sudoers.json vmsigmaas1_globalsu -e

2.load json file in  python

]# /usr/bin/python3
Python 3.6.8 (default, Oct 11 2019, 15:04:54)
[GCC 8.3.1 20190507 (Red Hat 8.3.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> with open('sudoers.json') as f:
...     sudoers = json.load(f)
...

actual results: 
the json fails to load only when the -e is used : 

]# /usr/bin/python3
Python 3.6.8 (default, Oct 11 2019, 15:04:54)
[GCC 8.3.1 20190507 (Red Hat 8.3.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> with open('sudoers.json') as f:
...     sudoers = json.load(f)
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/usr/lib64/python3.6/json/__init__.py", line 299, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/lib64/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 224 column 1 (char 7234)

Expected results: 
the json should be valid and be able to load like when the -e option is NOT used: 

# cvtsudoers -f json -o sudoers.json vmsigmaas1_globalsu

>>> import json
>>> with open('sudoers.json') as f:
...      sudoers = json.load(f)
...
>>> print(type(sudoers))
<class 'dict'>

Build Date & Hardware:

cvtsudoers version 1.8.25p1
cvtsudoers grammar version 46
Red Hat Enterprise Linux release 8.1 (Ootpa)
Comment 1 Todd C. Miller 2020-04-02 11:30:33 MDT

*** This bug has been marked as a duplicate of bug 853 ***