Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cvtsudoers: regression in JSON output (CHROOT != CWD) #371

Closed
es-fabricemarie opened this issue Apr 28, 2024 · 1 comment
Closed

cvtsudoers: regression in JSON output (CHROOT != CWD) #371

es-fabricemarie opened this issue Apr 28, 2024 · 1 comment

Comments

@es-fabricemarie
Copy link

Using the following sudoers file in /etc/sudoers.d/test6:

Host_Alias SERVERS10=server1,server2,server10
user1,user2,+netgroup hostname1,hostname2,SERVERS10 = CWD=~root /usr/bin/test5, CWD=/tmp /bin/test5

Using the command:

cvtsudoers --defaults=all --output-format=JSON --input-format=SUDOERS --output=- /etc/sudoers.d/test6

We get the following invalid JSON output:

{
    "Host_Aliases": {
        "SERVERS10": [
            { "hostname": "server1" },
            { "hostname": "server2" },
            { "hostname": "server10" }
        ]
    },
    "User_Specs": [
        {
            "User_List": [
                { "username": "user1" },
                { "username": "user2" },
                { "netgroup": "netgroup" }
            ],
            "Host_List": [
                { "hostname": "hostname1" },
                { "hostname": "hostname2" },
                { "hostalias": "SERVERS10" }
            ],
            "Cmnd_Specs": [
                {
                    "Options": [
                        { "runchroot": "~root" }
                    ],
                    "Commands": [
                        { "command": "/usr/bin/test5" }
                    ]
                },
                {
                    "Options": [
                        { "runchroot": "/tmp" }
                    ],
                    "Commands": [
                        { "command": "/bin/test5" }
                    ]
                }
            ]
        }
    ]
}

The options here read runchroot when in fact it should read runcwd.

For reference, this is what the stock sudo-1.9.15 release cvtsudoers returns:

{
    "Host_Aliases": {
        "SERVERS10": [
            { "hostname": "server1" },
            { "hostname": "server2" },
            { "hostname": "server10" }
        ]
    },
    "User_Specs": [
        {
            "User_List": [
                { "username": "user1" },
                { "username": "user2" },
                { "netgroup": "netgroup" }
            ],
            "Host_List": [
                { "hostname": "hostname1" },
                { "hostname": "hostname2" },
                { "hostalias": "SERVERS10" }
            ],
            "Cmnd_Specs": [
                {
                    "Options": [
                        "runcwd": "~root"
                    ],
                    "Commands": [
                        { "command": "/usr/bin/test5" }
                    ]
                },
                {
                    "Options": [
                        "runcwd": "/tmp"
                    ],
                    "Commands": [
                        { "command": "/bin/test5" }
                    ]
                }
            ]
        }
    ]
}
millert added a commit that referenced this issue Apr 28, 2024
@millert
Copy link
Collaborator

millert commented Apr 29, 2024

Fixed by e770c85

@millert millert closed this as completed Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants