<p dir=ltr>Very interesting!</p>
<p dir=ltr>You're right, I used simple  "ldapsearch -x" command on the client when browsing the LDAP database. With IPA 3.3 it returned a whole lot of info about hostgroups, but with IPA 4.1 - only a single string 'cn=ng,cn=compat,$SUFFIX'. That's why current script didn't work.</p>
<p dir=ltr>Tomorrow at work I'll try your advice, and if there's no another problem between the chair and the keyboard, I'll definitely stick with FreeIPA 4.1!</p>
<p dir=ltr>Отправлено от <a href="http://r.bluemailapp.com">Blue Mail</a></p>
<head><head><style type="text/css"> pre.blue {white-space: pre-wrap; word-wrap:break-word; font-family: sans-serif; margin-top: 0px} div, p { -ms-word-break: break-all; word-break: break-all; word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; -ms-hyphens: auto;hyphens: auto;} a {color: #226EF9 ;}</style></head><body style="zoom: 100%; "><div class="gmail_quote" >На 23.10.2014, в 21:40, Alexander Bokovoy <<a href="mailto:abokovoy@redhat.com" target="_blank">abokovoy@redhat.com</a>> написал:п<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="blue">On Thu, 23 Oct 2014, Орхан Касумов wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"><br>Alright then, thanks for info!<br>Tomorrow is the deadline for my researches on FreeIPA.<br>Then I have to start deploying a centralized management solution in our production environment.<br>Please help me to make a final decision on which version of FreeIPA to choose - 3.3 or 4.1?<br>I'd like to have all the benefits of the latest version, but all our production servers are FreeBSD.<br>With all information sources at my disposal right now I tend to choose FreeIPA 3.3.<br>The cause is that otherwise I can't use host groups with sudo commands -<br>the cron script proposed at FreeBSD forums works with old way of storing host group information in the LDAP directory of FreeIPA.<br>Is there any workaround for this? (P.S. Here's what I'm talking about:<br><blockquote class="gmail_quote"
style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;">" The tricky part was getting  sudo  to work with host groups. FreeIPA<br>keeps host groups in netgroups, and FreeBSD's support for netgroups is<br>limited. One solution would have been to enable NIS services on the<br>FreeIPA server so that we could use proper netgroups on FreeBSD<br>clients. We didn't like that solution, so instead we wrote a script<br>that pulls all netgroup data from FreeIPA and stores it in <br>/etc/netgroup . We run the script every hour via  cron . "<br><br>The script looks for host groups in<br>'cn=hostgroups,cn=accounts,dc=<domain>', and="" that="" works="" with="" freeipa<br="">3.3. But in FreeIPA v4 host groups get in<br>'cn=ng,cn=compat,dc=<domain>'. so="" the="" script="" needs="" modification.="" but="" i<br="">don't know how to modify the script, simply changing the string passed<br>to the ldapsearch command doesn't
work.)<br></domain>'.></domain>',></blockquote></blockquote>I think you completely missed the way FreeIPA works. :)<br><br>Host groups are always in cn=hostgroups,cn=accounts,$SUFFIX, no changes<br>were done.<br><br>What you see in cn=ng,cn=compat,$SUFFIX are net groups for compatibility<br>with older applications which expect old LDAP schema. The tree in<br>cn=compat,$SUFFIX is provided through schema compatibility plugin and<br>was also provided this way for quite a long time.<br><br>What I think you are stumbling upon is the fact that starting with<br>FreeIPA 4.0 we are providing more fine-grained access control to the<br>data in LDAP tree. <br><br>For example:<br>$ ipa permission-find --subtree=cn=hostgroups,cn=accounts,dc=ipacloud,dc=test  --right=read<br>---------------------<br>2 permissions matched<br>---------------------<br>  Permission name: System: Read Hostgroup Membership<br>  Granted rights: read, compare, search<br>  Effective attributes: memb!
 er,
memberhost, memberof, memberuser<br>  Default attributes: member, memberof, memberuser, memberhost<br>  Bind rule type: all<br>  Subtree: cn=hostgroups,cn=accounts,dc=ipacloud,dc=test<br>  Type: hostgroup<br><br>  Permission name: System: Read Hostgroups<br>  Granted rights: read, compare, search<br>  Effective attributes: businesscategory, cn, createtimestamp,<br>description, entryusn, ipauniqueid, modifytimestamp, o, objectclass, ou,<br>owner, seealso<br>  Default attributes: cn, businesscategory, objectclass, description, o,<br>ipauniqueid, owner, ou, seealso<br>  Bind rule type: all<br>  Subtree: cn=hostgroups,cn=accounts,dc=ipacloud,dc=test<br>  Type: hostgroup<br>----------------------------<br>Number of entries returned 2<br>----------------------------<br><br>As you can see, both permissions require bind rule type 'all' which<br>means 'all authenticated users'.<br><br>On contrast, in schema compat tree you'll get the whole tree anonymously<br><br>$ ipa permission-find
--target=cn=ng,cn=compat,dc=ipacloud,dc=test --right=read<br>--------------------<br>1 permission matched<br>--------------------<br>  Permission name: System: Read Netgroup Compat Tree<br>  Granted rights: read, compare, search<br>  Effective attributes: cn, createtimestamp, entryusn, membernisnetgroup, modifytimestamp, nisnetgrouptriple, objectclass<br>  Default attributes: objectclass, nisnetgrouptriple, membernisnetgroup, cn<br>  Bind rule type: anonymous<br>  Subtree: dc=ipacloud,dc=test<br>  Target DN: cn=ng,cn=compat,dc=ipacloud,dc=test<br>----------------------------<br>Number of entries returned 1<br>----------------------------<br><br>This means that your script should work as before, only that it needs to<br>authenticate before connecting. As you run it as root, you can use host<br>keytab, try adding something like this:<br><br>old_krb5_ccache=${KRB5_CCACHE}<br>KRB5_CCACHE=/tmp/_hostgroups_access.ccache.$$<br>export KRB5_CCACHE<br>kinit -k -t /etc/krb5.keytab
host/`hostname`<br># perform actual search<br>ldapsearch -Y GSSAPI .....<br><br># end of script<br>kdestroy<br>KRB5_CCACHE=${old_krb5_ccache}<br>export KRB5_CCACHE<br><br>note that ldapsearch -Y GSSAPI will use Kerberos authentication when<br>talking to IPA LDAP server and use host/`hostname` principal for that.<br>This should be enough for allowing access to the host groups.<br></pre></blockquote></div></body></head>