<html><body><p>Rob,<br><br>  Yes.. in our setup allow_all has to be explicitly applied to a persons/group HBAC for it to be available to them.  This user has one direct HBAC rule and its called Bob which only allows access to 2 servers and the services I provided below and one indirect HBAC rule which allows him access to our NFS server automouting home profiles and his own sudo rule called bob.<br><br>I have removed /bin/bash from his sudo rule and it is working as expected now however I am thinking this will affect app owners from being able to sudo to app IDs so they will just have to su to them instead I am thinking.  Is probably a better approach anyways as the app owner should know the app password and keep anyone else from sudoing to it with there own pw.<br><br>output of working as required:<br><br>[bob@server ~]$ sudo -i<br>Sorry, user bob is not allowed to execute '/bin/bash' as root on server.example.local.<br>[bob@server ~]$ sudo cat /etc/sysconfig/iptables<br># Firewall configuration written by system-config-firewall<br># Manual customization of this file is not recommended.<br>*filter<br>[bob@server ~]$ sudo -i<br>Sorry, user bob is not allowed to execute '/bin/bash' as root on server.example.local.<br>[bob@server ~]$ <br><br>Any comments or suggestions welcome<br><br><br><br>Sean Hogan<br>Security Engineer<br>Watson Security & Risk Assurance<br>Watson Cloud Technology and Support<br><font size="2" face="Verdana">email: schogan@us.ibm.com | Tel 919 486 1397</font><br><font size="2" face="Verdana"><br></font><img src="cid:1__=88BBF583DFFACA398f9e8a93df938690918c88B@" width="67" height="53" align="top"><font size="2" face="Verdana">  </font><img src="cid:2__=88BBF583DFFACA398f9e8a93df938690918c88B@" width="60" height="51" align="top"><br><br><br><br><br><img width="16" height="16" src="cid:3__=88BBF583DFFACA398f9e8a93df938690918c88B@" border="0" alt="Inactive hide details for Rob Crittenden ---12/03/2015 11:21:23 AM---Sean Hogan wrote: > I had the log bumped to 8 and yes the "><font color="#424282">Rob Crittenden ---12/03/2015 11:21:23 AM---Sean Hogan wrote: > I had the log bumped to 8 and yes the allow_all HBAC rule is enabled</font><br><br><font size="2" color="#5F5F5F">From:        </font><font size="2">Rob Crittenden <rcritten@redhat.com></font><br><font size="2" color="#5F5F5F">To:        </font><font size="2">Sean Hogan/Durham/IBM@IBMUS, "Freeipa-users@redhat.com" <Freeipa-users@redhat.com></font><br><font size="2" color="#5F5F5F">Date:        </font><font size="2">12/03/2015 11:21 AM</font><br><font size="2" color="#5F5F5F">Subject:        </font><font size="2">Re: [Freeipa-users] Sudo question</font><br><hr width="100%" size="2" align="left" noshade style="color:#8091A5; "><br><br><br><tt>Sean Hogan wrote:<br>> I had the log bumped to 8 and yes the allow_all HBAC rule is enabled<br>> however not associated with this user at all. This test only allows this<br>> user to hit 2 servers with individual HBAC rule to the 2 servers via the<br>> services I provided earlier.<br>> <br><br>allow_all applies to everyone unless you've changed it. HBAC is deny by<br>default so once allowed, always allowed.<br><br>I'm not well-versed in the sssd logs so maybe one of those guys will<br>chime in.<br><br>rob<br><br>> [bob@server ~]$ sudo -l<br>> [sudo] password for bob:<br>> Matching Defaults entries for bob on this host:<br>> requiretty, !visiblepw, always_set_home, env_reset, env_keep="COLORS<br>> DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS", env_keep+="MAIL PS1<br>> PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE", env_keep+="LC_COLLATE<br>> LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES", env_keep+="LC_MONETARY<br>> LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE", env_keep+="LC_TIME LC_ALL<br>> LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY",<br>> secure_path=/sbin\:/bin\:/usr/sbin\:/usr/bin, logfile=/var/log/sudo.log<br>> <br>> User bob may run the following commands on this host:<br>> (root) !/usr/local/bin/sudo, !/usr/bin/sudo, !/bin/sudo<br>> (root) /usr/bin/xclock<br>> (root) /sbin/iptables, /sbin/service, /bin/vi, /bin/view, /usr/bin/vim,<br>> /bin/bash, /bin/netstat, /usr/bin/sudo -u user -i, /bin/cat,<br>> !/usr/bin/sudo -i, !/usr/bin/sudo-i, !/usr/bin/sudo -u root -i<br>> <br>> <br>> <br>> sssd.conf<br>> server.example.local:/var/log# cat /etc/sssd/sssd.conf<br>> [domain/example.local]<br>> cache_credentials = True<br>> krb5_store_password_if_offline = True<br>> ipa_domain = example.local<br>> id_provider = ipa<br>> auth_provider = ipa<br>> access_provider = ipa<br>> ipa_hostname = server.example.local<br>> chpass_provider = ipa<br>> ipa_dyndns_update = True<br>> ipa_server = _srv_, mastersrv.example.local<br>> ldap_tls_cacert = /etc/ipa/ca.crt<br>> [sssd]<br>> services = nss, sudo, pam, ssh<br>> config_file_version = 2<br>> debug_level = 8<br>> <br>> domains = example.local<br>> [nss]<br>> homedir_substring = /home<br>> <br>> [pam]<br>> <br>> [sudo]<br>> <br>> [autofs]<br>> <br>> [ssh]<br>> <br>> [pac]<br>> <br>> [ifp]<br>> <br>> <br>> Ran thru the commands again:<br>> [me@mine ~]$ ssh bob@server<br>> bob@server password:<br>> Last login: Thu Dec 3 11:24:53 2015 from IP_ADDRESS<br>> [bob@server ~]$ sudo -i<br>> [sudo] password for bob:<br>> Sorry, try again.<br>> [sudo] password for bob:<br>> sudo: 1 incorrect password attempt<br>> [bob@server ~]$ sudo cat /etc/sysconfig/iptables<br>> [sudo] password for bob:<br>> # Firewall configuration written by system-config-firewall<br>> # Manual customization of this file is not recommended.<br>> *filter<br>> [bob@server ~]$ sudo -i<br>> server.example.local:/root# exit<br>> <br>> This is what the logs show for above conversations<br>> Dec 3 11:49:52 server sshd[61682]: pam_unix(sshd:auth): authentication<br>> failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=IP_ADDRESS user=bob<br>> Dec 3 11:49:53 server sshd[61682]: pam_sss(sshd:auth): authentication<br>> success; logname= uid=0 euid=0 tty=ssh ruser= rhost=IP_ADDRESS user=bob<br>> Dec 3 11:49:53 server sshd[61682]: Accepted password for bob from<br>> IP_ADDRESS port 50273 ssh2<br>> Dec 3 11:49:53 server sshd[61682]: pam_unix(sshd:session): session<br>> opened for user bob by (uid=0)<br>> Dec 3 11:49:53 server sshd[61682]: User child is on pid 61687<br>> <br>> Attempt sudo -i which fails with bad pw but at least fails, PW is correct.<br>> Dec 3 11:50:05 server sudo: pam_unix(sudo-i:auth): authentication<br>> failure; logname=bob uid=1091450500 euid=0 tty=/dev/pts/2 ruser=bob<br>> rhost= user=bob<br>> Dec 3 11:50:06 server sudo: pam_sss(sudo-i:auth): authentication<br>> success; logname=bob uid=1091450500 euid=0 tty=/dev/pts/2 ruser=bob<br>> rhost= user=bob<br>> Dec 3 11:50:06 server sudo: pam_sss(sudo-i:account): Access denied for<br>> user bob: 6 (Permission denied)<br>> Dec 3 11:50:11 server sudo: pam_unix(sudo-i:auth): conversation failed<br>> Dec 3 11:50:11 server sudo: pam_unix(sudo-i:auth): auth could not<br>> identify password for [bob]<br>> Dec 3 11:50:11 server sudo: pam_sss(sudo-i:auth): authentication<br>> failure; logname=bob uid=1091450500 euid=0 tty=/dev/pts/2 ruser=bob<br>> rhost= user=bob<br>> Dec 3 11:50:11 server sudo: pam_sss(sudo-i:auth): received for user bob:<br>> 7 (Authentication failure)<br>> Dec 3 11:50:11 server sudo: bob : 1 incorrect password attempt ;<br>> TTY=pts/2 ; PWD=/home/rusers/bob ; USER=root ; COMMAND=/bin/bash<br>> <br>> Cat /etc/syconfig/iptables which works after prompting for pw so good<br>> Dec 3 11:50:42 server sudo: pam_unix(sudo:auth): authentication failure;<br>> logname=bob uid=1091450500 euid=0 tty=/dev/pts/2 ruser=bob rhost= user=bob<br>> Dec 3 11:50:43 server sudo: pam_sss(sudo:auth): authentication success;<br>> logname=bob uid=1091450500 euid=0 tty=/dev/pts/2 ruser=bob rhost= user=bob<br>> Dec 3 11:50:43 server sudo: bob : TTY=pts/2 ; PWD=/home/rusers/bob ;<br>> USER=root ; COMMAND=/bin/cat /etc/sysconfig/iptables<br>> <br>> sudo -i now works even though it did not before<br>> Dec 3 11:50:52 server sudo: bob : TTY=pts/2 ; PWD=/home/rusers/bob ;<br>> USER=root ; COMMAND=/bin/bash<br>> <br>> <br>> I expect the pam_unix fails as the accounts are not local.. I expect the<br>> first set of fails for sudo -i even though its comes up a pw issue which<br>> is not the case. I expect success when catting iptables which is good<br>> but then sudo -i just works after that which is not expected.<br>> <br>> Client:<br>> rpm -qa | grep ipa<br>> python-iniparse-0.3.1-2.1.el6.noarch<br>> libipa_hbac-python-1.11.6-30.el6_6.4.ppc64<br>> ipa-python-3.0.0-42.el6.ppc64<br>> libipa_hbac-1.11.6-30.el6_6.4.ppc64<br>> device-mapper-multipath-libs-0.4.9-80.el6_6.3.ppc64<br>> sssd-ipa-1.11.6-30.el6_6.4.ppc64<br>> ipa-client-3.0.0-42.el6.ppc64<br>> device-mapper-multipath-0.4.9-80.el6_6.3.ppc64<br>> <br>> <br>> Server:<br>> rpm -qa | grep ipa<br>> sssd-ipa-1.12.4-47.el6.x86_64<br>> ipa-admintools-3.0.0-47.el6.x86_64<br>> ipa-pki-ca-theme-9.0.3-7.el6.noarch<br>> libipa_hbac-python-1.12.4-47.el6.x86_64<br>> ipa-client-3.0.0-47.el6.x86_64<br>> ipa-python-3.0.0-47.el6.x86_64<br>> ipa-pki-common-theme-9.0.3-7.el6.noarch<br>> ipa-server-selinux-3.0.0-47.el6.x86_64<br>> ipa-server-3.0.0-47.el6.x86_64<br>> python-iniparse-0.3.1-2.1.el6.noarch<br>> libipa_hbac-1.12.4-47.el6.x86_64<br>> <br>> <br>> <br>> Inactive hide details for Rob Crittenden ---12/03/2015 08:29:53<br>> AM---Sean Hogan wrote: > Hi Rob,Rob Crittenden ---12/03/2015 08:29:53<br>> AM---Sean Hogan wrote: > Hi Rob,<br>> <br>> From: Rob Crittenden <rcritten@redhat.com><br>> To: Sean Hogan/Durham/IBM@IBMUS, "Freeipa-users@redhat.com"<br>> <Freeipa-users@redhat.com><br>> Date: 12/03/2015 08:29 AM<br>> Subject: Re: [Freeipa-users] Sudo question<br>> <br>> ------------------------------------------------------------------------<br>> <br>> <br>> <br>> Sean Hogan wrote:<br>>> Hi Rob,<br>>><br>>> Thanks for the suggestion. I think that is what I have though. The<br>>> sudorule applied for this user does not have sudo as an avail command<br>>> unless it picks up /usr/bin/sudo -u user -i which I was thinking would<br>>> only allow sudoing to user.<br>>> HBAC services I have for the user has sudo and no sudo -i.<br>>> Services<br>>> sshd<br>>> login<br>>> gdm<br>>> gdm-password<br>>> kdm<br>>> su<br>>> su-l<br>>> vsftpd<br>>> sudo<br>>><br>>> Sudo Rule<br>>> *Sudo Allow Commands*: /sbin/iptables, /sbin/service,<br>>> /bin/view,/bin/bash, /bin/netstat, /usr/bin/sudo -u user -i, /bin/cat<br>>> *Sudo Deny Commands*: /usr/bin/sudo -i, /usr/bin/sudo-i, /usr/bin/sudo<br>>> -u root -i<br>>><br>>> Unfortunately I am really stumped on this one.<br>> <br>> You probably have the allow_all HBAC rule enabled. If sudo-i isn't<br>> allowed in HBAC then the pam service shouldn't be allowed at all. I'd<br>> suggest you bump up the sssd debug level to better see what is happening.<br>> <br>> rob<br>> <br>>><br>>><br>>><br>>><br>>><br>>> Inactive hide details for Rob Crittenden ---12/02/2015 04:26:24<br>>> PM---Sean Hogan wrote: > Hi All,Rob Crittenden ---12/02/2015 04:26:24<br>>> PM---Sean Hogan wrote: > Hi All,<br>>><br>>> From: Rob Crittenden <rcritten@redhat.com><br>>> To: Sean Hogan/Durham/IBM@IBMUS, freeipa-users@redhat.com<br>>> Date: 12/02/2015 04:26 PM<br>>> Subject: Re: [Freeipa-users] Sudo question<br>>><br>>> ------------------------------------------------------------------------<br>>><br>>><br>>><br>>> Sean Hogan wrote:<br>>>> Hi All,<br>>>><br>>>> I have a significant amount of time on this and hoping some of you might<br>>>> have an idea. I want to limit user bob from getting to a root prompt on<br>>>> this test box.<br>>>> It seems to work until bob is able to run a command he is allowed via<br>>>> sudo such as cat. Sudo -i is on the deny command list in IPA and root is<br>>>> local(not in IPA) with<br>>>> nsswitch pointing to files first then sss.<br>>>><br>>>> So logged on as user bob, first thing attempted was sudo -i which<br>>>> produces wrong pw message even though it is the correct pw but it is<br>>>> denying so fine. Then I issue sudo cat /etc/sysconfig/iptables<br>>>> and it allows it after I enter bob's pw which is fine. However right<br>>>> after that I try sudo -i again and get root prompt which is not good. I<br>>>> am thinking since root is local and files first then once I sudo up root<br>>>> is avail.<br>>>> Any suggestions are welcome<br>>><br>>> I think you are better off using an HBAC rule to only grant sudo and not<br>>> sudo -i.<br>>><br>>> rob<br>>><br>>>><br>>>><br>>>><br>>>> *[me@mine ~]$ ssh bob@server*<br>>>> bob@servers password:<br>>>> Last login: Time: from IP<br>>>> Internal systems must only be used for conducting company business or<br>>>> for purposes authorized by company management<br>>>> Use is subject to audit at any time by company management<br>>>> *[bob@server ~]$ sudo -i*<br>>>> [sudo] password for bob:<br>>>> Sorry, try again.<br>>>> *[bob@server ~]$ sudo -i*<br>>>> [sudo] password for bob:<br>>>> Sorry, try again.<br>>>> [sudo] password for bob:<br>>>> Sorry, try again.<br>>>> [sudo] password for bob:<br>>>> sudo: 2 incorrect password attempts<br>>>> *[bob@server ~]$ sudo cat /etc/sysconfig/iptables*<br>>>> [sudo] password for bob:<br>>>> # Firewall configuration written by system-config-firewall<br>>>> # Manual customization of this file is not recommended.<br>>>> *filter<br>>>> *[bob@server ~]$ sudo -i*<br>>>> *server.example.local:/root# cat /etc/sysconfig/iptables*<br>>>> # Firewall configuration written by system-config-firewall<br>>>> # Manual customization of this file is not recommended.<br>>>> *filter<br>>>><br>>>><br>>>><br>>>> ipa sudorule-show bob<br>>>> Rule name: bob<br>>>> Description: test sudo rule for user bob<br>>>> Enabled: TRUE<br>>>> Host category: all<br>>>> Users: bob<br>>>> Sudo Allow Commands: /sbin/iptables, /sbin/service, /bin/view,<br>>>> /bin/bash, /bin/netstat, /usr/bin/sudo -u user -i, /bin/cat<br>>>> Sudo Deny Commands: /usr/bin/sudo -i, /usr/bin/sudo-i, /usr/bin/sudo -u<br>>>> root -i<br>>>><br>>>> Is it just me or is white space ignored as well with sudo commands much<br>>>> like the sudo options?<br>>>><br>>>><br>>>><br>>>><br>>>><br>>>><br>>>> Sean Hogan<br>>>> Security Engineer<br>>>> Watson Security & Risk Assurance<br>>>> Watson Cloud Technology and Support<br>>>> email: schogan@us.ibm.com | Tel 919 486 1397<br>>>><br>>>><br>>>><br>>>><br>>>><br>>>><br>>>><br>>><br>>><br>>><br>>><br>> <br>> <br>> <br>> <br><br></tt><br><br><BR>
</body></html>