<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fellinghaug Blog &#187; tips</title>
	<atom:link href="http://asbjorn.fellinghaug.com/blog/category/linux/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://asbjorn.fellinghaug.com/blog</link>
	<description>&#62;&#62;&#62; from fellinghaug import asbjorn; asbjorn.play()</description>
	<lastBuildDate>Thu, 19 Nov 2009 21:22:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Apache, subversion and LDAP group authentication</title>
		<link>http://asbjorn.fellinghaug.com/blog/2009/06/apache-subversion-and-ldap-group-authentication/</link>
		<comments>http://asbjorn.fellinghaug.com/blog/2009/06/apache-subversion-and-ldap-group-authentication/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 07:30:00 +0000</pubDate>
		<dc:creator>Asbjørn Alexander Fellinghaug</dc:creator>
				<category><![CDATA[general IT]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[authenticate]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[ldap-filter]]></category>
		<category><![CDATA[ldap-group]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://asbjorn.fellinghaug.com/blog/?p=222</guid>
		<description><![CDATA[Hellu!
Lately I&#8217;ve been working on securing some web accessible resource, especially Subversion access to repositories through the Apache webserver. One aspect we found very difficult was to secure subversion access through our apache server, when we had a Active Directory server to authenticate against (I know..).
Apache have some directives such as &#8220;Require valid-user&#8221; which signals [...]]]></description>
			<content:encoded><![CDATA[<p>Hellu!</p>
<p>Lately I&#8217;ve been working on securing some web accessible resource, especially Subversion access to repositories through the Apache webserver. One aspect we found very difficult was to secure subversion access through our apache server, when we had a Active Directory server to authenticate against (I know..).</p>
<p>Apache have some directives such as &#8220;Require valid-user&#8221; which signals that a user has to be authenticated against some authentication provider. This is in most cases a standard &#8220;.htaccess&#8221; and &#8220;.htpasswd&#8221; combination which provides this. For small projects, this may be a working approach. However, in a large-scale organization where you want a dynamic handling of users and their access, then using groups to reflect the users access to resources may be a better working solution.</p>
<p>For one of our projects, we wanted all LDAP (AD) users to have read access, while members of certain groups have read and write access. We solved this with the following Apache config:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="apache apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">Location</span> /wicked_project&gt;
   DAV svn
   SVNParentPath /var/svn/wicked_project
   AuthzLDAPAuthoritative <span style="color: #0000ff;">off</span>
   <span style="color: #00007f;">AuthType</span> basic
   AuthBasicProvider ldap
   <span style="color: #00007f;">AuthName</span> <span style="color: #7f007f;">&quot;Need to authenticate here&quot;</span>
   AuthLDAPBindDN <span style="color: #7f007f;">&quot;ldap_user@domain.net&quot;</span>
   AuthLDAPBindPassword secretPassword
   AuthLDAPURL <span style="color: #7f007f;">&quot;ldap://ad.domain.net/dc=domain,dc=net?sAMAccountName?sub?(objectClass=*)&quot;</span>
&nbsp;
   &lt;Limit GET PROPFIND <span style="color: #00007f;">OPTIONS</span> CHECKOUT&gt;
      <span style="color: #00007f;">Require</span> valid-<span style="color: #00007f;">user</span>
   &lt;/Limit&gt;
   &lt;Limit REPORT MKACTIVITY PROPPATCH PUT MKCOL MOVE COPY DELETE LOCK UNLOCK MERGE&gt;
   <span style="color: #00007f;">Require</span> ldap-filter |(memberOf=CN=Staff,OU=GROUPS,DC=DOMAIN,DC=NET) \
                (memberOf=CN=Wicked_project_rw,OU=GROUPS,DC=DOMAIN,DC=NET)
   &lt;/Limit&gt;
&lt;/<span style="color: #000000; font-weight:bold;">Location</span>&gt;</pre></td></tr></table></div>

<p>Another LDAP directive which can work if you only need one group to have read and write access is the &#8220;ldap-group&#8221; directive. However, in our case we needed multiple groups, which is not supported by the &#8220;ldap-group&#8221; directive.</p>
<p>To solve this problem we used &#8220;ldap-filter&#8221; with multiple group filters inside the same filter, and divide them with the boolean OR. I don&#8217;t know if there are any more elegant ways of achieving the same result, but this solved our problems.</p>
<p>Having a second look at this &#8220;ldap-fiter&#8221; directive, I see that it have a significant strength in terms of flexibility. However, one aspect I have not considered is the performance of this approach. Without looking in-depth into the mod_ldap apache module, I can guess that for each filter inside the ldap-filter directive, it have to make a query to the LDAP (AD) server to retrieve the wanted resource. So, for each group filter inside the ldap-filter, you need a call. In our approach, we need two LDAP queries. As you now may see, the more groups to filter, the more LDAP queries, hence the performance will degrade the more complex the ldap-filter is.</p>
]]></content:encoded>
			<wfw:commentRss>http://asbjorn.fellinghaug.com/blog/2009/06/apache-subversion-and-ldap-group-authentication/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Twitter from commandline</title>
		<link>http://asbjorn.fellinghaug.com/blog/2008/05/twitter-from-commandline/</link>
		<comments>http://asbjorn.fellinghaug.com/blog/2008/05/twitter-from-commandline/#comments</comments>
		<pubDate>Mon, 05 May 2008 19:26:44 +0000</pubDate>
		<dc:creator>Asbjørn Alexander Fellinghaug</dc:creator>
				<category><![CDATA[Funny]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[lucene]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://asbjorn.fellinghaug.com/blog/?p=24</guid>
		<description><![CDATA[I&#8217;ve been taken by the Twitter storm these days.. Damn, I should focus a hole lot more on my master report. Well, this took me only one little hour, so it&#8217;s not that waste of time..    So, I guess you have heard about the new &#8220;facebook&#8221; called Twitter? Well, its this new [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been taken by the Twitter storm these days.. Damn, I should focus a hole lot more on my master report. Well, this took me only one little hour, so it&#8217;s not that waste of time.. <img src='http://asbjorn.fellinghaug.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   So, I guess you have heard about the new &#8220;facebook&#8221; called <a title="Twitter" href="http://www.twitter.com">Twitter</a>? Well, its this new web community thing were people can write their current status for what they are doing in the world.. And, of course, one can follow friends and pay attention to were / what they are doing.. Now, after some time I found it rather heavy to enter the twitter webpage, login, and then post a new twitter message for each time I want to update my status. So, as a python fan I am, I created myself a little python script to capture this problem. It relies on the <a title="Python Twitter" href="http://code.google.com/p/python-twitter/">python-twitter</a> module available at the Google Code pages. So, lets have a look at the code. I have named this file &#8220;update.py&#8221;, however feel free to rename it.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
</pre></td><td class="code"><pre class="python python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
<span style="color: #ff7700;font-weight:bold;">import</span> twitter
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
&nbsp;
USERNAME=<span style="color: #483d8b;">&quot;&quot;</span>
PASSWORD=<span style="color: #483d8b;">&quot;&quot;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> postNewMessage<span style="color: black;">&#40;</span>msg<span style="color: black;">&#41;</span>:
    api = twitter.<span style="color: black;">Api</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    api = twitter.<span style="color: black;">Api</span><span style="color: black;">&#40;</span>username=<span style="color: #483d8b;">&quot;&quot;</span>, password=<span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">isinstance</span><span style="color: black;">&#40;</span>msg, <span style="color: #008000;">list</span><span style="color: black;">&#41;</span>:
        msg = <span style="color: #483d8b;">&quot; &quot;</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>msg<span style="color: black;">&#41;</span>
    msg = <span style="color: #008000;">unicode</span><span style="color: black;">&#40;</span>msg, <span style="color: #483d8b;">&quot;utf-8&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>msg<span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">140</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;ERROR: Message can't be over 140 chars.&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span>
    <span style="color: #ff7700;font-weight:bold;">try</span>:
        api.<span style="color: black;">PostUpdate</span><span style="color: black;">&#40;</span>msg<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;OK. Was %i chars in msg.&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>msg<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">Exception</span>, e:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;FUck..&quot;</span>
&nbsp;
    api.<span style="color: black;">ClearCredentials</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">1</span>:
        t = <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>t<span style="color: black;">&#41;</span> == <span style="color: #ff4500;">1</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>t<span style="color: black;">&#91;</span>0<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">10</span>:
            <span style="color: #808080; font-style: italic;"># writes ./update &quot;hi there mate&quot;</span>
            postNewMessage<span style="color: black;">&#40;</span>t<span style="color: black;">&#91;</span>0<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">else</span>:
            <span style="color: #808080; font-style: italic;"># writes ./update hello world</span>
            postNewMessage<span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;fuck&quot;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://asbjorn.fellinghaug.com/blog/2008/05/twitter-from-commandline/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Linux and internal OS caching</title>
		<link>http://asbjorn.fellinghaug.com/blog/2008/04/linux-and-internal-os-caching/</link>
		<comments>http://asbjorn.fellinghaug.com/blog/2008/04/linux-and-internal-os-caching/#comments</comments>
		<pubDate>Sat, 19 Apr 2008 19:46:34 +0000</pubDate>
		<dc:creator>Asbjørn Alexander Fellinghaug</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[memory]]></category>

		<guid isPermaLink="false">http://asbjorn.fellinghaug.com/wp/?p=5</guid>
		<description><![CDATA[Caching inside Linux such as pages and inodes can become quite hugh, and thats the point. Linux wants to utilize all the available memory to create a faster working environment&#8230;
Now, lately I&#8217;ve been experimenting on some IR-software (http://lucene.apache.org), and for these experiments I needed to clear the internal page caching of I/O data. Basicly, whenever [...]]]></description>
			<content:encoded><![CDATA[<p>Caching inside Linux such as pages and inodes can become quite hugh, and thats the point. Linux wants to utilize all the available memory to create a faster working environment&#8230;</p>
<p>Now, lately I&#8217;ve been experimenting on some IR-software <a href="http://lucene.apache.org/">(http://lucene.apache.org)</a>, and for these experiments I needed to clear the internal page caching of I/O data. Basicly, whenever I open a file, then Linux caches that particular file, so that if I need it again later on, it will be available in &#8220;no-time&#8221;. For my experiments, I needed a &#8220;clean&#8221; cache for every run, and therefor needed to clear my cache.</p>
<p>After some Googling I stumbled upon this site:  <a href="http://linux-mm.org/Drop_Caches">http://linux-mm.org/Drop_Caches</a>. There was a lot of interessting stuff there, so I would recommend people to read it.</p>
<p>Basically, whenever you need to <em>uncache</em> something in your computer, you can (in Linux that is), write the following in a terminal:</p>
<p>This one below will free pagecache:</p>
<div class="code">
# echo 1 > /proc/sys/vm/drop_caches
</div>
<p>This one below will free dentries and inodes:</p>
<div class="code">
# echo 2 > /proc/sys/vm/drop_caches
</div>
<p>This one below will free both pagecache, dentries and inodes:</p>
<div class="code">
# echo 3 > /proc/sys/vm/drop_caches
</div>
]]></content:encoded>
			<wfw:commentRss>http://asbjorn.fellinghaug.com/blog/2008/04/linux-and-internal-os-caching/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
