<?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; general IT</title>
	<atom:link href="http://asbjorn.fellinghaug.com/blog/category/general-it/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>Absolute path to running C program</title>
		<link>http://asbjorn.fellinghaug.com/blog/2009/08/absolute-path-to-running-c-program/</link>
		<comments>http://asbjorn.fellinghaug.com/blog/2009/08/absolute-path-to-running-c-program/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 21:47:09 +0000</pubDate>
		<dc:creator>Asbjørn Alexander Fellinghaug</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[general IT]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[absolute path]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[hack]]></category>

		<guid isPermaLink="false">http://asbjorn.fellinghaug.com/blog/?p=235</guid>
		<description><![CDATA[One day I needed to make an embedded Python interpreter in a Fortran/C program aware of its path, since it should search for a predefined python source code file in the same directory from the binary is located.
Now, this introduces some issues, as the Fortran/C program can be runned in many ways:

Absolute path (/home/asbjorn/test1/main)
Standing in [...]]]></description>
			<content:encoded><![CDATA[<p>One day I needed to make an embedded Python interpreter in a Fortran/C program aware of its path, since it should search for a predefined python source code file in the same directory from the binary is located.</p>
<p>Now, this introduces some issues, as the Fortran/C program can be runned in many ways:</p>
<ol>
<li>Absolute path (/home/asbjorn/test1/main)</li>
<li>Standing in the directory and run ./main</li>
<li>Having the /home/asbjorn/test1/ in your $PATH variable (Linux/UNIX), and type &#8216;main&#8217;.</li>
</ol>
<p>Now, the simplest approach is to use the &#8220;int argc, char *argv[]&#8221; variables inside your &#8216;int main()&#8217; method. Then the &#8220;argv[0]&#8221; would contain the binary file name, including any absolute path if that what being used. But, if your application is in your $PATH variable, it wont work.</p>
<p>A &#8216;dirty&#8217; trick could be to use:</p>

<div class="wp_syntax"><div class="code"><pre class="c c" style="font-family:monospace;"><span style="color: #993333;">char</span> path<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#93;</span>;
path <span style="color: #339933;">=</span> system<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;which main&quot;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>but, its not recommended using this approach. Another very hackish and cool solution is the following:</p>

<div class="wp_syntax"><div class="code"><pre class="c c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdlib.h&gt;</span>
<span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;sys/param.h&gt;</span>
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span><span style="color: #339933;">*</span> argv<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   <span style="color: #993333;">char</span> path<span style="color: #009900;">&#91;</span>MAXPATHLEN<span style="color: #009900;">&#93;</span>;
   <span style="color: #993333;">int</span> length;
   length <span style="color: #339933;">=</span> readlink<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;/proc/self/exe&quot;</span><span style="color: #339933;">,</span> path<span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>path<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>length<span style="color: #339933;">&lt;</span><span style="color:#800080;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      fprintf<span style="color: #009900;">&#40;</span>stderr<span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;error resolving /proc/self/exe!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span>;
      exit<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #009900;">&#125;</span>
   path<span style="color: #009900;">&#91;</span>length<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'<span style="color: #000099; font-weight: bold;">\0</span>'</span>;
   <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;The absolute path to this running binary is: %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> path<span style="color: #009900;">&#41;</span>;
&nbsp;
   <span style="color: #b1b100;">return</span> <span style="color:#800080;">0</span>;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Another approach which is often used is to include some kind of configuration file that contains this path. Or, in my case, I could specify another folder which should hold my Python files. This approach would probably make more sense in the long run, as it is more flexible.</p>
<p>So, in case you find yourself in this situation, then feel free to copy-paste the code and save the day <img src='http://asbjorn.fellinghaug.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Have a good summer people!</p>
]]></content:encoded>
			<wfw:commentRss>http://asbjorn.fellinghaug.com/blog/2009/08/absolute-path-to-running-c-program/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<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>Make global-ignores in subversion</title>
		<link>http://asbjorn.fellinghaug.com/blog/2009/01/make-global-ignores-in-subversion/</link>
		<comments>http://asbjorn.fellinghaug.com/blog/2009/01/make-global-ignores-in-subversion/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 08:42:41 +0000</pubDate>
		<dc:creator>Asbjørn Alexander Fellinghaug</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[general IT]]></category>
		<category><![CDATA[ignores]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[svn:ignore]]></category>

		<guid isPermaLink="false">http://asbjorn.fellinghaug.com/blog/?p=190</guid>
		<description><![CDATA[Hi everyone.
Every now and then I get somewhat annoyed by the fact that I add temporary or &#8220;unwanted&#8221; files to a subversion repository. These files may be just temporary files, like *.tmp, which has no value of being kept in a repository, or compiled python files *.pyc, etc.
The common characteristics is that they are generally [...]]]></description>
			<content:encoded><![CDATA[<p>Hi everyone.</p>
<p>Every now and then I get somewhat annoyed by the fact that I add temporary or &#8220;unwanted&#8221; files to a subversion repository. These files may be just temporary files, like *.tmp, which has no value of being kept in a repository, or compiled python files *.pyc, etc.</p>
<p>The common characteristics is that they are generally unwanted, and that they can easily be removed from the SVN repository. A common approach towards this issue is to set a property named &#8220;<em>svn:ignore</em>&#8221; on a directory, or the whole directory structure. This can be achieved with this command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #007800;">$#</span> <span style="color: #c20cb9; font-weight: bold;">svn</span> propset <span style="color: #c20cb9; font-weight: bold;">svn</span>:ignore <span style="color: #ff0000;">&quot;*.tmp&quot;</span> .</pre></div></div>

<p>where the single-dot at the end signalize the standing directory. However, this must be performed for each subversion project, which can get annoying in time. I&#8217;ve recently discovered the possibility of setting global subversion settings for my own user. The per-user subversion settings file is located on $HOME/.subversion/config. In that file there is a section named &#8220;[miscellany]&#8220;, which holds a variable named &#8220;global-ignores&#8221;. This variable can hold multiple ignore statements which will apply for all the svn checkouts you may work on (given you are using this user).</p>
<p>This subversion setting file also contains many more exciting options, such as automatic properties which apply to certain files. Have a look at the end for the $HOME/.subversion/config file and notice some of the predefined settings.</p>
<p>A tip based on personal experience is to hook the current files to the global-ignores variable:</p>
<blockquote><p>
*.pyc # python byte compiled code<br />
*.swp # vim swap file<br />
*.tmp # general temp files
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://asbjorn.fellinghaug.com/blog/2009/01/make-global-ignores-in-subversion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New year resolutions</title>
		<link>http://asbjorn.fellinghaug.com/blog/2008/12/new-year-resolutions/</link>
		<comments>http://asbjorn.fellinghaug.com/blog/2008/12/new-year-resolutions/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 19:04:30 +0000</pubDate>
		<dc:creator>Asbjørn Alexander Fellinghaug</dc:creator>
				<category><![CDATA[general IT]]></category>
		<category><![CDATA[goals]]></category>
		<category><![CDATA[new year]]></category>
		<category><![CDATA[open-source]]></category>

		<guid isPermaLink="false">http://asbjorn.fellinghaug.com/blog/?p=153</guid>
		<description><![CDATA[Every year I make myself some &#8220;abstract&#8221; goals regarding some achievements I should manage to reach. However, each year there are always one or two goals which is left behind. What I would especially highlight this year is to finish some of my software projects which has just been left in the mid-air.

A simple webpage [...]]]></description>
			<content:encoded><![CDATA[<p>Every year I make myself some &#8220;abstract&#8221; goals regarding some achievements I should manage to reach. However, each year there are always one or two goals which is left behind. What I would especially highlight this year is to finish some of my software projects which has just been left in the mid-air.</p>
<ul>
<li>A simple webpage for my topdomain (fellinghaug.com)</li>
<li>My very simple, yet (hopefully) powerfull Python search engine (<em>codename &#8220;Wallace&#8221;</em>)</li>
<li>Contribute more to the open-source community (register myself as a python developer, solve bugs and translate projects on launchpad.net)</li>
</ul>
<p>Let&#8217;s now get ahead of ourselves here, and just stop the list there. Adding more would simply make it overwhelming and unrealistic. If I surprise myself in terms of the timeframe (a year) for these goals, then I would allow myself to add more stuff on this list.</p>
<p style="text-align: center;"><a href="http://asbjorn.fellinghaug.com/blog/wp-content/uploads/2008/12/dsc01009.jpg"><img class="size-medium wp-image-161 aligncenter" style="border: 1px solid black;" title="Asbjørn in london with beer googles" src="http://asbjorn.fellinghaug.com/blog/wp-content/uploads/2008/12/dsc01009-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>I would point to fellow developers out there to also make yourselves goal lists, as these lists tend to improve the developers efficiency. It certainly feels so in my case.</p>
<p><a href="http://asbjorn.fellinghaug.com/blog/wp-content/uploads/2008/12/dsc01003.jpg"><img class="alignright size-medium wp-image-158" style="border: 1px solid black;" title="My python coffe cup" src="http://asbjorn.fellinghaug.com/blog/wp-content/uploads/2008/12/dsc01003-300x225.jpg" alt="" width="300" height="225" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://asbjorn.fellinghaug.com/blog/2008/12/new-year-resolutions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>distribuering av MS Office 2007 dokumenter</title>
		<link>http://asbjorn.fellinghaug.com/blog/2008/10/distribuering-av-ms-office-2007-dokumenter/</link>
		<comments>http://asbjorn.fellinghaug.com/blog/2008/10/distribuering-av-ms-office-2007-dokumenter/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 09:42:52 +0000</pubDate>
		<dc:creator>Asbjørn Alexander Fellinghaug</dc:creator>
				<category><![CDATA[Funny]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[general IT]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[norsk]]></category>
		<category><![CDATA[odt]]></category>
		<category><![CDATA[ooxml]]></category>

		<guid isPermaLink="false">http://asbjorn.fellinghaug.com/blog/?p=98</guid>
		<description><![CDATA[Hei.
Jeg tenkte å ta for meg et voksende problem innen utveksling av dokumenter rundt omkring i Norge (og resten av verdenen). Etter at MS Office 2007 kom ut, og med det innførte et nytt filformat (docx, pptx, xlsx, ..), så har folk som tidligere har benyttet MS Office 2003/XP (og eldre) ikke vært istand til [...]]]></description>
			<content:encoded><![CDATA[<p>Hei.</p>
<p>Jeg tenkte å ta for meg et voksende problem innen utveksling av dokumenter rundt omkring i Norge (og resten av verdenen). Etter at MS Office 2007 kom ut, og med det innførte et nytt filformat (docx, pptx, xlsx, ..), så har folk som tidligere har benyttet MS Office 2003/XP (og eldre) ikke vært istand til å lese dokumentene lagret i disse formatene. Enda verre er det for de som benytter OpenOffice (et gratis verktøy av tilsvarende funksjonalitet som MS Office).</p>
<p>Så, problemet ligger i at MS Office 2007 lagrer som default alle dokumenter i disse nye formatene. Og som kjent så tenker ikke folk flest over dette, og derfor vil mesteparten av produserte dokumenter bli lagret i slike obskure formater. Det skal nevnes at formatet er svært lik OOXML (dog oppfyller den ikke helt spesifikasjonene). Uansett, dette innebærer problemer for folk som benytter andre tilsvarende programmer.</p>
<p>Jeg har selv erfart å få e-post med slike dokumenter, da jeg konsekvent svarer at formatet er ukjent for meg og at de enten skal lagre i det (gamle) &#8220;doc&#8221; formatet eller ODT (OpenDocument format for tekstbehandling), eventuelt PDF. Sistnevnte byr på problemer dersom du er avhengig av å redigere dokumentet dog.</p>
<p>Hovedpoenget er at folk må slutte å benytte formater som er svært dårlig utbredt, da de innsnevrer mulighetene for andre å lese dokumentene. Inntil det faktisk er mulig for andre enn MS Office å lese og skrive i de respektive formatene, så anbefales det <strong>sterkt </strong>å unngå dem.</p>
]]></content:encoded>
			<wfw:commentRss>http://asbjorn.fellinghaug.com/blog/2008/10/distribuering-av-ms-office-2007-dokumenter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
