Comment 28 for bug 893842

Krzysztof Klimonda (kklimonda) wrote :

I can confirm that command-not-found 0.2.46ubuntu2 on my precise system (clean install) is still broken.
The problem is this line::
self.user_can_sudo = grp.getgrnam("admin")[2] in posix.getgroups() or grp.getgrnam("sudo")[2] in posix.getgroups()
on clean systems there is no admin group, so first grp.getgrnam("admin") raises KeyError which is then catched and self.user_can_sude is set to False without checking if user is in sudo group.
As mentioned by mc3man in #24 changing the order of grp.getgrnam will fix that because sudo group is always there (and if user is not part of it, admin group will be checked)