<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Raphaël Ouazana on Medium]]></title>
        <description><![CDATA[Stories by Raphaël Ouazana on Medium]]></description>
        <link>https://medium.com/@rouazana?source=rss-b6b3b0cfb04b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*jAYLWBmDr_1_f6fx.</url>
            <title>Stories by Raphaël Ouazana on Medium</title>
            <link>https://medium.com/@rouazana?source=rss-b6b3b0cfb04b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 06:13:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rouazana/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[To quote, or not to quote, that is the question]]></title>
            <link>https://medium.com/linagora-engineering/to-quote-or-not-to-quote-that-is-the-question-c38ba7f6a1f7?source=rss-b6b3b0cfb04b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c38ba7f6a1f7</guid>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[script]]></category>
            <category><![CDATA[quotes]]></category>
            <category><![CDATA[shell]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Raphaël Ouazana]]></dc:creator>
            <pubDate>Fri, 28 Jul 2017 07:54:50 GMT</pubDate>
            <atom:updated>2017-07-28T07:54:50.749Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GEQopbMc3r-VzsyWNZ-svQ.jpeg" /><figcaption>You can feel alone when learning shell</figcaption></figure><p>When working with my workmates on some command line — so every time I work in pair in fact — I often hear the same question: with quotes? simple or double?</p><p>I would like to explain once for all when to put quotes around your shell (here I will speak only about bash) arguments, and when not, and why.</p><h3>Do I need to quote my password?</h3><p>Quotes are here to not have to escape some characters that would be interpreted differently by bash. They have almost no relation why the tool you are calling, even if it’s a node runtime, a scala runtime, another shell script or an ELF executable (binary).</p><p>The basic case is if you have a space in a file name, for example crazy file name with spaces. If you don’t escape spaces, you turn to pass 5 arguments to your command: crazy,file,name,with and spaces. So if you want to remove this file you end up removing 5 unrelated files. And not the one you wanted to remove. To remove this file, you need to escape the spaces:</p><pre>$ rm crazy\ file\ name\ with\ spaces<br>$ rm &quot;crazy file name with spaces&quot;<br>$ rm &#39;crazy file name with spaces&#39;</pre><p>That’s the basics. But to be sure you understand the principle, the following sample is also valid:</p><pre>$ rm crazy\ file&quot; &quot;nam&#39;e &#39;with&quot; spac&quot;es</pre><p>But I’m sure you prefer the previous ones!</p><p>The interesting part is as you can see, quotes are only there to escape and don’t split argument by themselves. It’s only the internal field separator (IFS, it can be changed, but that’s another story) that is set to space by default.</p><h3>Can I haz my vars?</h3><p>Now that you understand when you need to quote, you’ll be happy to differentiate between simple and double quotes.</p><p>As already said, quoting is done to prevent the shell from interpreting some special (for the shell, not for you) characters: spaces as we seen, but also &gt; and &lt; (for redirections), parenthesis (for sub processing), ! (history expansion, very useful to save you some typing), ` (back-quote, for getting a result from a sub command), $ (to resolve variables for example), and of course… escaping characters themselves: &quot;, &#39; and \ which you would like to sometimes escape too.</p><p>With simple quotes this is very simple: you escape everything, i.e. everything you write between simple quotes will be taken as literal. But simple quotes themselves. Because they will end the escaping, and so you cannot escape them. If you need them either you use double quotes, which are effectively escaping simple quotes, or you use some tricks:</p><pre>$ cat &quot;I&#39;m learning to quote with strange filenames.txt&quot;<br>$ cat &#39;I&#39;\&#39;&#39;m learning to quote with strange filenames.txt&#39;<br>$ cat &#39;I&#39;&quot;&#39;&quot;&#39;m learning to quote with strange filenames.txt&#39;</pre><p>But double quotes are not only for escaping simple quotes. They let also the shell interpret a useful subset of special chars: $, \, ` and !. For example:</p><pre>$ var=myvalue<br>$ echo &quot;with double quotes \$var is interpreted as $var&quot;<br>with double quotes $var is interpreted as myvalue<br>$ echo &#39;with single quotes $var is not interpreted&#39;<br>with single quotes $var is not interpreted</pre><pre>$ echo hello<br>hello<br>$ echo &quot;last param was $!&quot;<br>last param was hello</pre><h3>Minus + minus = plus?</h3><p>If you have well followed, you have remarked that we have never spoke about the minus character, which is used as a de facto standard in the CLI (Command Line Interface) for options. How do you remove a file named -f for example? Or even worst a file named -f /?</p><p>There is a convention that is widespread between most CLI, it’s to use -- for that. All parameters written after -- will be taken as files, not as options. So problem solved:</p><pre>$ rm -- -f<br>$ rm -- &quot;-f /&quot;</pre><h3>Going further?</h3><p>Now that you know how to use quoting, you can be proud to use filenames with spaces in, real passwords (who writes passwords in command lines tools anyway?), and have a hankering after writing shell scripts. So last but no least, how do you take all parameters of a shell script and pass them to another command?</p><pre>#!/bin/bash<br>wrappedcommand &quot;$@&quot;</pre><p>That’s a special case of using double quotes. I hope that made you want to write shell scripts… or not!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c38ba7f6a1f7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/linagora-engineering/to-quote-or-not-to-quote-that-is-the-question-c38ba7f6a1f7">To quote, or not to quote, that is the question</a> was originally published in <a href="https://medium.com/linagora-engineering">Linagora Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[(Open)LDAP best practices — Part 1]]></title>
            <link>https://medium.com/linagora-engineering/open-ldap-best-practices-part-1-c9324c73340f?source=rss-b6b3b0cfb04b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9324c73340f</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[load-testing]]></category>
            <category><![CDATA[ldap]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Raphaël Ouazana]]></dc:creator>
            <pubDate>Fri, 28 Jul 2017 07:54:04 GMT</pubDate>
            <atom:updated>2017-07-28T07:54:04.536Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xvlJmE0092KvI1Za4lqwOg.jpeg" /></figure><p>I started working on LDAP about 15 years ago, almost at the same time I stepped in <a href="http://www.linagora.com/">LINAGORA</a>. As often with love, it was hard and passionate at the beginning.</p><p>My first steps in the LDAP world were about writing compatibility patch allowing to <a href="http://www.openldap.org/its/index.cgi/Contrib?id=3429">download the schema</a> from a proxied proprietary directory. Another step was to get a little further into <a href="http://www.openldap.org/">OpenLDAP</a>’s code and write a <a href="http://aacls.sourceforge.net/">custom backend</a> to handle advanced rights handling (incredible this site is still up).</p><p>When you start digging with so advanced features, it is then pretty easy to get into OpenLDAP administration and LDAP audit in general. LDAP is a very well normalized protocol (even if some points are still in discussion, password policy for example). It is a very good example of how interoperability should work. Many vendors (free and proprietary) are implementing a standard and try to stick as much as possible to it (many but not all… I won’t denounce anyone here, I will just write its initial: AD). So it is really not so hard to migrate from one vendor to one other, giving that the same capabilities are implemented. Sometimes it needs you to <a href="http://www.openldap.org/its/index.cgi/Software%20Enhancements?id=6686">enhance some product</a> to bring more compatibility, but it always goes into the right direction.</p><p>All of this lead me to implement and give advice on many directories, from the smallest (hundreds of entries) to the biggest (hundreds of… millions entries).</p><h3>Performances</h3><p>Fifteen years ago it was pretty hard to make a good LDAP architecture, with a good fault tolerance and good performances. RAM was not as cheap as today, and fitting a big directory into memory was not always possible or sometimes too expensive.</p><p>At this time, we made an extensive use of proxies to spread the load. Of course proxies were <a href="http://www.openldap.org/its/index.cgi/Archive.Software%20Bugs?expression=ouazana;usearchives=1;statetype=-1">buggy</a> too, but at least when a proxy is down you can restart it quickly without wondering if you need to recover the database. You even restart it each night to avoid memory leaks… even if you are really not proud of it when you have to do it.</p><p>Speaking about recovering databases, managing OpenLDAP at this time could be a nightmare. First database implementation, <a href="http://www.openldap.org/software/man.cgi?query=slapd-ldbm&amp;apropos=0&amp;sektion=0&amp;manpath=OpenLDAP+2.4-Release&amp;format=html">LDBM</a> (please don’t mix up with <a href="http://www.openldap.org/software/man.cgi?query=slapd-mdb&amp;apropos=0&amp;sektion=0&amp;manpath=OpenLDAP+2.4-Release&amp;format=html">LMDB</a>, I’ll speak about it later) was very buggy, and you were not even aware of its failure. Following BerkeleyDB based implementations (<a href="http://www.openldap.org/software/man.cgi?query=slapd-bdb&amp;apropos=0&amp;sektion=0&amp;manpath=OpenLDAP+2.4-Release&amp;format=html">BDB</a> and then <a href="http://www.openldap.org/software/man.cgi?query=slapd-hdb&amp;apropos=0&amp;sektion=0&amp;manpath=OpenLDAP+2.4-Release&amp;format=html">HDB</a> backends) were really better: you could know when they were failing, but generally (from my experience) recover was always failing, even in full recovery mode where you keep gigas of transaction logs. And I don’t speak of the choice of version of BerkeleyDB, where you had to choose (and compile) the exact version known to work with OpenLDAP, accompanied by its 2, 4 or 5 patches depending on the version. And then of the many tuning options you had to set: cachesize, idlecachesize, db_cachesize, separated transaction logs, etc. And finally hope all these caches fit in memory…</p><p>If I tell you all this historical stuff, it’s just for you to realize how lucky you are if you are a new LDAP admin. Now you just have to use the brand new <a href="http://www.lmdb.tech/">LMDB</a> <a href="http://www.openldap.org/software/man.cgi?query=slapd-mdb&amp;apropos=0&amp;sektion=0&amp;manpath=OpenLDAP+2.4-Release&amp;format=html">backend</a> (here we are), supported and developed by the OpenLDAP community, and known to be <a href="https://www.usenix.org/conference/osdi14/technical-sessions/presentation/pillai">very</a> <a href="https://www.usenix.org/conference/osdi14/technical-sessions/presentation/zheng_mai">reliable</a>. So speaking about performances with OpenLDAP is really child’s play. You just need to configure the olcDbMaxSize parameter. The value needs just to be as big as your database can be… so just set it to the size of your hard drive and you are done!</p><p>Ok you are done with tuning, but there is still some work to do. Hey, you are not paid only to add one configuration parameter!</p><p>At first don’t forget to specify the olcDbCheckPoint parameter. It takes two values: the first one is the size (in kbytes) of the modifications done before a checkpoint is performed (i.e. really writing datas on the hard drive) ; the second is the time (in minutes) before a checkpoint is also forced if not enough modifications occur.</p><p>Second is a bigger subject: <strong>indexes</strong>. Indexing depend entirely on how your directory is used. In a perfect world, I recommend you to ask every application aimed at connecting the directory which typical requests (particularly LDAP filters) they’ll do. Once done, you can set index matching the request filters. For example (uid=toto) means you have to index with olcDbIndex: uid eq, while (uid=to*to) means olcDbIndex: uid sub and (uid=*) olcDbIndex: uid pres. If needed you can of course combine them olcDbIndex: pres,eq,sub.<br>Note at least two special cases: objectClass should never been indexed in pres (because objectClass in always present, so an index on it will match all the database and will be useless) but should generally be in eq (if you have several object types into your directory). On another hand, entryCSN and entryUUID should be always indexed if you use replication (and you want to use replication, but that’s another subject).</p><p>If you have no idea of how your applications behave, you have two solutions: logs and logs. Warning logs provide you exactly what non existing index has been triggered. Stats logs provide you filters being used on your directory. You can easily extract indexing information from these two sources: warnings will remind you which index to add, while filters analysis will tell you if you can safely remove some indexes. Because, yes, you may want to remove some indexes to improve write performances. You can even have a pool of directories with different indexes matching different applications needs.</p><h3>Coming next</h3><p>I hope this article to be the first one of a long series. Don’t hesitate to comment if you want me to go deeper on some subjects or speak about specific LDAP related topics.</p><p>To do some teasing, I would like to speak about architecture (high availability and load balancing), monitoring, Linux administration (packaging and logging), access rights, <a href="http://loadtesting.sourceforge.net/">performance testing</a>, <a href="https://en.wikipedia.org/wiki/Directory_information_tree">DIT</a> organization and maybe others!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9324c73340f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/linagora-engineering/open-ldap-best-practices-part-1-c9324c73340f">(Open)LDAP best practices — Part 1</a> was originally published in <a href="https://medium.com/linagora-engineering">Linagora Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>