If you encountered some problem when doing sudoCommand, you will be happy if there’s debug info showed in console. To show detailed debug info when doing sudo, modify /etc/ldap.conf(for both solaris ldap and linux ldap):
# verbose sudoers matching from ldap
sudoers_debug 2
sudoers_debug setting to 1 will show moderate debugging, setting to 2 will show the results of the matches themselves. For example, if you have set sudoers_debug to 2 and when you execute sudoCommand, info you’ll get will like the following:
$ sudo -i
LDAP Config Summary
===================
uri ldaps://testLdapServer/
ldap_version 3
sudoers_base ou=SUDOers,dc=doxer,dc=org
binddn cn=proxyAgent,ou=profile,dc=doxer,dc=org
bindpw password
bind_timelimit 120000
timelimit 120
ssl on
tls_cacertdir /etc/openldap/cacerts
===================
sudo: ldap_initialize(ld, ldaps://testLdapServer/)
sudo: ldap_set_option: debug -> 0
sudo: ldap_set_option: ldap_version -> 3
sudo: ldap_set_option: tls_cacertdir -> /etc/openldap/cacerts
sudo: ldap_set_option: timelimit -> 120
sudo: ldap_set_option(LDAP_OPT_NETWORK_TIMEOUT, 120)
sudo: ldap_set_option(LDAP_OPT_X_TLS, LDAP_OPT_X_TLS_HARD)
sudo: ldap_simple_bind_s() ok
sudo: found:cn=defaults,ou=SUDOers,dc=doxer,dc=org
sudo: ldap sudoOption: ‘ignore_local_sudoers’
sudo: ldap search ‘(|(sudoUser=liandy)(sudoUser=%linuxsupport)(sudoUser=%linux)(sudoUser=ALL))’
sudo: found:cn=LDAPpwchange,ou=sudoers,dc=doxer,dc=org
sudo: ldap sudoHost ‘server01′ … not
sudo: ldap sudoHost ‘server02′ … not
sudo: ldap search ‘sudoUser=+*’
sudo: found:cn=test-su,ou=SUDOers,dc=doxer,dc=org
sudo: ldap sudoUser netgroup ‘+sysadmin-ng’ … not
sudo: found:cn=dba-su,ou=SUDOers,dc=doxer,dc=org
sudo: ldap sudoUser netgroup ‘+dba-ng’ … not
sudo: ldap sudoUser netgroup ‘test01′ … not
sudo: ldap sudoUser netgroup ‘test02′ … not
sudo: found:cn=Linux-Team-root,ou=SUDOers,dc=doxer,dc=org
sudo: ldap sudoUser netgroup ‘+linuxadmins’ … MATCH!
sudo: ldap sudoHost ‘ALL’ … MATCH!
sudo: ldap sudoorgmand ‘ALL’ … MATCH!
sudo: Perfect Matched!
sudo: ldap sudoOption: ‘!authenticate’
sudo: user_matches=-1
sudo: host_matches=-1
sudo: sudo_ldap_check(0)=0×422
So from above debugging outputs, you’ll know that the account to be sudo authenticated belongs to linuxadmins netgroup and this netgroup is in the sudoUser’s scope of Linux-Team-root SUDOers. As Linux-Team-root has sudoCommand for “ALL” and sudoHost for “ALL” and also has sudoOption “!authenticate”, then the user will successfully get root access with no password prompt.
Now let’s go through a failed authentication to see the debugging information:
$ sudo hastatus -sum
LDAP Config Summary
===================
host testLdapServer
port 389
ldap_version 3
sudoers_base ou=SUDOers,dc=doxer,dc=org
binddn (anonymous)
bindpw (anonymous)
===================
ldap_init(testLdapServer,389)
ldap_set_option(LDAP_OPT_PROTOCOL_VERSION,0×03)
ldap_bind() ok
found:cn=defaults,ou=SUDOers,dc=doxer,dc=org
ldap sudoOption: ‘ignore_local_sudoers’
ldap search ‘(|(sudoUser=liandy)(sudoUser=%normaluser)(sudoUser=%normaluser)(sudoUser=%patop)(sudoUser=ALL))’
ldap search ‘sudoUser=+*’
found:cn=test-su,ou=SUDOers,dc=doxer,dc=org
ldap sudoUser netgroup ‘+sysadmin-ng’ … not
found:cn=tstwas-su,ou=SUDOers,dc=doxer,dc=org
ldap sudoUser netgroup ‘+linux-team-ng’ … not
found:cn=normal-su,ou=SUDOers,dc=doxer,dc=org
ldap sudoUser netgroup ‘+normaluser-ng’ … MATCH!
ldap sudoHost ‘all’ … MATCH!
ldap sudoCommand ‘/opt/OV/bin/OpC/opcagt -start’ … not
ldap sudoCommand ‘/opt/OV/bin/OpC/opcagt -status’ … not
ldap sudoCommand ‘/opt/OV/bin/OpC/opcagt -stop’ … not
ldap sudoCommand ‘/opt/OV/bin/OpC/opcagt -kill’ … not
user_matches=-1
host_matches=-1
sudo_ldap_check(0)=0×04
Password:
From here we can see that although the user to be authenticated is in “normal-su” SUDOers, and the host is in it’s sudoHost, but as there’s no “hastatus -sum” defined for sudoCommand, so at last the authentication failed(user_matches=-1, host_matches=-1) and prompts for sudo password.