<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Moiristo's Weblog</title>
	<atom:link href="http://moiristo.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://moiristo.wordpress.com</link>
	<description>We can't stop here, this is bat country!</description>
	<lastBuildDate>Thu, 12 Jan 2012 23:15:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='moiristo.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Moiristo's Weblog</title>
		<link>http://moiristo.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://moiristo.wordpress.com/osd.xml" title="Moiristo&#039;s Weblog" />
	<atom:link rel='hub' href='http://moiristo.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Gem: settler</title>
		<link>http://moiristo.wordpress.com/2010/09/30/gem-settler/</link>
		<comments>http://moiristo.wordpress.com/2010/09/30/gem-settler/#comments</comments>
		<pubDate>Thu, 30 Sep 2010 11:34:26 +0000</pubDate>
		<dc:creator>moiristo</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://moiristo.wordpress.com/?p=176</guid>
		<description><![CDATA[Link to source code: http://github.com/moiristo/settler Settler can be used for defining application wide settings in Rails. Settings are loaded from a YAML file and stored in the database using ActiveRecord to allow users to update settings on the fly. The YAML configuration allows you to not only specify defaults, but setting value validations and typecasts [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=176&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Link to source code: <a href="http://github.com/moiristo/settler">http://github.com/moiristo/settler</a></p>
<p>Settler can be used for defining application wide settings in Rails. Settings are loaded from a YAML file and stored in the database using ActiveRecord to allow users to update settings on the fly. The YAML configuration allows you to not only specify defaults, but setting value validations and typecasts as well!</p>
<p>Settler originated out of fact that I found that some common features were missing from to existing solutions like binarylogic&#8217;s settingslogic and Squeegy&#8217;s rails-settings:</p>
<ul>
<li>I was looking for something that would enable me to define settings in a file, but could be updated afterwards by users of a given system.</li>
<li>I wanted to enable users to change settings and therefore had to make sure that these changes would be valid. It should therefore be possible to add validations to settings.</li>
<li>Instead of being a simple key-value store, I did not want to cast a setting to its appropriate type (string, bool, integer or float) every time I used a certain setting. The configuration should therefore allow me to specify the data type of the setting, which should be properly typecasted every time I used it. </li>
</ul>
<p>As I found that the aforementioned gems had their own strengths, I decided to use their functionality and combine it into one gem. The added value comes with the validation and typecasting functionality. Please see the Github project page for more info!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moiristo.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moiristo.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moiristo.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moiristo.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moiristo.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moiristo.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moiristo.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moiristo.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moiristo.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moiristo.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moiristo.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moiristo.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moiristo.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moiristo.wordpress.com/176/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=176&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moiristo.wordpress.com/2010/09/30/gem-settler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">moiristo</media:title>
		</media:content>
	</item>
		<item>
		<title>Gem: dynamic_attributes</title>
		<link>http://moiristo.wordpress.com/2010/09/30/gem-dynamic_attributes/</link>
		<comments>http://moiristo.wordpress.com/2010/09/30/gem-dynamic_attributes/#comments</comments>
		<pubDate>Thu, 30 Sep 2010 11:22:22 +0000</pubDate>
		<dc:creator>moiristo</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://moiristo.wordpress.com/?p=167</guid>
		<description><![CDATA[Link to source code: http://github.com/moiristo/dynamic_attributes dynamic_attributes is a gem that lets you dynamically specify attributes on ActiveRecord models, which will be serialized and deserialized to a given text column. Think of it as having some document-database functionality in Rails while just using a relational database. Example: I used this gem in our CMS to add [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=167&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Link to source code: <a href="http://github.com/moiristo/dynamic_attributes">http://github.com/moiristo/dynamic_attributes</a></p>
<p>dynamic_attributes is a gem that lets you dynamically specify attributes on ActiveRecord models, which will be serialized and deserialized to a given text column. Think of it as having some document-database functionality in Rails while just using a relational database.</p>
<p>Example:<br />
<pre class="brush: ruby; wrap-lines: false;">
    &gt;&gt; dm = DynamicModel.new(:field_test =&gt; 'I am a dynamic attribute')
      +-------+-------------+--------------------------------------------+
      | title | description | dynamic_attributes                         |
      +-------+-------------+--------------------------------------------+
      |       |             | {&quot;field_test&quot;=&gt;&quot;I am a dynamic_attribute&quot;} |
      +-------+-------------+--------------------------------------------+
    &gt;&gt; dm.field_test
      =&gt; &quot;I am a dynamic_attribute&quot;
    &gt;&gt; dm.field_test2
      NoMethodError: undefined method `field_test2'
    &gt;&gt; dm.field_test2 = 'I am too!'
      =&gt; 'I am too!'
    &gt;&gt; dm.field_test2
      =&gt; 'I am too!'
    &gt;&gt; dm.save
      +-------+-------------+------------------------------------------------------------------------+
      | title | description | dynamic_attributes                                                     |
      +-------+-------------+------------------------------------------------------------------------+
      |       |             | {&quot;field_test2&quot;=&gt;&quot;I am too!&quot;, &quot;field_test&quot;=&gt;&quot;I am a dynamic_attribute&quot;} |
      +-------+-------------+------------------------------------------------------------------------+
</pre></p>
<p>I used this gem in our CMS to add non-standard attributes to upcoming events. Events usually have a start time, location and description, but some events needed some more attributes, like the name of the presenter or a case number. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moiristo.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moiristo.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moiristo.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moiristo.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moiristo.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moiristo.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moiristo.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moiristo.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moiristo.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moiristo.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moiristo.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moiristo.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moiristo.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moiristo.wordpress.com/167/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=167&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moiristo.wordpress.com/2010/09/30/gem-dynamic_attributes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">moiristo</media:title>
		</media:content>
	</item>
		<item>
		<title>Github</title>
		<link>http://moiristo.wordpress.com/2010/09/30/github/</link>
		<comments>http://moiristo.wordpress.com/2010/09/30/github/#comments</comments>
		<pubDate>Thu, 30 Sep 2010 11:06:55 +0000</pubDate>
		<dc:creator>moiristo</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://moiristo.wordpress.com/?p=163</guid>
		<description><![CDATA[Please check out my github account to see what I&#8217;ve been working on lately!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=163&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Please check out my <a href="http://github.com/moiristo">github account</a> to see what I&#8217;ve been working on lately!  </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moiristo.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moiristo.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moiristo.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moiristo.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moiristo.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moiristo.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moiristo.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moiristo.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moiristo.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moiristo.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moiristo.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moiristo.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moiristo.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moiristo.wordpress.com/163/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=163&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moiristo.wordpress.com/2010/09/30/github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">moiristo</media:title>
		</media:content>
	</item>
		<item>
		<title>YubNub for Safari using GlimmerBlocker</title>
		<link>http://moiristo.wordpress.com/2010/01/17/yubnub-for-safari-using-glimmerblocker/</link>
		<comments>http://moiristo.wordpress.com/2010/01/17/yubnub-for-safari-using-glimmerblocker/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 22:39:32 +0000</pubDate>
		<dc:creator>moiristo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[glimmerblocker]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[yubnub]]></category>

		<guid isPermaLink="false">http://moiristo.wordpress.com/?p=142</guid>
		<description><![CDATA[Just recently I found out about YubNub by watching Remi&#8217;s screencast, which was listed on Learnivore. However, none of the installation instructions listed for Safari seemed to work on my machine (Snow Leopard, Safari4). A cool program that acts as a HTTP proxy for Safari is called GlimmerBlocker. Besides being a great adblocker, it supports [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=142&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just recently I found out about <a href="http://www.yubnub.org/">YubNub</a> by watching <a href="http://www.learnivore.com/show/yubnub-a-social-command-line-for-the-web--922">Remi&#8217;s screencast</a>, which was listed on <a href="http://www.learnivore.com/">Learnivore</a>. However, none of the installation instructions listed for Safari seemed to work on my machine (Snow Leopard, Safari4). </p>
<p>A cool program that acts as a HTTP proxy for Safari is called <a href="http://glimmerblocker.org/">GlimmerBlocker</a>. Besides being a great adblocker, it supports keyword handling by passing the text entered in the Safari address bar through a list of filters. Some keywords that are common to Yubnub users are already defined, like for example &#8216;gim&#8217; for google image search or &#8216;y&#8217; for a Yahoo search. </p>
<p>It was an easy step to add a new filter that passes commands to Yubnub instead. This is by far the most elegant solution I found to have Yubnub integration into Safari that <em>doesn&#8217;t hack</em> Safari and works for <em>any version</em> of Safari. </p>
<h2>Installation</h2>
<p>The installation consists of installing GlimmerBlocker and defining one simple filter. Here are the steps to take:</p>
<ul>
<li>Download and install <a href="http://glimmerblocker.org/">GlimmerBlocker</a></li>
<li>Go to the GlimmerBlocker Preferences Pane (listed in the &#8216;Other&#8217; section of your System Preferences</li>
<li>Check &#8216;Activate GlimmerBlocker&#8217; in the Setup tab</li>
<li>Go to the Filters tab and create a new filter. Name the new filter &#8216;YubNub&#8217;</li>
<li>Select the new filter by clicking on the name and enable it by checking the checkbox next to it</li>
<li>In the bottom part of the pane, create a new rule (<strong>OR</strong> paste the rule XML described in the next paragraph!). Get it to look like the following screenshot:<br />
<a href="http://moiristo.files.wordpress.com/2010/01/screen-shot-2010-01-17-at-23-22-11.png"><img src="http://moiristo.files.wordpress.com/2010/01/screen-shot-2010-01-17-at-23-22-11.png?w=497" alt="" title="GlimmerBlocker YubNub rule configuration"  class="alignnone size-full wp-image-143" /></a><br />
The keyword used is &#8216;.*&#8217; (dot star), meaning that this will handle any keyword that is detected. Since it will accept <em>any</em> keyword, the priority of the rule is the lowest to give precedence to rules with more specific keywords.
</li>
<li>On the &#8216;expansion&#8217; tab, which appears when &#8216;Use javascript expansion&#8217; is selected in the previous pane, copy-paste the following script:<br />
<code>gb.url = "http://www.yubnub.org/parser/parse?command=" + gb.keyword + "+" + gb.encodedTerm;</code>. It should now look like this:<br />
<a href="http://moiristo.files.wordpress.com/2010/01/screen-shot-2010-01-17-at-23-32-06.png"><img src="http://moiristo.files.wordpress.com/2010/01/screen-shot-2010-01-17-at-23-32-06.png?w=497" alt="" title="Screen shot 2010-01-17 at 23.32.06"  class="alignnone size-full wp-image-148" /></a>
</li>
<li>Save the rule.</li>
<li>Try it out by entering some YubNub commands in the Safari address bar! Safari doesn&#8217;t have to be restarted for new rules to be applied, so you can tinker with it very easily. Check out the <a href="http://www.yubnub.org/">YubNub website</a> for some example commands!</li>
</ul>
<h2>YubNub Rule XML</h2>
<p>A really cool feature of GlimmerBlocker is that rules can be shared. By pasting the following XML into the rules table of the YubNub filter, you can skip all rule configuration steps described above!</p>
<p><pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;glimmerblocker-rules&gt;
    &lt;rule priority=&quot;1&quot; type=&quot;keyword&quot; keyword=&quot;.*&quot; keyword-type=&quot;regexp&quot;&gt;
        &lt;comments&gt;&lt;![CDATA[Send YubNub commands]]&gt;&lt;/comments&gt;
        &lt;keyword language=&quot;js&quot; version=&quot;1&quot; keyword-uses-js=&quot;1&quot;&gt;&lt;![CDATA[gb.url = &quot;http://www.yubnub.org/parser/parse?command=&quot; + gb.keyword + &quot;+&quot; + gb.encodedTerm;]]&gt;&lt;/keyword&gt;
    &lt;/rule&gt;
&lt;/glimmerblocker-rules&gt;
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moiristo.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moiristo.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moiristo.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moiristo.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moiristo.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moiristo.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moiristo.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moiristo.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moiristo.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moiristo.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moiristo.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moiristo.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moiristo.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moiristo.wordpress.com/142/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=142&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moiristo.wordpress.com/2010/01/17/yubnub-for-safari-using-glimmerblocker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">moiristo</media:title>
		</media:content>

		<media:content url="http://moiristo.files.wordpress.com/2010/01/screen-shot-2010-01-17-at-23-22-11.png" medium="image">
			<media:title type="html">GlimmerBlocker YubNub rule configuration</media:title>
		</media:content>

		<media:content url="http://moiristo.files.wordpress.com/2010/01/screen-shot-2010-01-17-at-23-32-06.png" medium="image">
			<media:title type="html">Screen shot 2010-01-17 at 23.32.06</media:title>
		</media:content>
	</item>
		<item>
		<title>Samba: Logging User Activity</title>
		<link>http://moiristo.wordpress.com/2009/08/10/samba-logging-user-activity/</link>
		<comments>http://moiristo.wordpress.com/2009/08/10/samba-logging-user-activity/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 10:52:35 +0000</pubDate>
		<dc:creator>moiristo</dc:creator>
				<category><![CDATA[samba]]></category>
		<category><![CDATA[activity]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[monitoring]]></category>

		<guid isPermaLink="false">http://moiristo.wordpress.com/?p=127</guid>
		<description><![CDATA[Ever wondered why Samba seems to log so many things, except what you&#8217;re interested in? So did I, and it took me a while to find out that 1) there actually is a solution and 2) how to configure this. Here&#8217;s how. The solution to logging what a user is actually doing can be achieved [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=127&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ever wondered why Samba seems to log so many things, except what you&#8217;re interested in? So did I, and it took me a while to find out that 1) there actually is a solution and 2) how to configure this. Here&#8217;s how.</p>
<p>The solution to logging what a user is actually doing can be achieved with <a href="http://us5.samba.org/samba/docs/man/Samba-HOWTO-Collection/VFS.html">Stackable VFS Modules</a>, which is available since Samba 3. Unfortunately, the link there does not describe the <code>full_audit</code> module, which I highly recommend using instead of <code>audit </code> or <code>extd_audit</code>. The reason for this is that I couldn&#8217;t get those modules to log simple things like a file upload by a user, unless I chose VFS log level 10.</p>
<h2>Using the Full_audit VFS Module</h2>
<p>If you&#8217;re running Debian unstable like I do, then <a href="http://www.z4.cn/kit/man?command=vfs_full_audit">full_audit</a> is included when installed from the APT. To find out which modules you have, take a look in <code>/usr/lib/samba/vfs</code>. When you&#8217;re sure you have the module, configure it as follows in <code>smb.conf</code>:</p>
<p><pre class="brush: bash;">
    vfs objects = full_audit

    full_audit:prefix = %u|%I|%m|%S
    full_audit:success = mkdir rename unlink rmdir pwrite
    full_audit:failure = none
    full_audit:facility = LOCAL7
    full_audit:priority = NOTICE
</pre></p>
<p>Let&#8217;s go through it one line at a time.</p>
<ul>
<li><code>vfs objects</code>: we&#8217;d like to use the full_audit module. </li>
<li><code>full_audit:prefix</code>: Every line that full_audit outputs will be prefixed by this line, in which you can use <a href="http://www.faqs.org/docs/samba/ch06.html#samba2-CHP-6-TABLE-2">Samba variables</a>. This line will prefix the username, IP, machine name and share name, separated by pipes.</li>
<li><code>full_audit:success</code>: This specifies which actions will actually be logged when it has successfully been completed. <code>unlink</code> is in this case a delete action and <code>pwrite</code> is an upload action.</li>
<li><code>full_audit:failure</code>: Specifies which actions should be logged, but which have resulted in a failure. Since a failure will often mean that nothing has been changed, I found that it is not interesting to log any of these actions.</li>
<li><code>full_audit:facility</code>: By default, full_audit will only write to the system syslog, but you can specify a different &#8216;syslog facility&#8217; to write all output to a different log file. Custom syslog facilities should be named <code>local[number]</code>, where <code>number</code> is a number between 0 and 7 (don&#8217;t ask me why syslogd doesn&#8217;t support any name). I&#8217;ll get back on this later.</li>
<li><code>full_audit:priority</code>: This line sets the severity of the log messages that are generated, like &#8216;notice&#8217;, &#8216;info&#8217;, &#8216;warning&#8217;, &#8216;debug&#8217;, &#8216;alert&#8217;. There are probably more, but these are the most well-known ones.</li>
</ul>
<h2>Creating a Syslogd Facility</h2>
<p>To specify a custom log file to which full_audit should write, you should create a new syslogd facility. A facility can be described in <a href="http://linux.die.net/man/5/syslog.conf">syslog.conf</a>. Since I had chosen the facility <code>local7</code>, I can add that facility to the configuration like this:</p>
<p><pre class="brush: bash;">
local7.*                        /var/log/samba/log.audit
</pre></p>
<p>This line means that all log messages of facility <code>local7</code> will be written to <code>/var/log/samba/log.audit</code>. The star is needed to say that I&#8217;d like to log messages of any severity to the same log file. Finally, restart the <code>syslogd</code> daemon: <code>/etc/init.d/sysklogd restart<br />
</code></p>
<h2>Final Words</h2>
<ul>
<li>When things don&#8217;t seem to be working, ensure you have restarted/reloaded syslogd and samba.</li>
<li>If there is anything bad you could say about full_audit, then it would be that it can&#8217;t output log messages to the log file specified in smb.conf. I always found it very useful that Samba could log by machine name by specifying <code>log file = /var/log/samba/log.%m</code>, but full_audit cannot use this. If you find a way though, please let me know!</li>
<li>Other references: A blog in a language I can&#8217;t read where I took the configuration part from: <a href="http://kannyd.multiply.com/journal/item/48/Monitoring_Aktivitas_Samba">Monitoring Aktivitas Samba</a></li>
</ul>
<h2>Output Example</h2>
<p>Here is an example of what the configuration just explained generates:</p>
<p><pre class="brush: bash;">
Aug 10 11:52:52 rhino smbd_audit: moiristo|123.45.67.89|moiristo|moiristo|unlink|ok|public/Upload/hypnotoad.gif
Aug 10 11:52:59 rhino smbd_audit: moiristo|123.45.67.89|moiristo|moiristo|pwrite|ok|public/Upload/hypnotoad.gif
Aug 10 11:53:41 rhino smbd_audit: moiristo|123.45.67.89|moiristo|moiristo|rename|ok|public/Upload/hypnotoad.gif|public/Upload/hypnotoads.gif
Aug 10 11:53:51 rhino smbd_audit: moiristo|123.45.67.89|moiristo|moiristo|rename|ok|public/Upload/hypnotoads.gif|public/Upload/hypnotoad.gif
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moiristo.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moiristo.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moiristo.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moiristo.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moiristo.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moiristo.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moiristo.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moiristo.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moiristo.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moiristo.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moiristo.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moiristo.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moiristo.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moiristo.wordpress.com/127/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=127&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moiristo.wordpress.com/2009/08/10/samba-logging-user-activity/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">moiristo</media:title>
		</media:content>
	</item>
		<item>
		<title>Ruby: Checking if a string is all letters</title>
		<link>http://moiristo.wordpress.com/2009/06/04/ruby-checking-if-a-string-is-all-letters/</link>
		<comments>http://moiristo.wordpress.com/2009/06/04/ruby-checking-if-a-string-is-all-letters/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 12:07:06 +0000</pubDate>
		<dc:creator>moiristo</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[ruby string letters]]></category>

		<guid isPermaLink="false">http://moiristo.wordpress.com/?p=115</guid>
		<description><![CDATA[Looking at the stats on my previous post, I noticed a lot of people are wrongly redirected when they&#8217;re looking for a solution to check if a ruby string is all letters. For those, I&#8217;d like to post my solution, which is imo a clean way of doing it: Analogous, we can do this with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=115&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Looking at the stats on my previous post, I noticed a lot of people are wrongly redirected when they&#8217;re looking for a solution to check if a ruby string is all letters. For those, I&#8217;d like to post my solution, which is imo a clean way of doing it:</p>
<p><pre class="brush: ruby;">
def all_letters(str)
	# Use 'str[/[a-zA-Z]*/] == str' to let all_letters
	# yield true for the empty string
	str[/[a-zA-Z]+/]  == str
end
</pre></p>
<p>Analogous, we can do this with digits as well:</p>
<p><pre class="brush: ruby;">
def all_digits(str)
	str[/[0-9]+/]  == str
end

def all_letters_or_digits(str)
	str[/[a-zA-Z0-9]+/]  == str
end
</pre></p>
<p>Of course, it&#8217;s even better if you make these methods a core extension of String itself <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moiristo.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moiristo.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moiristo.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moiristo.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moiristo.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moiristo.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moiristo.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moiristo.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moiristo.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moiristo.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moiristo.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moiristo.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moiristo.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moiristo.wordpress.com/115/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=115&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moiristo.wordpress.com/2009/06/04/ruby-checking-if-a-string-is-all-letters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">moiristo</media:title>
		</media:content>
	</item>
		<item>
		<title>Successor: Ruby String.succ For Java</title>
		<link>http://moiristo.wordpress.com/2009/05/26/successor-ruby-stringsucc-for-java/</link>
		<comments>http://moiristo.wordpress.com/2009/05/26/successor-ruby-stringsucc-for-java/#comments</comments>
		<pubDate>Tue, 26 May 2009 09:23:47 +0000</pubDate>
		<dc:creator>moiristo</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[lexicographic]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[successor]]></category>

		<guid isPermaLink="false">http://moiristo.wordpress.com/?p=105</guid>
		<description><![CDATA[For my master thesis I&#8217;m working on a Java application that should allow you to specify string intervals. A string interval can be specified by defining a start string and an end string, from which the system should be able to generate a list of successive strings in lexicographical order. Knowing of the function string.succ [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=105&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For my master thesis I&#8217;m working on a Java application that should allow you to specify string intervals. A string interval can be specified by defining a start string and an end string, from which the system should be able to generate a list of successive strings in lexicographical order. </p>
<p>Knowing of the function string.succ in Ruby and the ability to specify string ranges, I figured that something similar would also exist in Java. After browsing the webs for hours, I didn&#8217;t find anything however. Moreover, even C# with all its extra convenience methods doesn&#8217;t come with this (see also Mack Allen&#8217;s post <a href="http://allen-mack.blogspot.com/2008/07/c-succ.html">here</a>)! </p>
<p>The code below is my stab at creating string.succ in Java. It (mostly) does exactly the same thing as the Ruby version. Mostly I say, try for example the range <code>("test1".."test10")</code> in irb and <code>Successor.range("test1","test10",false)</code> in a java console. </p>
<p>See the <code>main()</code> function for examples! </p>
<p>Update 5-6-2009: Made it a lot shorter by getting rid of the helper classes, which turned out to be overkill.</p>
<p><pre class="brush: java;">
/** 
 * Successor.java: A utility class for generating string successors.
 *
 * Copyright (c) 2009, R de Lange
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
import java.util.*;
import java.io.*;

/**
* The Successor utility class can be used to find string successors or
* to generate lists of successive strings.
* 
* @author    R de Lange
* @created   June 5, 2009
*/
public class Successor {
	
	/**
	*	Main class to test Successor. Examples taken from Ruby string#succ.
	*	
	*	Call						should yield
	*	Successor.succ(&quot;abcd&quot;)      #=&gt; &quot;abce&quot;
	*	Successor.succ(&quot;THX1138&quot;)   #=&gt; &quot;THX1139&quot;
	*	Successor.succ(&quot;&lt;&lt;koala&gt;&gt;&quot;) #=&gt; &quot;&lt;&lt;koalb&gt;&gt;&quot;
	*	Successor.succ(&quot;1999zzz&quot;)   #=&gt; &quot;2000aaa&quot;
	*	Successor.succ(&quot;ZZZ9999&quot;)   #=&gt; &quot;AAAA0000&quot;
	*	Successor.succ(&quot;***&quot;)       #=&gt; &quot;**+&quot;
	*
	*	- For an interactive console interface for testing Successor.succ(str), specify the -i argument
	*	- To test successor ranges using Successor.range(str), specify the -r argument. Adding an arbitrary 
	*	extra argument (e.g. -r e) will toggle the 'exclusive' boolean for successor ranges.
	*/	
	public static void main(String[] args) throws Exception{
		if(args.length == 0){
			System.out.println(&quot;Running Successor examples...&quot;);
			System.out.println(&quot;abcd #=&gt; &quot; + Successor.succ(&quot;abcd&quot;));
			System.out.println(&quot;THX1138 #=&gt; &quot; + Successor.succ(&quot;THX1138&quot;));
			System.out.println(&quot;&lt;&lt;koala&gt;&gt; #=&gt; &quot; + Successor.succ(&quot;&lt;&lt;koala&gt;&gt;&quot;));
			System.out.println(&quot;1999zzz #=&gt; &quot; + Successor.succ(&quot;1999zzz&quot;));
			System.out.println(&quot;ZZZ9999 #=&gt; &quot; + Successor.succ(&quot;ZZZ9999&quot;));
			System.out.println(&quot;*** #=&gt; &quot; + Successor.succ(&quot;***&quot;));			
		}
		else {
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));				
			String command = args[0];
			if(command.equals(&quot;-i&quot;)) {
				String line = &quot;&quot;;
				while(!line.equals(&quot;quit&quot;)){
					System.out.print(&quot;String? &quot;);
					line = in.readLine();
					if(!line.equals(&quot;quit&quot;)) System.out.println(Successor.succ(line));
				}	
			}
			else if(command.equals(&quot;-r&quot;)) {
				String left = &quot;&quot;, right=&quot;&quot;;
				while(true){
					System.out.print(&quot;Left? &quot;);
					left = in.readLine();
					System.out.print(&quot;Right? &quot;);
					right = in.readLine();
					System.out.println(Arrays.deepToString(Successor.range(left, right, args.length == 2).toArray()));
				}	
			}				
		}
	}
	
	/**
	* Returns the successor to str. The successor is calculated by incrementing characters starting from the rightmost 
	* alphanumeric (or the rightmost character if there are no alphanumerics) in the string. Incrementing a digit always 
	* results in another digit, and incrementing a letter results in another letter of the same case. Incrementing 
	* nonalphanumerics uses the system default character set's collating sequence. If the increment generates a 'carry', 
	* the character to the left of it is incremented. This process repeats until there is no carry, adding an additional 
	* character if necessary. 
	*/
	public static String succ(String str){
		char[] cstr = str.toCharArray();
		if(cstr.length == 0) return &quot;&quot;;
		
		int letterOrDigitIndex = getLastLetterOrDigitIndex(cstr, cstr.length-1);	
		if(letterOrDigitIndex &gt;= 0)
			return alphanumSucc(cstr, letterOrDigitIndex);
		else {
            // Increment rightmost character
            cstr[cstr.length-1] = (char) (cstr[cstr.length-1] + 1);
            return new String(cstr);
        }
	}
	
	/**
	* Alias of Successor.succ(str)
	*/
	public static String next(String str){ return Successor.succ(str); }
	
	/**
	* Returns a range of string successors as a list. Starting from str1, this method will add all successors	
	* to a list until the successor string equals str2. If the 'exclusive' boolean is true, str2 will be included
	* in the resulting list, otherwise excluded. If the successor str2 is not found after generating half a million
	* successors, the range is assumed to be invalid, in which case it will return an empty list.
	*/
	public static List&lt;String&gt; range(String str1, String str2, boolean exclusive){
		int counter, limit = 500000;
		ArrayList&lt;String&gt; result = new ArrayList&lt;String&gt;();
		
		result.add(str1);
		String currentSuccessor = str1;
		for(counter = 0;counter&lt;=limit &amp;&amp; !currentSuccessor.equals(str2); counter++){
			currentSuccessor = Successor.succ(currentSuccessor);
			if((currentSuccessor.equals(str2) &amp;&amp; !exclusive)|| !currentSuccessor.equals(str2)) 
				result.add(currentSuccessor);
		}
		if(counter &gt; limit) {
			System.err.println(&quot;Range could not be created, level too deep.&quot;);
			result.clear();
		}
		return result;	
	}
	
	/**
	* Calculates the successive string for strings that contain alphanumeric characters. 
	* See the description of Successor.succ(str) for more informtionon this function
	*/
	private static String alphanumSucc(char[] cstr, int lastLetterOrDigitIndex){
		char succ = charSucc(cstr[lastLetterOrDigitIndex]);

		int currentIndex = lastLetterOrDigitIndex;
        cstr[currentIndex] = succ;
		
		// Loop while we have a carry
		while(succHasCarry(succ) &amp;&amp; lastLetterOrDigitIndex &gt;= 0){
			lastLetterOrDigitIndex = getLastLetterOrDigitIndex(cstr, lastLetterOrDigitIndex-1);		
			if(lastLetterOrDigitIndex &gt;= 0) {
				currentIndex = lastLetterOrDigitIndex;
				succ = charSucc(cstr[currentIndex]);
				cstr[currentIndex] = succ;
			}
		}

		// Check if we still have a carry left
		if(succHasCarry(succ)) cstr = insertCarry(cstr, succ, currentIndex);
		
		// Finished!
		return new String(cstr);
	}
	
	/**
	* Create a new array in which the given carry is inserted at the given index
	* @return A new char array of length cstr.length+1, which contains all values of
	* cstr + the carry char inserted at the given index.
	*/
	private static char[] insertCarry(char[] cstr, char carry, int index){
		char[] result = new char[cstr.length+1];
		System.arraycopy(cstr,0,result,0,index+1);
		result[index] = carry;
		System.arraycopy(cstr,index,result,index+1,cstr.length);
		return result;
	}
	
	/**
	* Determines whether the given char array contains alphanumeric characters
	* @return the highest index at which an alphanumeric character can be found, or -1 if none were found 
	*/
	private static int getLastLetterOrDigitIndex(char[] cstr, int lastIndex){
		int result = -1;
		for(int i=lastIndex;i&gt;=0 &amp;&amp; result &lt; 0;i--) {
			if(Character.isLetterOrDigit(cstr[i])) result = i;
		}
		return result;
	}

    /**
     * Determines if a given *successor* character (returned by charSucc(char c)) is a
     * character with a carry.
     *
     * @param c - the successor char
     * @return true if c is '0', 'a' or 'A'.
     */
    private static boolean succHasCarry(char c){
        return c == '0' || c == 'a' || c == 'A';
    }

    /**
     * Determines the successor of the given char
     * @param c - the char
     * @return the successor of char c
     */
    private static char charSucc(char c) {
        char result;

        switch(c) {
            case '9': result = '0'; break;
            case 'z': result = 'a'; break;
            case 'Z': result = 'A'; break;
            default: result = (char) (c + 1);
        }

        return result;
    }
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moiristo.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moiristo.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moiristo.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moiristo.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moiristo.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moiristo.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moiristo.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moiristo.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moiristo.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moiristo.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moiristo.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moiristo.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moiristo.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moiristo.wordpress.com/105/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=105&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moiristo.wordpress.com/2009/05/26/successor-ruby-stringsucc-for-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">moiristo</media:title>
		</media:content>
	</item>
		<item>
		<title>Executing smbstatus as non-root user</title>
		<link>http://moiristo.wordpress.com/2009/02/16/executing-smbstatus-as-non-root-user/</link>
		<comments>http://moiristo.wordpress.com/2009/02/16/executing-smbstatus-as-non-root-user/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 22:58:45 +0000</pubDate>
		<dc:creator>moiristo</dc:creator>
				<category><![CDATA[samba]]></category>
		<category><![CDATA[smb]]></category>

		<guid isPermaLink="false">http://moiristo.wordpress.com/?p=95</guid>
		<description><![CDATA[I found that after upgrading to samba 3 (Debian 2.6.15 unstable), I was unable to execute smbstatus as a non-root user. This was very inconvenient, since I was using a PHP script to track which users are connected to my server (see my previous post). The error that occurs looks as follows: ERROR: Failed to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=95&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I found that after upgrading to samba 3 (Debian 2.6.15 unstable), I was unable to execute <code>smbstatus</code> as a non-root user. This was very inconvenient, since I was using a PHP script to track which users are connected to my server (see my previous post). The error that occurs looks as follows:<br />
<code><br />
ERROR: Failed to initialise messages database: Permission denied<br />
messaging_tdb_init failed: NT_STATUS_ACCESS_DENIED<br />
messaging_init failed<br />
</code></p>
<p>Making <code>smbstatus</code> suid root unfortunately didn&#8217;t do the trick. Taking a closer look at the error suggested that it got to do with the *.tdb files that samba is using. So, I went to the folder containing these files (for me <code>/var/run/samba/*.tdb</code>). All these database files were chmodded to 644, so only enabled rw permissions to root. </p>
<p>By changing the permissions of <code>messages.tdb</code> to 666 (rw permissions on world, if you find this to devil-ish, 646 would also do the trick <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ) a normal user can also open the database file and thus everything worked again. Of course, you should keep in mind that this may pose a security risk.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moiristo.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moiristo.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moiristo.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moiristo.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moiristo.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moiristo.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moiristo.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moiristo.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moiristo.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moiristo.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moiristo.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moiristo.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moiristo.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moiristo.wordpress.com/95/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=95&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moiristo.wordpress.com/2009/02/16/executing-smbstatus-as-non-root-user/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">moiristo</media:title>
		</media:content>
	</item>
		<item>
		<title>Monitoring Samba from a web page using smbstatus</title>
		<link>http://moiristo.wordpress.com/2008/12/14/monitoring-samba-using-smbstatus/</link>
		<comments>http://moiristo.wordpress.com/2008/12/14/monitoring-samba-using-smbstatus/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 12:22:11 +0000</pubDate>
		<dc:creator>moiristo</dc:creator>
				<category><![CDATA[samba]]></category>
		<category><![CDATA[monitor]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[smbstatus]]></category>

		<guid isPermaLink="false">http://moiristo.wordpress.com/?p=77</guid>
		<description><![CDATA[A long time ago, I found that I needed something to be able to see which users are logged in using samba and kick users as necessary. The usual way is to check the currently logged in users using smbstatus and kicking users by killing the smb process belonging to a user. To make this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=77&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A long time ago, I found that I needed something to be able to see which users are logged in using samba and kick users as necessary. The usual way is to check the currently logged in users using smbstatus and kicking users by killing the smb process belonging to a user. To make this a bit easier, I made a small webpage in *cough*PHP*cough*. Hey, it was 2 years ago! <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Anyway, I still find it very useful, so maybe it&#8217;s useful to you, too.</p>
<p><pre class="brush: php;">
&lt;?
error_reporting(0);

if(isset($_GET['kill'])){
	echo shell_exec(&quot;sudo /scripts/smbkill &quot;.$_GET['kill'].&quot; 2&gt;&amp;1&quot;);
	}

exec(&quot;smbstatus -S&quot;,$log);
exec(&quot;smbstatus -L&quot;,$lock);

$pid_us = array();
for($i=3;$i&lt;sizeof($log);$i++)
	if(!trim($log[$i])==&quot;&quot;) {
		$users[] = split(&quot;[ ]+&quot;,$log[$i],4);
		$pid_us[$users[sizeof($users)-1][1]] = $users[sizeof($users)-1][2];  
		}
for($i=3;$i&lt;sizeof($lock);$i++)
	if(!trim($lock[$i])==&quot;&quot;) {			
			$line = split(&quot;[ ]+&quot;,$lock[$i],7);
			$usr = $pid_us[$line[0]];
			if(trim($usr)==&quot;&quot;) $usr = $line[0];									
			$locks[$line[0]][] = array($line[0],$usr,substr_replace($line[6],&quot;&quot;,-25));	//Remove date (25 chars from the right
		}
	
//die(&quot;&quot;);

echo &quot;&lt;br /&gt;&quot;;
echo &quot;&lt;font style=\&quot;font-family: Verdana;\&quot;&gt;Connected users:&lt;/font&gt;\n&quot;;
echo &quot;&lt;br /&gt;&lt;br /&gt;&quot;;
echo &quot;&lt;table&gt;\n&quot;;
foreach($users as $user){
	list($service,$pid,$mach,$date) = $user;
	echo &quot;&lt;tr\n&gt;&quot;;
	echo &quot;&lt;td&gt;&lt;a onclick=\&quot;return confirm('Kick this user?');\&quot; href=\&quot;&quot;.$PHP_SELF.&quot;?kill=&quot;.$pid.&quot;\&quot;&gt;&lt;img border=\&quot;0\&quot; src=\&quot;remove.gif\&quot; /&gt;&lt;/a&gt;&lt;/td&gt;\n&quot;;
	echo &quot;&lt;td class=\&quot;user\&quot;&gt;&quot;.$mach.&quot;&lt;/td&gt;\n&quot;;
	echo &quot;&lt;td class=\&quot;pid\&quot;&gt;&quot;.$pid.&quot;&lt;/td&gt;\n&quot;;
	echo &quot;&lt;td&gt;&quot;.$service.&quot;&lt;/td&gt;\n&quot;;
	echo &quot;&lt;td&gt;&quot;.$date.&quot;&lt;/td&gt;\n&quot;;
	echo &quot;&lt;/tr&gt;\n&quot;;
}
echo &quot;&lt;/table&gt;\n\n&quot;;

echo &quot;&lt;br /&gt;&lt;br /&gt;&quot;;
echo &quot;&lt;font style=\&quot;font-family: Verdana;\&quot;&gt;Locked files:&lt;/font&gt;\n&quot;;
echo &quot;&lt;br /&gt;&lt;br /&gt;&quot;;
echo &quot;&lt;table&gt;\n&quot;;

$cuser = &quot;&quot;;
$first = true;
foreach($locks as $l){
	foreach($l as $lck){
		list($pid, $user,$file) = $lck;
		if($user != $cuser){		
			if(!$first){
				echo &quot;&lt;tr&gt;\n&quot;;
				echo &quot;&lt;td&gt;&amp;nbsp;&lt;/td&gt;\n&quot;;
				echo &quot;&lt;td&gt;&amp;nbsp;&lt;/td&gt;\n&quot;;
				echo &quot;&lt;td&gt;&amp;nbsp;&lt;/td&gt;\n&quot;;
				echo &quot;&lt;/tr&gt;\n&quot;;				
				}
			echo &quot;&lt;tr&gt;\n&quot;;			
			echo &quot;&lt;td class=\&quot;pid\&quot;&gt;&lt;a onclick=\&quot;return confirm('Kick this user?');\&quot; href=\&quot;&quot;.$PHP_SELF.&quot;?kill=&quot;.$pid.&quot;\&quot;&gt;&lt;img border=\&quot;0\&quot; src=\&quot;remove.gif\&quot; /&gt;&lt;/a&gt; &quot;.$pid.&quot;&lt;/td&gt;\n&quot;;
			echo &quot;&lt;td class=\&quot;user\&quot;&gt;&quot;.$user.&quot;&lt;/td&gt;\n&quot;;
			echo &quot;&lt;td&gt;&quot;.$file.&quot;&lt;/td&gt;\n&quot;;
			echo &quot;&lt;/tr&gt;\n&quot;;
			$cuser = $user;
			}
		else {
			echo &quot;&lt;tr&gt;\n&quot;;
			echo &quot;&lt;td&gt;&amp;nbsp;&lt;/td&gt;\n&quot;;
			echo &quot;&lt;td&gt;&amp;nbsp;&lt;/td&gt;\n&quot;;
			echo &quot;&lt;td&gt;&quot;.$file.&quot;&lt;/td&gt;\n&quot;;	
			echo &quot;&lt;/tr&gt;\n&quot;;				
			}
		$first = false;
		}
}
echo &quot;&lt;/table&gt;\n&quot;;
?&gt;
</pre></p>
<p>Note that you should of course make sure that only you are able to access the page and execute the kill command, so you&#8217;ll need to get creative with <code>sudo</code> and <code>htaccess</code> <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Image used: <img src="http://moiristo.files.wordpress.com/2008/12/remove.gif?w=497" alt="remove" title="remove"   class="alignnone size-full wp-image-85" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moiristo.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moiristo.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moiristo.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moiristo.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moiristo.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moiristo.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moiristo.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moiristo.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moiristo.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moiristo.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moiristo.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moiristo.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moiristo.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moiristo.wordpress.com/77/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=77&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moiristo.wordpress.com/2008/12/14/monitoring-samba-using-smbstatus/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">moiristo</media:title>
		</media:content>

		<media:content url="http://moiristo.files.wordpress.com/2008/12/remove.gif" medium="image">
			<media:title type="html">remove</media:title>
		</media:content>
	</item>
		<item>
		<title>Sorting IMAP Mail with Imapfilter</title>
		<link>http://moiristo.wordpress.com/2008/11/18/sorting-imap-mail-with-imapfilter/</link>
		<comments>http://moiristo.wordpress.com/2008/11/18/sorting-imap-mail-with-imapfilter/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 16:19:08 +0000</pubDate>
		<dc:creator>moiristo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[sort]]></category>

		<guid isPermaLink="false">http://moiristo.wordpress.com/?p=73</guid>
		<description><![CDATA[The situation is as follows: I have multiple IMAP mail accounts on multiple servers and access these mailboxes from multiple computers using different e-mail clients. Per mailbox, I have multiple folders that contain messages regarding a certain subject. To be sure that new mail appears in the folder it belongs to, I have set up [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=73&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The situation is as follows: I have multiple IMAP mail accounts on multiple servers and access these mailboxes from multiple computers using different e-mail clients. Per mailbox, I have multiple folders that contain messages regarding a certain subject. To be sure that new mail appears in the folder it belongs to, I have set up message filters on every e-mail client. The trouble is, for every new folder I had to alter the filters on every client. </p>
<p>As a solution, I left one computer always running with Thunderbird active, but since I already have a linux server running (terminal access only), I was thinking whether there was something available that was able to sort my messages, which I can alter from the command line and doesn&#8217;t involve a graphical frontend. </p>
<p><a href="http://imapfilter.hellug.gr/">Imapfilter</a> did the job for me. Although I don&#8217;t have any experience in Lua, in which it is written, I managed to successfully sort my mail. You can install it from source, but there is also a Debian package available from the apt (at least, from repository unstable). Below I&#8217;ll describe how I configured imapfilter, since there is not much information around on this (there are however some small examples described in a sample config file).</p>
<p>After install, first run imapfilter as a normal user. This will create the directory <code>~/.imapfilter</code> with appropriate permissions. Enter that directory and create a new file  named <code>config.lua</code>. In this file, you should first define some global options, then your IMAP accounts, followed by the filters (rules) that should be applied to the messages in your mailboxes.</p>
<p>The global options are defined in a lua table variable named <code>options</code>. A table in lua is much like a hash in Ruby. I have defined the following options:</p>
<p><pre class="brush: ruby;">
  options.timeout = 120
  options.subscribe = true
</pre></p>
<p>The meaning of these options is described on the imapfilter homepage.<br />
Definitions of IMAP accounts look like this:</p>
<p><pre class="brush: ruby;">
account1 = IMAP {
	   	server = 'imap.example.com',
		username = 'user',
		password = 'pass',
		ssl = 'ssl3'
	}

account2 = IMAP {
	   	server = 'imap2.example.com',
		username = 'user',
		password = 'pass'
	}

</pre></p>
<p>As you can see, imapfilter also supports SSL (you need to have OpenSSL installed though). You can define all your IMAP accounts like this.</p>
<p>Next, I define the sorting rules. Note that I mostly move messages from the inbox of an account to a folder of the same account. This is however not necessary, it is also possible to transfer messages from one account to the other. Example 1:</p>
<p><pre class="brush: ruby;">
   msgs = account1.INBOX:contain_from('MediaPortal')
   account1.INBOX:move_messages(account1.MediaPortal, msgs)
</pre></p>
<p>The first example is simple: find all messages in the INBOX in which the sender contains the name MediaPortal and move those messages to the MediaPortal folder.<br />
Now, a more complex example:  </p>
<p><pre class="brush: ruby;">
 msgs = 	account2.INBOX:contain_from('Cron') +
		account2.INBOX:contain_from('Log') +
		account2.INBOX:contain_subject('yum')
 account2.INBOX:mark_seen(msgs)
 account2.INBOX:move_messages(account2['Maildir/Admin Notifications'], msgs)
</pre></p>
<p>What you need to know here is that the &#8216;+&#8217; operator means &#8216;or&#8217;. So, I put all messages that are from &#8216;Cron&#8217;, &#8216;Log&#8217; or have the subject &#8216;yum&#8217; in the variable <code>msgs</code>, I mark all those messages as read and finally move them to the &#8216;Admin Notifications folder&#8217;. As you can see, this account uses the Maildir directory.</p>
<p>You can debug your configuration by running <code>imapfilter -d</code> or <code>imapfilter -v</code>. To run these rules frequently, I finally had to run this code in daemon mode. To achieve this, I had to enclose all the above code in a function and pass that function in the become_daemon() function:</p>
<p><pre class="brush: ruby;">
-- global options

function sortMail()
   -- IMAP account definitions
   -- rules
end

become_daemon(300, sortMail)
</pre></p>
<p>Note that I had to include the account definitions in the function; it seems the accounts are also initialized when defined and it wouldn&#8217;t work anymore when these definitions were outside the function. The above example will run imapfilter as a daemon and execute the sortMail function every 300 seconds.</p>
<p>UPDATE 03-02-2010: Sometimes, an error may occur while processing the messages, causing <code>imapfilter</code> to terminate. To solve this, I created a function that wraps the <code>sortMail</code> function and ensures errors are ignored:</p>
<p><pre class="brush: ruby;">
function sort_mail_and_ignore_errors()
        pcall(sort_mail())
end

daemon_mode(300, sort_mail_and_ignore_errors)
</pre></p>
<p>Some final remarks that may save you some time:</p>
<ul>
<li>There are problems selecting/searching messages when you&#8217;re running an Exchange server. I tried several things to get it working properly, but nothing worked. This could be dependent on the configuration or version of the Exchange server however.</li>
<li>Be sure you add the IMAP definitions to the function called in daemon mode</li>
<li>if you don&#8217;t know exactly which folders you have or should define, you can add some debugging code to find out:</li>
</ul>
<p><pre class="brush: ruby;">
-- Inbox information
account1.INBOX:check_status()

-- Get and print available mailboxes and folders
mailboxes, folders = account1:list_all()
table.foreach(mailboxes,print)
table.foreach(folders,print)
</pre></p>
<ul>
<li>Want to filter out spam? This can be done like this:</li>
</ul>
<p><pre class="brush: ruby;">
-- Select all messages marked as spam       
msgs = account1.INBOX:match_header('^.+MailScanner.*Check: [Ss]pam.*$')
-- Throw them away 
account1.INBOX:delete_messages(msgs)
</pre></p>
<p>Fore more information and examples, see also the imapfilter homepage: <a href="http://imapfilter.hellug.gr">http://imapfilter.hellug.gr</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moiristo.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moiristo.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moiristo.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moiristo.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moiristo.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moiristo.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moiristo.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moiristo.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moiristo.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moiristo.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moiristo.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moiristo.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moiristo.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moiristo.wordpress.com/73/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moiristo.wordpress.com&amp;blog=4269683&amp;post=73&amp;subd=moiristo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moiristo.wordpress.com/2008/11/18/sorting-imap-mail-with-imapfilter/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">moiristo</media:title>
		</media:content>
	</item>
	</channel>
</rss>
