通过ldap对sudoers进行故障排除

好消息是,我通过在Red Hat Directory Server上工作的ldap获得了sudoers 。 这个软件包是sudo-1.7.2p1。 我在LDAP组中有一些名为wheel的LDAP / Kerberos用户,并且在LDAP中有这个条目:

# %wheel, SUDOers, example.com dn: cn=%wheel,ou=SUDOers,dc=example,dc=com cn: %wheel description: Members of group wheel have access to all privileges. objectClass: sudoRole objectClass: top sudoCommand: ALL sudoHost: ALL sudoUser: %wheel 

所以,团轮成员通过sudo具有pipe理权限。 这已经过testing,工作正常。 现在,我已经设置了这个sudo权限,允许一个名为Administrators的组成员执行两个命令,作为这些命令的非root用户。

 # %Administrators, SUDOers, example.com dn: cn=%Administrators,ou=SUDOers,dc=example,dc=com sudoRunAsGroup: appGroup sudoRunAsUser: appOwner cn: %Administrators description: Allow members of the group Administrators to run various commands . objectClass: sudoRole objectClass: top sudoCommand: appStop sudoCommand: appStart sudoCommand: /path/to/appStop sudoCommand: /path/to/appStart sudoUser: %Administrators 

不幸的是,pipe理员的成员仍然被拒绝运行appStart或appStop的权限:

 -bash-3.2$ sudo /path/to/appStop [sudo] password for Aaron: Sorry, user Aaron is not allowed to execute '/path/to/appStop' as root on host.example.com. -bash-3.2$ sudo -u appOwner /path/to/appStop [sudo] password for Aaron: Sorry, user Aaron is not allowed to execute '/path/to/appStop' as appOwner on host.example.com. 

/var/log/secure显示了这两组消息的两次尝试:

 Oct 31 15:02:36 host sudo: pam_unix(sudo:auth): authentication failure; logname=Aaron uid=0 euid=0 tty=/dev/pts/3 ruser= rhost= user=Aaron Oct 31 15:02:37 host sudo: pam_krb5[1508]: TGT verified using key for 'host/[email protected]' Oct 31 15:02:37 host sudo: pam_krb5[1508]: authentication succeeds for 'Aaron' ([email protected]) Oct 31 15:02:37 host sudo: Aaron : command not allowed ; TTY=pts/3 ; PWD=/auto/home/Aaron ; USER=root ; COMMAND=/path/to/appStop Oct 31 15:02:52 host sudo: pam_unix(sudo:auth): authentication failure; logname=Aaron uid=0 euid=0 tty=/dev/pts/3 ruser= rhost= user=Aaron Oct 31 15:02:52 host sudo: pam_krb5[1547]: TGT verified using key for 'host/[email protected]' Oct 31 15:02:52 host sudo: pam_krb5[1547]: authentication succeeds for 'Aaron' ([email protected]) Oct 31 15:02:52 host sudo: Aaron : command not allowed ; TTY=pts/3 ; PWD=/auto/home/Aaron ; USER=appOwner; COMMAND=/path/to/appStop 

问题:

  • sudo是否有某种冗长或debugging模式,我可以实际看到它捕获sudoers特权列表并确定Aaron是否应该有权限运行此命令? (这个问题可能独立于sudoers数据库的保存位置。)
  • sudo是否可以使用一些可能会出现日志级别的后台机制?

现在,我无法解决我无法识别的问题。 这是一个LDAPsearch失败? 这是一个组成员匹配失败? 确定命令失败的原因将帮助我识别修复

下一步:在/ etc / sudoers中重新创build权限,并查看它是否在本地运行…

干杯!

您可以通过在sudo LDAPconfiguration文件(可能是/etc/sudo-ldap.conf )中设置SUDOERS_DEBUG debug_level来debuggingsudo / LDAP。 debug_level的值可以是1或2.有关详细信息,请参见http://www.sudo.ws/sudo/sudoers.ldap.man.html

首先,答案不答:我忽略了在我的%Administrators条目中为sudoers分支添加sudoHost属性。 我直觉地看到了这一点。

其次,几乎是答案的答案:如果我在sudo手册页上做了更好的RTFM,我会看到sudo -l ,它会告诉我sudo是否看到特权。 一旦我知道特权清单被正确地返回,我可以检查这个可能性列表。

说了这些事情,我仍然想知道如果sudo特权检查有任何debugging入口点。 所以,我解决了我的问题,但没有回答我的问题…