Bugzilla – Bug 474
sudo -l returns 1 when command is allowed
Last modified: 2011-04-11 08:05:55 MDT
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)
Created attachment 304 [details] Fix for "sudo -l command" with sudoers plugin I've attached a patch that fixes this.
This is fixed in 1.8.1 which is currently in beta test, see http://www.sudo.ws/sudo/devel.html
Fixed in sudo 1.8.1