tag:www.rhnh.net,2008:/ldapLdap - Xavier Shay's Blog2008-05-03T11:43:53ZEnkiXavier Shaynotreal@rhnh.nettag:www.rhnh.net,2008:Post/2142007-11-03T10:23:00Z2007-11-03T10:29:31ZIntroducing Clerk Simon<p>Someone sends you an email and you want to add them to your <span class="caps">LDAP</span> address book, but your email client doesn’t support it <strong>cough</strong>thunderbird<strong>cough</strong>. If you think the next best way would be to just forward that email somewhere and have someone else take care of it, then allow me to introduce <a href="http://code.rhnh.net/clerk_simon/README">Clerk Simon</a>. He’s quite attentive when it comes to such matters, and fully certified to boot. Full details at that link, check it out.</p><table class="CodeRay"><tr>
<td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt></pre></td>
<td class="code"><pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }">bzr co http://code.rhnh.net/clerk_simon/<tt>
</tt>cd clerk_simon<tt>
</tt>cp config.sample.yml config.yml # Edit to taste<tt>
</tt>bin/clerk_simon config.yml<tt>
</tt></pre></td>
</tr></table>
tag:www.rhnh.net,2008:Post/2132007-11-03T06:28:00Z2007-11-04T00:00:43ZLDAP Address Book with FreeBSD and SSL<p>First you need to install and configure the OpenLDAP server. Clearly you won’t want to use rhnh.net – just substitute in your own domain.</p><table class="CodeRay"><tr>
<td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt>5<tt>
</tt>6<tt>
</tt>7<tt>
</tt>8<tt>
</tt>9<tt>
</tt><strong>10</strong><tt>
</tt>11<tt>
</tt>12<tt>
</tt>13<tt>
</tt>14<tt>
</tt>15<tt>
</tt>16<tt>
</tt>17<tt>
</tt>18<tt>
</tt>19<tt>
</tt><strong>20</strong><tt>
</tt>21<tt>
</tt>22<tt>
</tt>23<tt>
</tt>24<tt>
</tt>25<tt>
</tt>26<tt>
</tt>27<tt>
</tt>28<tt>
</tt>29<tt>
</tt><strong>30</strong><tt>
</tt>31<tt>
</tt>32<tt>
</tt>33<tt>
</tt>34<tt>
</tt>35<tt>
</tt>36<tt>
</tt></pre></td>
<td class="code"><pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }">sudo pkg_add -r openldap24-server<tt>
</tt>sudo pkg_add -r openssl<tt>
</tt><tt>
</tt>sudo cp /usr/local/openssl/openssl.cnf.sample /usr/local/openssl/openssl.cnf <tt>
</tt># Generate a self signed certificate<tt>
</tt>sudo openssl req -newkey rsa:1024 -x509 -nodes -out server.pem -keyout server.pem -days 3650<tt>
</tt>sudo mkdir /usr/local/etc/ldap<tt>
</tt>sudo mv server.pem /usr/local/etc/ldap<tt>
</tt><tt>
</tt># /etc/rc.conf<tt>
</tt>slapd_enable="YES"<tt>
</tt>slapd_flags='-h "ldaps://rhnh.net/"'<tt>
</tt><tt>
</tt># /usr/local/etc/openldap/ldap.conf<tt>
</tt># Add these same settings not just on the server but for each client<tt>
</tt>BASE dc=rhnh, dc=net<tt>
</tt>URI ldaps://rhnh.net/<tt>
</tt>TLS_REQCERT allow<tt>
</tt><tt>
</tt># /usr/local/etc/openldap/slapd.conf:<tt>
</tt># Add<tt>
</tt>include /usr/local/etc/openldap/schema/cosine.schema<tt>
</tt>include /usr/local/etc/openldap/schema/inetorgperson.schema<tt>
</tt><tt>
</tt>TLSCipherSuite HIGH:MEDIUM:-SSLv2<tt>
</tt>TLSCACertificateFile /usr/local/etc/ldap/server.pem<tt>
</tt>TLSCertificateFile /usr/local/etc/ldap/server.pem<tt>
</tt>TLSCertificateKeyFile /usr/local/etc/ldap/server.pem<tt>
</tt><tt>
</tt>require authc<tt>
</tt><tt>
</tt># Modify these properties from their defaults<tt>
</tt>suffix "dc=rhnh,dc=net"<tt>
</tt>rootdn "cn=xavier,dc=rhnh,dc=net"<tt>
</tt># Use slappasswd to generate your own password<tt>
</tt>rootpw {SSHA}Iogj+Awafoj9FP5IdLVy1DmFaASDw1P5 # secret<tt>
</tt></pre></td>
</tr></table>
<p>Start up the server to make sure everything is apples</p><table class="CodeRay"><tr>
<td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre>1<tt>
</tt>2<tt>
</tt></pre></td>
<td class="code"><pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }">sudo /usr/local/etc/rc.d/slapd start<tt>
</tt>openssl s_client -connect rhnh.net:636 -showcerts<tt>
</tt></pre></td>
</tr></table>
<p>Load up a schema to hold your address book entries, and here is also an example entry.</p><table class="CodeRay"><tr>
<td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt>5<tt>
</tt>6<tt>
</tt>7<tt>
</tt>8<tt>
</tt>9<tt>
</tt><strong>10</strong><tt>
</tt>11<tt>
</tt>12<tt>
</tt>13<tt>
</tt>14<tt>
</tt>15<tt>
</tt>16<tt>
</tt>17<tt>
</tt>18<tt>
</tt>19<tt>
</tt><strong>20</strong><tt>
</tt>21<tt>
</tt>22<tt>
</tt>23<tt>
</tt>24<tt>
</tt>25<tt>
</tt></pre></td>
<td class="code"><pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"># directory.ldif<tt>
</tt>dn: dc=rhnh, dc=net<tt>
</tt>objectClass: top<tt>
</tt>objectClass: dcObject<tt>
</tt>objectClass: organization<tt>
</tt>dc: rhnh<tt>
</tt>o: Robot Has No Heart<tt>
</tt><tt>
</tt>dn: ou=people, dc=rhnh, dc=net<tt>
</tt>objectClass: top<tt>
</tt>objectClass: organizationalUnit<tt>
</tt>ou: people<tt>
</tt><tt>
</tt># contact.ldif<tt>
</tt>dn: cn=Xavier Shay, ou=people, dc=rhnh, dc=net<tt>
</tt>objectClass: top<tt>
</tt>objectClass: person<tt>
</tt>objectClass: organizationalPerson<tt>
</tt>objectClass: inetOrgPerson<tt>
</tt>cn: Xavier Shay<tt>
</tt>gn: Xavier<tt>
</tt>sn: Shay<tt>
</tt>mail: contact@rhnh.net<tt>
</tt>ou: people<tt>
</tt>mobile: 0400-123-456<tt>
</tt></pre></td>
</tr></table>
<table class="CodeRay"><tr>
<td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre>1<tt>
</tt>2<tt>
</tt></pre></td>
<td class="code"><pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }">ldapadd -D 'cn=xavier,dc=rhnh,dc=net' -f directory.ldif -W<tt>
</tt>ldapsearch -D 'cn=xavier,dc=rhnh,dc=net' -w -x # Check everything worked<tt>
</tt></pre></td>
</tr></table>
<p>To configure Thunderbird to use your address book, go to <code>Edit - Preferences... - Composition - Edit Directories...</code> and follow the bouncing ball. Thunderbird can’t write to the directory, which is kind of a pain. Maybe you could use Evolution, which I think works. Maybe you could write an app that monitors a drop box and updates your directory for you. Maybe you could assume I’ve already done what I suggested and wait for me to release it in the very near future.</p>
<p>Tested on FreeBSD 6.2-stable</p>
<h3>References</h3>
<ul>
<li><a href="http://www.onlamp.com/pub/a/onlamp/2003/03/27/ldap_ab.html">Building an Address Book with OpenLDAP</a></li>
<li><a href="http://islandlinux.org/howto/installing-secure-ldap-openldap-ssl-ubuntu-using-self-signed-certificate">Installing Secure <span class="caps">LDAP</span> on Ubuntu using a self-signed certificate</a></li>
<li><a href="http://www.openldap.org/doc/admin23/security.html">OpenLDAP Administrator’s Guide</a></li>
</ul>tag:www.rhnh.net,2008:Post/7602006-05-20T13:04:00Z2008-05-03T11:10:31ZSVN, Trac and NFS<p>Migrated my Subversion repository to my dev server, and am getting it served up through https with <span class="caps">LDAP</span> authentication. Going to set up <a href="http://gentoo-wiki.com/HOWTO_Apache2_with_subversion_SVN_and_DAV">pretty formatting</a> this afternoon – not that I ever use the web interface.</p>
<p>Trac also relies on the webserver for authentication, so it too is running through https/LDAP. All very pretty. One thing that’s not immediately obvious about Trac (you know, if you don’t read the welcome screen) is that managing things like components and milestones is done using the trac-admin program, and not anything on the web interface (although there is a plugin available for this). Initial inspection looks like I’m going to be using it as a glorified <span class="caps">TODO</span> list, but hopefully it will improve my work ethic. The value of this program would increase exponentially with the number of developers, I feel.</p><table class="CodeRay"><tr>
<td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt>5<tt>
</tt>6<tt>
</tt>7<tt>
</tt>8<tt>
</tt>9<tt>
</tt></pre></td>
<td class="code"><pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"><Location /svn><tt>
</tt> DAV svn<tt>
</tt> SVNPath /var/svn/repos<tt>
</tt> AuthType Basic<tt>
</tt> AuthName "Subversion repository"<tt>
</tt> AuthLDAPURL ldap://rhino:389/OU=People,DC=noreality,DC=net?uid?sub?(objectClass=account)<tt>
</tt> Require valid-user<tt>
</tt> SSLRequireSSL<tt>
</tt></Location><tt>
</tt></pre></td>
</tr></table>
<p>Improvements would be using <code>require group insert-ldap-group</code> rather than <code>require valid-user</code>, and to not allow anonymous binds to my <span class="caps">LDAP</span> tree. I don’t have groups setup yet though…</p>
<p>Also set up <span class="caps">NFS</span> on my server – I had been using <span class="caps">SMB</span> (still am for windows) even on my linux clients, but recent dapper updates have really thrown a spanner in those works. I need to comment out my <span class="caps">SMB</span> shares in fstab before I reboot or I’ll be waiting a loooong time for the system to come up again. Noted a neat trick on the gentoo wiki for <a href="http://gentoo-wiki.com/HOWTO_Remote_Kernel_Upgrade">specifying a fallback kernel</a> when recompiling the kernel on a remote box. Thankfully I didn’t have to rely on it, but hooking up a keyboard/monitor to my server-behind-the-TV is not a task I want to have to do on a weekend.</p>tag:www.rhnh.net,2008:Post/7712006-04-07T01:26:00Z2008-05-03T11:43:53ZLDAP Authentication<p>Spent the better part of the evening setting up <span class="caps">LDAP</span> authentication for my boxen. The portage issue I mentioned prior was because I hadn’t updated portage for like 8 months … my bad. Slapd installed without a hitch on my gentoo server, and I was even able to set it up with an <span class="caps">SSL</span> certificate. The problems came getting pam_ldap setup on my ubuntu client. I’m not really sure what I did, but part of my problem was installing all the packages a few days ago, and then changing my mind on the configuration today but not reinstalling the packages. As such, I learnt a handy new command, to reconfigure without reinstall:</p><table class="CodeRay"><tr>
<td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre>1<tt>
</tt>2<tt>
</tt></pre></td>
<td class="code"><pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }">dpkg-reconfigure libpam-ldap<tt>
</tt>dpkg-reconfigure libnss-ldap<tt>
</tt></pre></td>
</tr></table>
<p>I’d also warn against using the libnss-ldap sample nsswitch.conf without a contigency plan – I wasn’t able to execute commands (ls, sudo) after using it, and my machine wouldn’t reboot properly, even in recovery mode. Moral of the story – Always have a LiveCD handy!</p>
<p>I’m at the point now where everything seems to work … except passwd. When changing my password I get “passwd: Authentication information cannot be recovered”. Posted something on the forums, hopefully someone helps me out.</p>