Bug 474 - sudo -l returns 1 when command is allowed
sudo -l returns 1 when command is allowed
Status: RESOLVED FIXED
Product: Sudo
Classification: Unclassified
Component: Sudo
1.8.0
PC Linux
: low normal
Assigned To: Todd C. Miller
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-03-03 08:23 MST by tuxce.net
Modified: 2011-04-11 08:05 MDT (History)
0 users

See Also:


Attachments
Fix for "sudo -l command" with sudoers plugin (594 bytes, patch)
2011-03-03 09:49 MST, Todd C. Miller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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