Bug 474

Summary: sudo -l returns 1 when command is allowed
Product: Sudo Reporter: tuxce.net
Component: SudoAssignee: Todd C. Miller <Todd.Miller>
Status: RESOLVED FIXED    
Severity: normal    
Priority: low    
Version: 1.8.0   
Hardware: PC   
OS: Linux   
Attachments: Fix for "sudo -l command" with sudoers plugin

Description tuxce.net 2011-03-03 08:23:54 MST
The return code for "sudo -l some_cmd" is inverted, here is some tests:

$  sudo -U test -l; sudo -U test -l ls; echo $?
User test is not allowed to run sudo on myhost.
0
$  sudo -U tuxce -l; sudo -U tuxce -l ls; echo $?
Matching Defaults entries for tuxce on this host:
    env_reset

Runas and Command-specific defaults for tuxce:

User tuxce may run the following commands on this host:
    (ALL) ALL
/bin/ls
1
$ sudo -V
Sudo version 1.8.0
Sudoers policy plugin version 1.8.0
Sudoers I/O plugin version 1.8.0



I think it's because of 
http://www.sudo.ws/repos/sudo/file/1f2050745096/plugins/sudoers/sudoers.c#l538

The function display_cmnd() returns 0 on success and caller's function returns TRUE (1) or FALSE (0)
Comment 1 Todd C. Miller 2011-03-03 09:49:13 MST
Created attachment 304 [details]
Fix for "sudo -l command" with sudoers plugin

I've attached a patch that fixes this.
Comment 2 Todd C. Miller 2011-03-22 09:46:18 MDT
This is fixed in 1.8.1 which is currently in beta test, see
http://www.sudo.ws/sudo/devel.html
Comment 3 Todd C. Miller 2011-04-11 08:05:55 MDT
Fixed in sudo 1.8.1