<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6390279852945612246</id><updated>2012-02-16T19:31:32.542Z</updated><category term='thunderbird pst outlook convert dovecot linux'/><title type='text'>Handy Linux notes</title><subtitle type='html'>Linux notes, tips and tricks. Handy scripts and solutions to arcane problems.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://linuxblog.kieser.net/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default'/><link rel='alternate' type='text/html' href='http://linuxblog.kieser.net/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Bradley Kieser</name><uri>http://www.blogger.com/profile/10723853755510927711</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://1.bp.blogspot.com/_iZ-YXgCJsC8/S1YnFCicyiI/AAAAAAAAAK4/t-ix9xqqeXc/S220/brad_smaller.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>15</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6390279852945612246.post-8577373406252943812</id><published>2010-09-16T16:35:00.000+01:00</published><updated>2010-09-16T16:35:57.465+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='thunderbird pst outlook convert dovecot linux'/><title type='text'>Converting PST files to Linux MBOX format</title><content type='html'>You want to upgrade from Outlook to Thunderbird and you've changed from Windows to Linux as a desktop. If you have control over a mail server running dovecot, you are in luck.&lt;br /&gt;&lt;br /&gt;The tool that you need is the very handy &lt;a href="http://www.five-ten-sg.com/libpst/"&gt;libpst&lt;/a&gt; library, although if you run Kubuntu or Ubuntu then this is available on synaptic.&lt;br /&gt;&lt;br /&gt;Simply export your Outlook mail into a pst file. Let's call the file mailBackup.pst. Now copy the file to your email server or linux desktop.&lt;br /&gt;&lt;br /&gt;It is important to create a directory to work in because for each folder in the PST (Outlook) file, there will be a mbox file created with the same name. Cd into this directory and keep emailBackup.pst in the directory above it.&lt;br /&gt;&lt;br /&gt;Now simply run:&lt;br /&gt;&amp;nbsp;&amp;nbsp; readpst ../emailBackup.pst&lt;br /&gt;&lt;br /&gt;The Outlook file will be converted into a series of mbox files. If you run Dovecot, these can be put into your mail directory (be careful not to overwrite existing files!) and you will be able to access them with Thunderbird or your webmail software (I recommend &lt;a href="http://www.horde.org/"&gt;horde&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;You are also able to open mbox files in Thunderbird.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6390279852945612246-8577373406252943812?l=linuxblog.kieser.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linuxblog.kieser.net/feeds/8577373406252943812/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://linuxblog.kieser.net/2010/09/converting-pst-files-to-linux-mbox.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/8577373406252943812'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/8577373406252943812'/><link rel='alternate' type='text/html' href='http://linuxblog.kieser.net/2010/09/converting-pst-files-to-linux-mbox.html' title='Converting PST files to Linux MBOX format'/><author><name>Bradley Kieser</name><uri>http://www.blogger.com/profile/10723853755510927711</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://1.bp.blogspot.com/_iZ-YXgCJsC8/S1YnFCicyiI/AAAAAAAAAK4/t-ix9xqqeXc/S220/brad_smaller.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6390279852945612246.post-770420722765453893</id><published>2010-06-03T19:13:00.001+01:00</published><updated>2010-06-03T19:14:40.993+01:00</updated><title type='text'>SpamAssassin (spamd) deadlocks, runnning slow, Postgres</title><content type='html'>The usual way to use spamassassin is to implement the Bayesian filtering database in flat files. That's the default configuration and most distros ship with this option.&lt;br /&gt;&lt;br /&gt;But that's a bad option. If you want to implement a database, use a proper database.&lt;br /&gt;&lt;br /&gt;The advantages are numerous: Proper caching and cache management, ability to tune the database and tables, better locking capabilities (as in the locking capabilities exist), clustering and fail-over capabilities which all amount to better resource usage, better throughput, less server strain, better maintenance and a much better service. &lt;br /&gt;&lt;br /&gt;There is no better enterprise class OpenSource database than Postgres (or it's twin, Ingres). Frankly, your decision to NOT use Postgres for your database needs has to be very well justified as PG is not only truly enterprise class, but it's also easy to set up, easy to admin and, most importantly. you can tune it properly.&lt;br /&gt;&lt;br /&gt;Which is why you should be using Postgres with SpamAssassin.&lt;br /&gt;&lt;br /&gt;Unfortunately, though, the latest version (and previous versions), 3.3.1 have some pretty bad SQL in them. Rather than utilise the PG strengths and keys, the SQL has not been optimised from a performance point of view. Which, in an email system, is one of the most important things to consider!&lt;br /&gt;&lt;br /&gt;The biggest hole is the use of the SQL I&lt;i&gt;N&lt;/i&gt; operator on the bayes_token table. This effectively forces a full table scan because the unique key is id, token. On a system-wide implementation, the ID column is a particularly weak key (i.e. not a key at all because it's always the same value) so this is a real deal-breaker.&lt;br /&gt;&lt;br /&gt;The solution is to use the primary key wherever possible, which, it turns out, is nearly all the time.&lt;br /&gt;&lt;br /&gt;On a system with a large spam database, this is the difference between a powerful server grinding to its knees v.s. the same server flying at vast throughput.&lt;br /&gt;&lt;br /&gt;The biggest deal-breaker is in the update of the atime column, which is about the most regularly performed task. So it's the hottest of the hot spots in the spamd PG code and also the worst implemented. The fix, however, is very easy.&lt;br /&gt;&lt;br /&gt;Simply edit this file (note the path will be different on your machine:&lt;br /&gt;/usr/lib/perl5/site_perl/5.8.8/Mail/SpamAssassin/BayesStore/PgSQL.pm&lt;br /&gt;&lt;br /&gt;and make these changes:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Original code fragment&lt;/b&gt;&lt;/i&gt;:&lt;br /&gt;------------- &lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;sub tok_touch_all { &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;. &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;. &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;. &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; my $sql = "UPDATE bayes_token SET atime = ? WHERE id = ? AND token IN ("; &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; my @bindings; &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; foreach my $token (sort @{$tokens}) { &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $sql .= "?,"; &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; push(@bindings, $token); &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; } &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; chop($sql); # get rid of trailing , &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; $sql .= ") AND atime &amp;lt; ?"; &lt;/div&gt;&lt;br /&gt;-------------- &lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt; &lt;br /&gt;&lt;i&gt;Amendments:&lt;/i&gt;&lt;br /&gt;---------- &lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;sub tok_touch_all { &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;. &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;. &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;. &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; foreach my $token (sort @{$tokens}) { &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; my $sql = "UPDATE bayes_token SET atime = ? WHERE id = ? AND token ="; &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; my @bindings; &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $sql .= "?,"; &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; push(@bindings, $token); &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; chop($sql); # get rid of trailing , &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; $sql .= " AND atime &amp;lt; ?"; &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;. &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;. &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;. &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; $self-&amp;gt;{_dbh}-&amp;gt;commit(); &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; } &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; return 1; &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;} &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;---------------------------- &lt;br /&gt;&lt;br /&gt;Note that I insert the closing } before the "return 1". &lt;br /&gt;&lt;br /&gt;I.e. I have converted this into a line by line update, so that the DB  can use the very strong primary key of id,token. &lt;br /&gt;&lt;br /&gt;The performance difference that this makes is absolutely enormous on a  busy system. &lt;br /&gt;&lt;br /&gt;In case you want to simply cut and paste the entire function, here is the tok_touch_all function with the amendments in it:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;sub tok_touch_all {&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; my ($self, $tokens, $atime) = @_;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; return 0 unless (defined($self-&amp;gt;{_dbh}));&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; return 1 unless (scalar(@{$tokens}));&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; foreach my $token (sort @{$tokens}) {&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; my $sql = "UPDATE bayes_token SET atime = ? WHERE id = ? AND token =";&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; my @bindings;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $sql .= "?,";&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; push(@bindings, $token);&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; chop($sql); # get rid of trailing ,&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; $sql .= " AND atime &amp;lt; ?";&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; $self-&amp;gt;{_dbh}-&amp;gt;begin_work();&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; my $sth = $self-&amp;gt;{_dbh}-&amp;gt;prepare_cached($sql);&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; unless (defined($sth)) {&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dbg("bayes: tok_touch_all: SQL error: ".$self-&amp;gt;{_dbh}-&amp;gt;errstr());&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $self-&amp;gt;{_dbh}-&amp;gt;rollback();&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; }&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; my $bindcount = 1;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; $sth-&amp;gt;bind_param($bindcount++, $atime);&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; $sth-&amp;gt;bind_param($bindcount++, $self-&amp;gt;{_userid});&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; foreach my $binding (@bindings) {&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $sth-&amp;gt;bind_param($bindcount++, $binding, { pg_type =&amp;gt; DBD::Pg::PG_BYTEA });&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; }&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; $sth-&amp;gt;bind_param($bindcount, $atime);&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; my $rc = $sth-&amp;gt;execute();&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; unless ($rc) {&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dbg("bayes: tok_touch_all: SQL error: ".$self-&amp;gt;{_dbh}-&amp;gt;errstr());&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $self-&amp;gt;{_dbh}-&amp;gt;rollback();&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; }&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; my $rows = $sth-&amp;gt;rows;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; unless (defined($rows)) {&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dbg("bayes: tok_touch_all: SQL error: ".$self-&amp;gt;{_dbh}-&amp;gt;errstr());&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $self-&amp;gt;{_dbh}-&amp;gt;rollback();&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; }&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; # if we didn't update a row then no need to update newest_token_age&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; if ($rows eq '0E0') {&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $self-&amp;gt;{_dbh}-&amp;gt;commit();&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 1;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; }&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; # need to check newest_token_age&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; # no need to check oldest_token_age since we would only update if the&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; # atime was newer than what is in the database&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; $sql = "UPDATE bayes_vars&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET newest_token_age = ?&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE id = ?&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND newest_token_age &amp;lt; ?";&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; $rows = $self-&amp;gt;{_dbh}-&amp;gt;do($sql, undef, $atime, $self-&amp;gt;{_userid}, $atime);&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; unless (defined($rows)) {&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dbg("bayes: tok_touch_all: SQL error: ".$self-&amp;gt;{_dbh}-&amp;gt;errstr());&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $self-&amp;gt;{_dbh}-&amp;gt;rollback();&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; }&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; $self-&amp;gt;{_dbh}-&amp;gt;commit();&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; }&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; return 1;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;}&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6390279852945612246-770420722765453893?l=linuxblog.kieser.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linuxblog.kieser.net/feeds/770420722765453893/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://linuxblog.kieser.net/2010/06/spamassassin-spamd-deadlocks-runnning.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/770420722765453893'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/770420722765453893'/><link rel='alternate' type='text/html' href='http://linuxblog.kieser.net/2010/06/spamassassin-spamd-deadlocks-runnning.html' title='SpamAssassin (spamd) deadlocks, runnning slow, Postgres'/><author><name>Bradley Kieser</name><uri>http://www.blogger.com/profile/10723853755510927711</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://1.bp.blogspot.com/_iZ-YXgCJsC8/S1YnFCicyiI/AAAAAAAAAK4/t-ix9xqqeXc/S220/brad_smaller.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6390279852945612246.post-7527554085645094670</id><published>2010-03-29T20:43:00.001+01:00</published><updated>2011-09-28T11:47:26.871+01:00</updated><title type='text'>No sound in flash on AMD 64 Kubuntu</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;The standard ubuntu/kubuntu installation breaks sound in flash. There are several reasons for this, the first that Kubuntu/Ubuntu uses pulse audio and flash (along with many other applications) doesn't play nicely with pulseaudio. However, PulseAudio problems is just the first of two issues. The second is that Adobe 32 bit flash cannot share audio devices and output sound in the shared environment. For that you need the 64 bit version.&lt;br /&gt;&lt;br /&gt;So the first port of call in Kubuntu is to go to system settings/multimedia/device preference/audio output/Music and bump PulseAudio to the preferred (top) device.&lt;br /&gt;&lt;br /&gt;Click on "test" to make sure that pulseaudio is actually working on your system. If you don't have a sound coming out, you need to first get pulseaudio working properly.&lt;br /&gt;&lt;br /&gt;Next, you need to download the 64bit version of flash from Adobe and you can do this here:&lt;br /&gt;http://labs.adobe.com/downloads/flashplayer10_64bit.html&lt;br /&gt;&lt;br /&gt;(note the above is for version 10, you may wish to check that it's still the latest 64bit version).&lt;br /&gt;&lt;br /&gt;Unzip the file. It gives you a libflashplayer.so file.&lt;br /&gt;&lt;br /&gt;Now you need to overwrite this for firefox (and other applications that use flash).&lt;br /&gt;&lt;br /&gt;For example in my system, in my user home directory, I have ~/.mozilla/plugins/&lt;br /&gt;This is the directory that firefox/mozilla/chrome loads flash from. So I copy the file into this directory, overwriting the existing 32 bit version.&lt;br /&gt;&lt;br /&gt;You may want to&lt;br /&gt;&lt;br /&gt;sudo find / -name libflashplayer.so -print&lt;br /&gt;&lt;br /&gt;to find out where this file is elsewhere on your system and update it there too.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6390279852945612246-7527554085645094670?l=linuxblog.kieser.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linuxblog.kieser.net/feeds/7527554085645094670/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://linuxblog.kieser.net/2010/03/no-sound-in-flash-on-amd-64-kubuntu.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/7527554085645094670'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/7527554085645094670'/><link rel='alternate' type='text/html' href='http://linuxblog.kieser.net/2010/03/no-sound-in-flash-on-amd-64-kubuntu.html' title='No sound in flash on AMD 64 Kubuntu'/><author><name>Bradley Kieser</name><uri>http://www.blogger.com/profile/10723853755510927711</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://1.bp.blogspot.com/_iZ-YXgCJsC8/S1YnFCicyiI/AAAAAAAAAK4/t-ix9xqqeXc/S220/brad_smaller.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6390279852945612246.post-5813179245825743282</id><published>2010-01-19T22:11:00.000Z</published><updated>2010-01-19T22:11:50.839Z</updated><title type='text'>KNetworkManager and WEP encryption</title><content type='html'>The KDE desktop environment is excellent. KDE is famous for its well integrated, powerful set of system utilities and applications. It's stable, fast and fully featured yet remains easy to use and highly customisable. In short, it rocks.&lt;br /&gt;&lt;br /&gt;KDE is so widely used and supported that there is usually more than one utility to do any given task. However, there is usually an official tool and then alternatives.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For managing networks, especially wireless and bluetooth networks, the knetworkmanager utility is the official tool to use. However, although knetworkmanager is very promising and integrates nicely into the KDE bar and is well designed and thought out, at present it seems to not be able to handle WEP encryption very well. Many people have reported problems with knetworkmanager whereas other network managers work well with the same settings on the same wireless network and hardware.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We tested knetworkmanager with kubuntu Heron and a 10 character ASCII WEP key. While WiFI Radar worked well, connected immediately and scanned the range of wifi networks accurately, on the same laptop (Dell XPS M1730) knetworkmanager simply was unable to connect to the same WiFI connection that WiFI Radar connected to. We ensured that kwallet had the correct key in it and to make extra sure we also tested in the config file mode that knetworkmanager offers (storing the WEP passphrase in unencrypted text format).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In /var/log/syslog there were numerous lines with the following entries:&lt;br /&gt;&lt;i&gt; &lt;br /&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;center&gt;wlan0: AP denied authentication (auth_alg=1 code=15)&lt;br /&gt;&lt;br /&gt;NetworkManager: &lt;info&gt;  Old device 'wlan0' activating, won't change.&lt;br /&gt;&lt;br /&gt;wlan0: RX authentication from XX:XX:XX:XX:XX:XX (alg=1 transaction=4 status=15)&lt;br /&gt;&lt;br /&gt;wlan0: unexpected authentication frame (alg=1 transaction=2)&lt;br /&gt;&lt;br /&gt;wlan0: replying to auth challenge&lt;br /&gt;&lt;br /&gt;wlan0: authentication with AP XX:XX:XX:XX:XX:XX timed out&lt;br /&gt;&lt;br /&gt;&lt;/info&gt;&lt;/center&gt; &lt;br /&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;It seems that for some reason, whilst other network management tools are able to configure the WEP passphrase correctly, KNetworkManager cannot. However, when we tested on unprotected WiFI networks, KNetworkManager worked a treat, reinforcing the notion that it only struggles with encryption.&lt;br /&gt;&lt;br /&gt;We also discovered during testing that sometimes other WiFI tools such as WiFI Radar scanned and reported more WiFI networks in the same area with the same laptop at the same time than KNetworkManager did. To be fair, we tried several scanning interations, starting up WiFI Radar and then KNetworkManager alternatively to ensure that the laptop hardware could still see all the WiFIs in the area. Not only was WiFI Radar consistent in its reports, but KNetworkManager was inconsistent, sometimes reporting the same number of WiFI networks as WiFI Radar, other times not seeing several of the networks.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Browsing around the 'net, it seems that some people have KNetworkManager working and others do not. So at least part of KNetworkManager is functional, however if you are roaming networks and encounter a wide range of passphrases and WiFI configurations, this means that for now, KNetworkManager is practically unusable.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So for now, it seems that unfortunately the KDE default network management tool should not be used. Instead, we would recommend that you try other tools. We found &lt;a href="http://wifi-radar.systemimager.org/"&gt;WiFI Radar to be excellent&lt;/a&gt;.However other tools are also available.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6390279852945612246-5813179245825743282?l=linuxblog.kieser.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linuxblog.kieser.net/feeds/5813179245825743282/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://linuxblog.kieser.net/2010/01/knetworkmanager-and-wep-encryption.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/5813179245825743282'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/5813179245825743282'/><link rel='alternate' type='text/html' href='http://linuxblog.kieser.net/2010/01/knetworkmanager-and-wep-encryption.html' title='KNetworkManager and WEP encryption'/><author><name>Bradley Kieser</name><uri>http://www.blogger.com/profile/10723853755510927711</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://1.bp.blogspot.com/_iZ-YXgCJsC8/S1YnFCicyiI/AAAAAAAAAK4/t-ix9xqqeXc/S220/brad_smaller.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6390279852945612246.post-4738059067592971827</id><published>2010-01-19T22:07:00.000Z</published><updated>2010-01-19T22:07:43.674Z</updated><title type='text'>Spamassassin tips and tricks</title><content type='html'>Spamassassin is a powerful antispam tool. However, it consumes a&amp;nbsp;lot of processing power, so a good idea is to install &lt;a href="http://www.amavis.org/"&gt;amavis&lt;/a&gt;.&amp;nbsp;This is a lightweight Perl script that pre-scans emails and rejects&amp;nbsp;many of them based on rules that you set up within the Amaviz&amp;nbsp;configuration file.&lt;br /&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;NOTE&lt;/i&gt;: &lt;i&gt;This page won't attempt to teach you how to&amp;nbsp;install and configure Spamassassin or Amavis. &amp;nbsp;other tutorials exist&amp;nbsp;online. This tutorial is here to give you tips that you may not find&amp;nbsp;elsewhere.&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Spamassassin uses bayesian filters (think of this as a form of&amp;nbsp;artificial intelligence) that can learn about what sort of emails are&amp;nbsp;spam (bad) and what sort are ham (good). The key to this is a tool&amp;nbsp;called &lt;i&gt;sa-learn&lt;/i&gt;&lt;span style="font-style: normal;"&gt; which you run&amp;nbsp;against mailbox files that either contain only ham or only spam&amp;nbsp;emails. This allows Spamassassin to learn which emails you think are spam. Spamassassin uses several files to store this information, kept&amp;nbsp;in a &amp;nbsp;hidden directory (.spamassassin) for each mail user.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: normal;"&gt;To teach Spamassassin  about&amp;nbsp;spam, you pass the –-spam paramter to sa-learn. For ham, the&amp;nbsp;parameter is –-ham.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: normal;"&gt;In the examples below we will&amp;nbsp;assume that Spamassassin is running under the user account &lt;/span&gt;&lt;i&gt;spamd&lt;/i&gt;&lt;span style="font-style: normal;"&gt; and that a mailbox file (in the mbox format common with IMAP servers)&amp;nbsp;that contains only sample spam emails is called &lt;/span&gt;&lt;i&gt;Junk&lt;/i&gt;&lt;span style="font-style: normal;"&gt; and is in the /tmp directory.&lt;/span&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Tip 1&lt;/b&gt;: Spamassassin with amavis uses the &lt;span style="font-style: normal;"&gt;.spamassassindirectory in the Amavis working directory (usually&lt;br /&gt;/var/spool/amavis). Therefore when you are teaching Spamassassin&amp;nbsp;called by Amavis, you need to use the --dbpath parameter. E.g.:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="margin-left: 1.01cm;"&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;sa-learn&amp;nbsp;--dbpath /var/spool/amavis/.spamassassin --mbox --spam -u spamd&amp;nbsp;/tmp/Junk&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: normal;"&gt;sa-learn will look at the emails&amp;nbsp;and will teach Spamassassin that the emails are spam. However,&amp;nbsp;Spamassassin needs to be told to reload its bayesian knowledge files&amp;nbsp;in order to gain this new-found knowledge.&lt;/span&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-style: normal;"&gt;Tip 2&lt;/span&gt;&lt;/b&gt;&lt;span style="font-style: normal;"&gt;:&amp;nbsp;After running sa-learn, issue a kill -HUP to the spamd parent process&amp;nbsp;to force a reload of the bayesian &amp;nbsp;knowledge base. E.g.:&lt;/span&gt;&lt;br /&gt;&lt;div style="margin-left: 1.03cm;"&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;kill&amp;nbsp;-HUP `cat /var/run/spamd.pid`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: normal;"&gt;In&amp;nbsp;very active system the spam flies in quickly filling the Junk file.&amp;nbsp;This can slow down the sa-learn processing dramatically so a good&amp;nbsp;idea is to clear it down. A common way in Linux to truncate a file is&amp;nbsp;to issue a command such as:&lt;/span&gt;&lt;br /&gt;&lt;div style="margin-left: 1.03cm;"&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&amp;gt; /tmp/Junk&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-style: normal;"&gt;However,&amp;nbsp;for some IMAP servers, this can produce some nasty lockups in client&amp;nbsp;email software when the mail user tries to add spam emails to the&amp;nbsp;folder.&lt;/span&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-style: normal;"&gt;Tip 3&lt;/span&gt;&lt;/b&gt;&lt;span style="font-style: normal;"&gt;:&amp;nbsp;Clear down the Junk file(s) in an IMAP-friendly way. This means&amp;nbsp;moving the file somewhere else for &amp;nbsp;processing and recreating the user&amp;nbsp;file rather than truncating it (note that we mv and recreate first&amp;nbsp;before &amp;nbsp;running sa-learn to ensure that the IMAP “folder”&amp;nbsp;has only disappeared for a fraction of a second rather than waiting&amp;nbsp;for a potentially very long sa-learn run to finish before recreating&amp;nbsp;the file):&lt;/span&gt;&lt;br /&gt;&lt;div style="margin-bottom: 0cm; margin-left: 1.03cm;"&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;mv/home/username/mail/Junk /tmp/Junk&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm; margin-left: 1.03cm;"&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;touch&amp;nbsp;/home/username/mail/Junk&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm; margin-left: 1.03cm;"&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;chown&amp;nbsp;brad /home/username/mail/Junk&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm; margin-left: 1.03cm;"&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;chmod&amp;nbsp;700 /home/username/mail/Junk&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm; margin-left: 1.03cm;"&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;sa-learn&amp;nbsp;--dbpath /var/spool/amavis/.spamassassin --mbox --spam -u spamd&lt;br /&gt;/tmp/Junk&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Spammers use automated tools to&amp;nbsp;harvest email addresses. Publishing an email address online is a&amp;nbsp;magnet for spam. This can be to your advantage if you want&amp;nbsp;Spamassassin to learn about new spam messages before they arrive at&amp;nbsp;your legitimate email addresses. The trick is to make spammers send&amp;nbsp;&lt;span style="font-style: normal;"&gt;spam to &lt;/span&gt;&lt;i&gt;honeypot&lt;/i&gt;&lt;span style="font-style: normal;"&gt; email&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: normal;"&gt; addresses first:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: normal;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: normal;"&gt;&lt;b&gt;Tip 4&lt;/b&gt;&lt;/span&gt;&lt;span style="font-style: normal;"&gt;:&amp;nbsp;Create &lt;/span&gt;&lt;i&gt;honeypot&lt;/i&gt;&lt;span style="font-style: normal;"&gt; email&amp;nbsp;addresses that route all email received at those addresses into a&amp;nbsp;spam email file. This can then be used to teach Spamassassin about&amp;nbsp;new forms of spam before the spammers send to your &amp;nbsp;legitimate email&amp;nbsp;addresses. Seed the spam email addresses on the Internet. Put them&amp;nbsp;into web pages where email address harvesting software will find them&amp;nbsp;but ensure that humans will not send legitimate email to them by&amp;nbsp;putting up suitable messages around the email addresses.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: normal;"&gt;Of course, you want Spamassassin&amp;nbsp;to learn about spam automatically. This means that you will want&amp;nbsp;sa-learn to run periodically.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: normal;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: normal;"&gt;&lt;b&gt;Tip 5&lt;/b&gt;&lt;/span&gt;&lt;span style="font-style: normal;"&gt;:&amp;nbsp;Create a cron job to run sa-learn periodically, letting it learn what&amp;nbsp;is spam from the honeypot email &amp;nbsp;addresses as well as the Junk folders&amp;nbsp;maintained by your email users. To do this, you need a suitable cron&amp;nbsp;script. Below is a template for you to use. You will need to adjust&amp;nbsp;the paths to the executables and files applicable on your system. In&amp;nbsp;the example below, we have called the file where the emails from the&amp;nbsp;honeypots are stored &lt;/span&gt;&lt;i&gt;honeypot&lt;/i&gt;&lt;span style="font-style: normal;"&gt; which we store in /var/spool/mail. &lt;/span&gt; &lt;br /&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;We have assumed that users move&amp;nbsp;&lt;span style="font-style: normal;"&gt;spam that they receive into (an IMAP) file on the server called &lt;/span&gt;&lt;i&gt;Junk&lt;/i&gt;&lt;span style="font-style: normal;"&gt;.&amp;nbsp;In the example we show two techniques for processing this Junk user&amp;nbsp;&lt;span style="font-style: normal;"&gt;file. For &lt;/span&gt;&lt;i&gt;username&lt;/i&gt;&lt;span style="font-style: normal;"&gt; we&amp;nbsp;truncate the file in an IMAP friendly manner by moving it and&amp;nbsp;recreating the user file before sa-learn processes the moved file.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: normal;"&gt; For &lt;/span&gt;&lt;i&gt;usernameX&lt;/i&gt;&lt;span style="font-style: normal;"&gt;  we&amp;nbsp;don't truncate the file. This means that the file will continue to&amp;nbsp;grow in size until it's truncated by some other means. Sa-learn will&amp;nbsp;ignore spam emails that it has already learned about so it is safe to&amp;nbsp;not truncate a file provided that it doesn't grow to a point that&amp;nbsp;sa-learn takes a long time to process it. If in doubt, truncate. &lt;/span&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: normal;"&gt;Also in the example below, we&amp;nbsp;show how sa-learn can simply take a list of filenames on the command&amp;nbsp;line which is handy if you have more than one file building up a&amp;nbsp;store of spam emails:&lt;/span&gt;&lt;br /&gt;&lt;div style="line-height: 100%; margin-bottom: 0cm; margin-left: 1.06cm;"&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;#!/bin/bash&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="line-height: 100%; margin-bottom: 0cm; margin-left: 1.06cm;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="line-height: 100%; margin-bottom: 0cm; margin-left: 1.06cm;"&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;/bin/mv&amp;nbsp;/home/&lt;/span&gt;&lt;span style="font-style: normal;"&gt;username&lt;/span&gt;&lt;span style="font-style: normal;"&gt;/mail/Junk&amp;nbsp;/tmp/Junk&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="line-height: 100%; margin-bottom: 0cm; margin-left: 1.06cm;"&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;/bin/touch&amp;nbsp;/home/&lt;/span&gt;&lt;span style="font-style: normal;"&gt;username&lt;/span&gt;&lt;span style="font-style: normal;"&gt;/mail/Junk&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="line-height: 100%; margin-bottom: 0cm; margin-left: 1.06cm;"&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;/bin/chown&amp;nbsp;brad /home/&lt;/span&gt;&lt;span style="font-style: normal;"&gt;username&lt;/span&gt;&lt;span style="font-style: normal;"&gt;/mail/Junk&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="line-height: 100%; margin-bottom: 0cm; margin-left: 1.06cm;"&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;/bin/chmod&amp;nbsp;700 /home/&lt;/span&gt;&lt;span style="font-style: normal;"&gt;username&lt;/span&gt;&lt;span style="font-style: normal;"&gt;/mail/Junk&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="line-height: 100%; margin-bottom: 0cm; margin-left: 1.06cm;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="line-height: 100%; margin-bottom: 0cm; margin-left: 1.06cm;"&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;/usr/bin/sa-learn&amp;nbsp;--dbpath /var/spool/amavis/.spamassassin --mbox --spam -u spamd&amp;nbsp;/tmp/Junk /home/&lt;/span&gt;&lt;span style="font-style: normal;"&gt;usernameX&lt;/span&gt;&lt;span style="font-style: normal;"&gt;/mail/Junk&amp;nbsp;/var/spool/mail/honeypot &amp;gt;/tmp/sa-learn.log 2&amp;gt;&amp;amp;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="line-height: 100%; margin-bottom: 0cm; margin-left: 1.06cm;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="line-height: 100%; margin-bottom: 0cm; margin-left: 1.06cm;"&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;#&lt;br /&gt;Truncate the honeypot file&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="line-height: 100%; margin-bottom: 0cm; margin-left: 1.06cm;"&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;br /&gt;&amp;gt; /var/spool/mail/honeypot&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="line-height: 100%; margin-bottom: 0cm; margin-left: 1.06cm;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="line-height: 100%; margin-bottom: 0cm; margin-left: 1.06cm;"&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;rm&amp;nbsp;-f /tmp/Junk&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="line-height: 100%; margin-bottom: 0cm; margin-left: 1.06cm;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="line-height: 100%; margin-bottom: 0cm; margin-left: 1.06cm;"&gt;&lt;span style="font-family: 'Courier New', monospace;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;/bin/kill&amp;nbsp;-HUP `/bin/cat /var/run/spamd.pid`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Honeypot: &lt;a href="mailto:spam@kieser.net"&gt;spam@kieser.net&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6390279852945612246-4738059067592971827?l=linuxblog.kieser.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linuxblog.kieser.net/feeds/4738059067592971827/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://linuxblog.kieser.net/2010/01/spamassassin-tips-and-tricks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/4738059067592971827'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/4738059067592971827'/><link rel='alternate' type='text/html' href='http://linuxblog.kieser.net/2010/01/spamassassin-tips-and-tricks.html' title='Spamassassin tips and tricks'/><author><name>Bradley Kieser</name><uri>http://www.blogger.com/profile/10723853755510927711</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://1.bp.blogspot.com/_iZ-YXgCJsC8/S1YnFCicyiI/AAAAAAAAAK4/t-ix9xqqeXc/S220/brad_smaller.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6390279852945612246.post-3219513872837601443</id><published>2010-01-19T21:48:00.000Z</published><updated>2010-01-19T21:48:04.054Z</updated><title type='text'>xen "unpack list of wrong size" error</title><content type='html'>One of the fantastic features about Xen is that when you build ane w Xen virtual machine (VM), you can specify a file on domain0 as a&amp;nbsp;physical device to the VM (domU). Here is an example from a Xen&lt;br /&gt;machine configuration file (typically found in /etc/xen):&lt;br /&gt;&lt;div style="margin-left: 0.95cm;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: 'Courier New';"&gt;disk&amp;nbsp;=&amp;nbsp;['file:/xen_files/215_main_disk.img,hda1,w','file:/xen_files/215_swap.img,hda2,w']&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.95cm;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;The above example shows a correctly configured definition for&amp;nbsp;device hda1 (which is mounted from the file&amp;nbsp;/xen_files/215_main_disk.img) and  hda2 (which is mounted from the&amp;nbsp;file /xen_files/215_swap.img).&lt;br /&gt;&lt;div style="font-style: normal;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;However, a frequent newbie error is to&amp;nbsp;forget the “file:”  tag. If you entered this, for&amp;nbsp;example:&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: 'Courier New';"&gt;disk&amp;nbsp;=&amp;nbsp;['file:/xen_files/215_main_disk.img,hda1,w','/xen_files/215_swap.img,hda2,w']&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;then when you run &lt;i&gt;xm create&amp;nbsp;&lt;/i&gt;&lt;span style="font-style: normal;"&gt;for that machine, it will output the error “unpack list of&amp;nbsp;wrong size” which isn't very helpful in telling you that you&amp;nbsp;forgot the “file:” tag!&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Please remember to link to this page if you found this useful so&amp;nbsp;that others can find it too!&lt;br /&gt;&lt;br /&gt;Honeypot: &lt;a href="mailto:spam@kieser.net"&gt;spam@kieser.net&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6390279852945612246-3219513872837601443?l=linuxblog.kieser.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linuxblog.kieser.net/feeds/3219513872837601443/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://linuxblog.kieser.net/2010/01/xen-unpack-list-of-wrong-size-error.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/3219513872837601443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/3219513872837601443'/><link rel='alternate' type='text/html' href='http://linuxblog.kieser.net/2010/01/xen-unpack-list-of-wrong-size-error.html' title='xen &quot;unpack list of wrong size&quot; error'/><author><name>Bradley Kieser</name><uri>http://www.blogger.com/profile/10723853755510927711</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://1.bp.blogspot.com/_iZ-YXgCJsC8/S1YnFCicyiI/AAAAAAAAAK4/t-ix9xqqeXc/S220/brad_smaller.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6390279852945612246.post-8520538999707743329</id><published>2010-01-19T21:40:00.000Z</published><updated>2010-01-19T21:40:49.370Z</updated><title type='text'>Disabling password expiry for specific accounts in msec</title><content type='html'>These notes are written specifically for Mandrake 10.1, however&amp;nbsp;they can apply equally well to many other releases and distributions&amp;nbsp;that use the msec security package.&lt;br /&gt;&lt;br /&gt;The msec package is a powerful tool for establishing tight&amp;nbsp;security controls on your linux machine. It is highly customisable&amp;nbsp;and comes with six pre-defined security settings that can be further&amp;nbsp;customised to your requirements. However, there is a catch. The most&amp;nbsp;useful setting is the &lt;i&gt;higher&lt;/i&gt; level of security. With this&amp;nbsp;level, though, comes a vicious password expiry regime that includes&amp;nbsp;the root password. Worse still, there is a bug that sets password&amp;nbsp;expiry to be immediate under certain conditions. This affects all&amp;nbsp;user account in addition to the root account.&lt;br /&gt;&lt;br /&gt;The result is that your computer can be locked out to all users&amp;nbsp;needing a reboot into stand-alone mode (failsafe) in order to unlock&amp;nbsp;it. Not exactly the best scenario especially if your machine happens&amp;nbsp;to be a server in a remote location!&lt;br /&gt;&lt;br /&gt;There is a solution to this problem though. The file&amp;nbsp;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: 'Courier New';"&gt;/etc/security/msec/level.local&lt;/span&gt;&lt;/span&gt; allows you to fine tune the security settings in the msec package.&amp;nbsp;You can add&lt;br /&gt;&lt;div style="margin-left: 0.95cm;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.95cm;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size: x-small;"&gt;no_password_aging_for('root')&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;to &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: 'Courier New';"&gt;/etc/security/msec/level.local&lt;/span&gt;&lt;/span&gt; to disable password expiry. In fact, you can call this multiple times&lt;br /&gt;to add any number of accounts, so for example&lt;br /&gt;&lt;div style="margin-left: 0.95cm;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.95cm;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size: x-small;"&gt;no_password_aging_for('sales')&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;will disable password expiry for the &lt;i&gt;sales&lt;/i&gt; login. However,&amp;nbsp;there is another gotcha. The chances are that if you found this page&amp;nbsp;you already have a problem with password expiry. Setting the above&amp;nbsp;will not unset an expiry that is permanently expiring an account. For&amp;nbsp;that you need to log into the machine and su – to root. Then&amp;nbsp;you meet your new best friend, the &lt;i&gt;chage&lt;/i&gt; command. This changes&amp;nbsp;the password aging setting for an existing entry. So, to make &lt;i&gt;sales&lt;/i&gt; never expire, you simply run:&lt;br /&gt;&lt;div style="margin-left: 0.95cm;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size: x-small;"&gt;chage&amp;nbsp;-M 99999 'sales'&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;This sets sales to expire in 99999&amp;nbsp;days' time. And with the &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: 'Courier New';"&gt;no_password_aging_for('sales')&lt;/span&gt;&lt;/span&gt; setting above, this will not be reset next time &lt;i&gt;msec&lt;/i&gt; runs.&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;Of course, you need to take careful&amp;nbsp;note of which accounts you turn off password expiry and ensure that&amp;nbsp;these passwords are changed at regular intervals when it suits you,&amp;nbsp;otherwise you may be compromising the security on your machine,&amp;nbsp;especially if it is online.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Honeypot: &lt;a href="mailto:spam@kieser.net"&gt;spam@kieser.net&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6390279852945612246-8520538999707743329?l=linuxblog.kieser.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linuxblog.kieser.net/feeds/8520538999707743329/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://linuxblog.kieser.net/2010/01/disabling-password-expiry-for-specific.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/8520538999707743329'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/8520538999707743329'/><link rel='alternate' type='text/html' href='http://linuxblog.kieser.net/2010/01/disabling-password-expiry-for-specific.html' title='Disabling password expiry for specific accounts in msec'/><author><name>Bradley Kieser</name><uri>http://www.blogger.com/profile/10723853755510927711</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://1.bp.blogspot.com/_iZ-YXgCJsC8/S1YnFCicyiI/AAAAAAAAAK4/t-ix9xqqeXc/S220/brad_smaller.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6390279852945612246.post-7954257730268187782</id><published>2010-01-19T21:32:00.000Z</published><updated>2010-01-19T21:32:49.952Z</updated><title type='text'>Preserving postgres default values on tables that have views and update rules</title><content type='html'>The Postgres database has many strengths, one of the most powerful&amp;nbsp;being the rules and triggers system. Combined with views, rules and&amp;nbsp;triggers allow you to control access to data in underlying tables,&amp;nbsp;stricting users to seeing only the data that they are allowed to see&amp;nbsp;and to enforce business logic. Even complex views with data that&amp;nbsp;comes from many tables through complex joins can be made updatable&amp;nbsp;(insert, update and delete) through using update rules. This can&amp;nbsp;dramatically simplify and speed up application development and makes&lt;br /&gt;rapid application development (for example using Borland's &lt;a href="http://www.borland.com/jbuilder/index.html"&gt;Jbuilder&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;To enable views to be used for updating the underlying datasets,&amp;nbsp;you have to create update rules.This implies creating one or more&amp;nbsp;rule for each update action: &lt;i&gt;Update&lt;/i&gt;, &lt;i&gt;delete&lt;/i&gt; and &lt;i&gt;insert&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;The postgres manual for rule creation is &lt;a href="http://www.postgresql.org/docs/manuals"&gt;here&amp;nbsp;&lt;/a&gt;(&lt;a href="http://www.postgresql.org/docs/manuals"&gt;http://www.postgresql.org/docs/manuals&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;Here is an example of creating a table, a view and an updatable&amp;nbsp;rule, in this case for inserts:&lt;br /&gt;&lt;div style="margin-left: 0.71cm;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size: x-small;"&gt;create&amp;nbsp;table test1 (id serial, col1 integer not null default 10, col2 text&amp;nbsp;not null);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.71cm;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size: x-small;"&gt;create&amp;nbsp;view test1v as select * from test1;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm; margin-left: 0.71cm;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size: x-small;"&gt;create&amp;nbsp;rule testins as on insert to test1v do instead (&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm; margin-left: 0.71cm;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size: x-small;"&gt;insert&amp;nbsp;into test1 (col1,col2) values (NEW.col1,NEW.col2);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm; margin-left: 0.71cm;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size: x-small;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;However, the default values for col1 and the id columns in test1&amp;nbsp;will not be preserved on insert into view est1v. Inserting a null&amp;nbsp;value into these columns will cause a not-null violation. Postgres&amp;nbsp;does not propogate the rules and triggers in the object beneath the&amp;nbsp;view into the update rules on the view. To do this you need to&amp;nbsp;explicitly add these constraints to the view using &lt;i&gt;alter table&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;&lt;div style="font-style: normal;"&gt;In this case we have the col1 default&amp;nbsp;value constraint to apply:&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal; margin-left: 0.74cm;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size: x-small;"&gt;alter&amp;nbsp;table test1v alter column col1 set default 10;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;We now have the default values added to&amp;nbsp;the view. In this way you can build up very complex views,&amp;nbsp;abstracting a good underlying database design, adding strong security&amp;nbsp;and maintaining the sort of database interface that RAD tools such as&amp;nbsp;JBuilder and Delphi excel at using.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Honeypot: &lt;a href="mailto:spam@kieser.net"&gt;spam@kieser.net&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6390279852945612246-7954257730268187782?l=linuxblog.kieser.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linuxblog.kieser.net/feeds/7954257730268187782/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://linuxblog.kieser.net/2010/01/preserving-postgres-default-values-on.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/7954257730268187782'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/7954257730268187782'/><link rel='alternate' type='text/html' href='http://linuxblog.kieser.net/2010/01/preserving-postgres-default-values-on.html' title='Preserving postgres default values on tables that have views and update rules'/><author><name>Bradley Kieser</name><uri>http://www.blogger.com/profile/10723853755510927711</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://1.bp.blogspot.com/_iZ-YXgCJsC8/S1YnFCicyiI/AAAAAAAAAK4/t-ix9xqqeXc/S220/brad_smaller.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6390279852945612246.post-6316356279366422575</id><published>2010-01-19T21:25:00.000Z</published><updated>2010-01-19T21:25:30.369Z</updated><title type='text'>Enabling ping, NFS and ssh in Mandrake at server-grade security levels</title><content type='html'>You have installed &lt;a href="http://www.linux-mandrake.com/" target="_blank"&gt;Mandrake&amp;nbsp;Linux&lt;/a&gt; and have discovered that you cannot ping the machine or ssh&amp;nbsp;onto it.&lt;br /&gt;&lt;br /&gt;To &lt;b&gt;enable pings&lt;/b&gt;, do this:&lt;br /&gt;&lt;div style="margin-bottom: 0cm; margin-left: 1.06cm;"&gt;Add/Edit&amp;nbsp;/etc/security/msec/level.local&lt;br /&gt;add the line:&amp;nbsp;accept_icmp_echo(yes)&lt;br /&gt;&lt;br /&gt;Edit /etc/sysctl.conf&lt;br /&gt;&lt;br /&gt;change the&amp;nbsp;line:&lt;br /&gt;net.ipv4.icmp_echo_ignore_all=1&lt;br /&gt;to&lt;br /&gt;net.ipv4.icmp_echo_ignore_all=0&lt;br /&gt;&lt;br /&gt;and&amp;nbsp;then run sysctl -p &lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;To &lt;b&gt;enable ssh&lt;/b&gt;, ensure that you have ssh installed&amp;nbsp;(urpmi ssh). Mandrake does not automatically enable ssh at&lt;br /&gt;server-grade security levels. The key here is the /etc/hosts.allow&amp;nbsp;file. Ensure that you have this line in /etc/hosts.allow:&lt;br /&gt;&lt;div align="LEFT" style="margin-bottom: 0cm; margin-left: 1.06cm;"&gt;sshd :&amp;nbsp;ALL&lt;br /&gt;&lt;/div&gt;&lt;div align="LEFT" style="margin-left: 1.06cm;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="LEFT"&gt;There is a similar problem if you run NFS mounts on&amp;nbsp;your machine. Your portmap is disabled by default at certain security&amp;nbsp;levels. The key here is to enable NFS ONLY for those IPs that need&amp;nbsp;access to that machine. Here is an example of enabling portmap for a&amp;nbsp;subnet and also the server itself (LOCAL) within the /etc/hosts.allow&amp;nbsp;file:&lt;br /&gt;&lt;/div&gt;&lt;div align="LEFT" style="margin-bottom: 0cm; margin-left: 1.06cm;"&gt;portmap&amp;nbsp;: 111.222.333.444/255.255.255.0, LOCAL&lt;br /&gt;&lt;/div&gt;&lt;div align="LEFT" style="margin-bottom: 0cm; margin-left: 1.06cm;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;Honeypot: &lt;a href="mailto:spam@kieser.net"&gt;spam@kieser.net&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6390279852945612246-6316356279366422575?l=linuxblog.kieser.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linuxblog.kieser.net/feeds/6316356279366422575/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://linuxblog.kieser.net/2010/01/enabling-ping-nfs-and-ssh-in-mandrake.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/6316356279366422575'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/6316356279366422575'/><link rel='alternate' type='text/html' href='http://linuxblog.kieser.net/2010/01/enabling-ping-nfs-and-ssh-in-mandrake.html' title='Enabling ping, NFS and ssh in Mandrake at server-grade security levels'/><author><name>Bradley Kieser</name><uri>http://www.blogger.com/profile/10723853755510927711</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://1.bp.blogspot.com/_iZ-YXgCJsC8/S1YnFCicyiI/AAAAAAAAAK4/t-ix9xqqeXc/S220/brad_smaller.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6390279852945612246.post-6849961860659449437</id><published>2010-01-19T21:04:00.000Z</published><updated>2010-01-19T21:04:09.339Z</updated><title type='text'>How do I search for keywords in OpenOffice word document files?</title><content type='html'>This is the tool that you need:&lt;br /&gt;&lt;a href="http://www.danielnaber.de/loook/"&gt;Loook&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6390279852945612246-6849961860659449437?l=linuxblog.kieser.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linuxblog.kieser.net/feeds/6849961860659449437/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://linuxblog.kieser.net/2010/01/how-do-i-search-for-keywords-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/6849961860659449437'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/6849961860659449437'/><link rel='alternate' type='text/html' href='http://linuxblog.kieser.net/2010/01/how-do-i-search-for-keywords-in.html' title='How do I search for keywords in OpenOffice word document files?'/><author><name>Bradley Kieser</name><uri>http://www.blogger.com/profile/10723853755510927711</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://1.bp.blogspot.com/_iZ-YXgCJsC8/S1YnFCicyiI/AAAAAAAAAK4/t-ix9xqqeXc/S220/brad_smaller.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6390279852945612246.post-799030085613453490</id><published>2010-01-19T18:27:00.000Z</published><updated>2010-01-19T18:27:54.624Z</updated><title type='text'>Compiling PHP versions &gt;= 4.3.0 fails</title><content type='html'>You downloaded the latest PHP version&amp;nbsp;with its built in GD library code and tried to compile it. All goes&amp;nbsp;well until it fails with this nto so meaningful message:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="margin-left: 2cm;"&gt;&lt;i&gt;In file included from gdft.c:37:&lt;/i&gt;&lt;br /&gt;&lt;i&gt;/usr/local/include/freetype2/freetype/ftglyph.h:104: &lt;b&gt;&lt;span style="color: black;"&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: #a0ffff; background-image: initial; background-origin: initial;"&gt;parse &lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: #99ff99; background-image: initial; background-origin: initial;"&gt;error&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;before `&lt;span style="background-attachment: initial; background-clip: initial; background-color: #ffff66; background-image: initial; background-origin: initial;"&gt;&lt;b&gt;&lt;span style="color: black;"&gt;FT_Library&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;'&lt;/i&gt;&lt;/pre&gt;&lt;div style="margin-left: 2cm;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-weight: medium;"&gt;&lt;span style="font-family: 'Times New Roman';"&gt;&lt;span style="font-size: small;"&gt;You&amp;nbsp;consider crying, but then you remember that the Kieser.net guys know&amp;nbsp;their stuff and maybe they have the answer? Well, you are in luck.&amp;nbsp;This error normally means that your /usr/local/include directory has&amp;nbsp;an old &lt;i&gt;freetype&lt;/i&gt; subdirectory as well as the new &lt;i&gt;freetype2&lt;/i&gt;&amp;nbsp;directory that contains both freetype 1 and 2 include files in it.&amp;nbsp;The solution is simple:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-weight: medium;"&gt;&lt;span style="font-family: 'Times New Roman';"&gt;&lt;span style="font-size: small;"&gt;&lt;i&gt;mv&amp;nbsp;/usr/local/include/freetype /usr/local/include/old.freetype&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal; font-weight: medium;"&gt;&lt;span style="font-family: 'Times New Roman';"&gt;&lt;span style="font-size: small;"&gt;and&amp;nbsp;try again! It should work now! ;-)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Honeypot: &lt;a href="mailto:spam@kieser.net"&gt;spam@kieser.net&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6390279852945612246-799030085613453490?l=linuxblog.kieser.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linuxblog.kieser.net/feeds/799030085613453490/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://linuxblog.kieser.net/2010/01/compiling-php-versions-430-fails.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/799030085613453490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/799030085613453490'/><link rel='alternate' type='text/html' href='http://linuxblog.kieser.net/2010/01/compiling-php-versions-430-fails.html' title='Compiling PHP versions &gt;= 4.3.0 fails'/><author><name>Bradley Kieser</name><uri>http://www.blogger.com/profile/10723853755510927711</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://1.bp.blogspot.com/_iZ-YXgCJsC8/S1YnFCicyiI/AAAAAAAAAK4/t-ix9xqqeXc/S220/brad_smaller.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6390279852945612246.post-2258717078188596408</id><published>2010-01-19T13:46:00.000Z</published><updated>2010-01-19T13:46:41.299Z</updated><title type='text'>NFS mounts that hang with status "D"</title><content type='html'>&lt;b&gt;Dang!&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;You got a great Linux office going or maybe a network of servers&amp;nbsp;working together. They share their drives and data through NFS&amp;nbsp;mounts.&lt;br /&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;Then disaster happens&lt;/i&gt;! A NFS server goes down and every&amp;nbsp;machine locks up! The machines trying to mount the NFS partition&amp;nbsp;hang. The processes trying to access the NFS disk (probably your root&amp;nbsp;partition) freeze and won't die!&lt;br /&gt;&lt;br /&gt;The reason this happens is&amp;nbsp;simple: A disastrous decision taken by Sun who developed NFS in the&amp;nbsp;first place, compounded with distributions that simply haven't&amp;nbsp;figured it out yet, means that NFS partitions are mounted, as a&amp;nbsp;default, with the &lt;i&gt;hard&lt;/i&gt; option. This tells the computer that it&amp;nbsp;cannot function without that NFS mount ... so it hangs, trying and&amp;nbsp;retrying forever to get that mount up and running.&lt;br /&gt;&lt;br /&gt;Great for diskless work stations.&lt;br /&gt;&lt;br /&gt;Horribly stupid for the real&amp;nbsp;world!&lt;br /&gt;&lt;br /&gt;Fortunately the solution is as easy as drinking a cappucino.&amp;nbsp;Simply add the option &lt;i&gt;soft&lt;/i&gt; into the /etc/fstab entry for the&amp;nbsp;NFS mount. This tells NFS to try but not hang up. Adding &lt;i&gt;bg&amp;nbsp;&lt;/i&gt;into the options tells it to background the retries, meaning that&amp;nbsp;reboots and mounts will keep the retries in the background allowing&amp;nbsp;the machine to continue processing as normal.&lt;br /&gt;&lt;div style="margin-left: 0.74cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.74cm;"&gt;Here is an example NFS line with&lt;br /&gt;suitable options set:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;sample.com:/kieser/is/great_dir&amp;nbsp;&lt;br /&gt;/sms_team&amp;nbsp;&amp;nbsp;&amp;nbsp; nfs&amp;nbsp;&lt;br /&gt;soft,bg,intr,timeo=10,retrans=2,retry=2,user,owner,exec,dev,suid,rw 0&amp;nbsp;0&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;Honeypot: &lt;a href="mailto:spam@kieser.net"&gt;spam@kieser.net&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6390279852945612246-2258717078188596408?l=linuxblog.kieser.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linuxblog.kieser.net/feeds/2258717078188596408/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://linuxblog.kieser.net/2010/01/nfs-mounts-that-hang-with-status-d.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/2258717078188596408'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/2258717078188596408'/><link rel='alternate' type='text/html' href='http://linuxblog.kieser.net/2010/01/nfs-mounts-that-hang-with-status-d.html' title='NFS mounts that hang with status &quot;D&quot;'/><author><name>Bradley Kieser</name><uri>http://www.blogger.com/profile/10723853755510927711</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://1.bp.blogspot.com/_iZ-YXgCJsC8/S1YnFCicyiI/AAAAAAAAAK4/t-ix9xqqeXc/S220/brad_smaller.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6390279852945612246.post-8146235588587286681</id><published>2010-01-19T11:02:00.000Z</published><updated>2010-01-19T11:02:44.242Z</updated><title type='text'>Unicode, PostgreSQL, JDBC and truncated data</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: Arial, sans-serif; font-size: large;"&gt;&lt;u&gt;&lt;b&gt;The problem&lt;/b&gt;&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Unicode&lt;/b&gt;&lt;br /&gt;Unicode is a 16 bit character encoding that is destined to replace&amp;nbsp;ASCII as the universal character encoding standard. Unlike ASCII,&amp;nbsp;which was design for (and is largely limited to) the american&amp;nbsp;character set, Unicode caters for the entire world's character sets,&amp;nbsp;even the awesome array of Chinese characters! If you can type it on a&amp;nbsp;keyboard, you can store it in Unicode. At last! A truly global,&amp;nbsp;properly usable character encoding that doesn't assume that the&amp;nbsp;entire world is an additional state of the USA!&lt;br /&gt;&lt;br /&gt;Er, right.&lt;br /&gt;&lt;br /&gt;Problem number one is that ASCII is a &lt;i&gt;de facto&lt;/i&gt; standard&amp;nbsp;across most of the world's machines and software.and things get&amp;nbsp;seriously tricky when you start trying to map local incarnations of&amp;nbsp;character sets that have been shoe-horned into the basic ASCII&amp;nbsp;encoding (limited to 7 or 8 bits) to the universal big brother of&lt;br /&gt;them all: Unicode.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;PostgreSQL&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.postgres.org/"&gt;PostgreSQL&lt;/a&gt; is the best&amp;nbsp;database around. Yes, we are biased. Yes there are other excellent&amp;nbsp;databases (you may think Oracle or Ingres, but we think of &lt;a href="http://www.mysql.com/"&gt;MySQL&lt;/a&gt;,&amp;nbsp;which very seriously rocks as well. PostgreSQL supprts many different&amp;nbsp;types of character sets (see the &lt;i&gt;create database&lt;/i&gt; command for&amp;nbsp;more details of its &lt;i&gt;encoding&lt;/i&gt; option).&lt;br /&gt;&lt;br /&gt;&lt;div style="font-style: normal;"&gt;&lt;b&gt;Symptom&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;The problem is that when you connect to&amp;nbsp;PostgreSQL via JDBC and you select text rows as a string from a&lt;br /&gt;table, if those rows contain 8 bit characters (for example a pound&amp;nbsp;(£) sign for the UK), then you may find that the data for that&amp;nbsp;column gets truncated just before that character. I.e., this command&amp;nbsp;fails:&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;&amp;nbsp;read_rs.getString(1);&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Trawling the news groups, it seems that this is caused by Java,&amp;nbsp;which also uses Unicode internally, not being able to map the&amp;nbsp;character coming back from Postgres into a valid Unicode character.&amp;nbsp;Often, the problem lies with the original insert into the Postgres&amp;nbsp;table. The character in question is sent from some client software&amp;nbsp;(with its own character set) to Postgres (which stores it in the&amp;nbsp;character set for that database). On insert, Postgres doesn't check&amp;nbsp;that the value stored in the table is a legal map from the client&amp;nbsp;character encoding set, it merely stores that ASCII value for that&amp;nbsp;character (there is a mapping option that you can turn on when you&lt;br /&gt;build Postgres, see the &lt;a href="http://www.postgresql.org/idocs/"&gt;Postgres&amp;nbsp;Manual&lt;/a&gt; for more information on this).&lt;br /&gt;&lt;div style="font-style: normal;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;It appears that the data is truncated&amp;nbsp;due to a fault in the error handling of the JDBC software.&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;We don't really agree with this&amp;nbsp;analysis. Although the common concensus is that this is a Postgres&amp;nbsp;fault, we're not actually convinced about this. There are numerous&amp;nbsp;reports of the same problem with different databases, including&amp;nbsp;Oracle, MySQL and DB2. We think that the problem lies with the JDBC&amp;nbsp;system and it not being able to determine what the character set is&amp;nbsp;that the data is stored in. This may well come down to the database&lt;br /&gt;supplying more information to JDBC but it may equally be that JDBC&amp;nbsp;needs to examine the environment or use some other resolution&amp;nbsp;mechanism&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;&lt;span style="font-family: Arial, sans-serif;"&gt;&lt;span style="font-size: medium;"&gt;&lt;u&gt;&lt;b&gt;The&amp;nbsp;solution&lt;/b&gt;&lt;/u&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="font-style: normal;"&gt;The best solution is to force Java to&amp;nbsp;read the column as a set of byte values and then explicitly tell Java&amp;nbsp;what the character set is that the table is stored in and then it can&amp;nbsp;do the translation no problem! SO, converting this line:&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;&amp;nbsp;&amp;nbsp;read_rs.getString(1)&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;into this line:&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;&amp;nbsp;&amp;nbsp;new&amp;nbsp;String(read_rs.getBytes(1),"ISO-8859-1")&lt;br /&gt;&lt;/div&gt;does the trick. Of course, in the above example the table was in&amp;nbsp;ISO-8859-1 format. This is the most likely format if Unicode&amp;nbsp;translations are failing, but you do need to check which character&amp;nbsp;set is used in you local software! &lt;a href="http://czyborra.com/charsets/iso8859.html"&gt;See&lt;/a&gt;&amp;nbsp;&lt;a href="http://czyborra.com/charsets/iso8859.html"&gt;here&lt;/a&gt; for a list of possible character codes, what they are, and a&amp;nbsp;very handy discussion of the codes and the characters in each coding.&lt;br /&gt;&lt;br /&gt;Honeypot: &lt;a href="mailto:spam@kieser.net"&gt;spam@kieser.net&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6390279852945612246-8146235588587286681?l=linuxblog.kieser.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linuxblog.kieser.net/feeds/8146235588587286681/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://linuxblog.kieser.net/2010/01/unicode-postgresql-jdbc-and-truncated.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/8146235588587286681'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/8146235588587286681'/><link rel='alternate' type='text/html' href='http://linuxblog.kieser.net/2010/01/unicode-postgresql-jdbc-and-truncated.html' title='Unicode, PostgreSQL, JDBC and truncated data'/><author><name>Bradley Kieser</name><uri>http://www.blogger.com/profile/10723853755510927711</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://1.bp.blogspot.com/_iZ-YXgCJsC8/S1YnFCicyiI/AAAAAAAAAK4/t-ix9xqqeXc/S220/brad_smaller.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6390279852945612246.post-5773536194865324916</id><published>2010-01-19T10:58:00.000Z</published><updated>2010-01-19T10:58:34.283Z</updated><title type='text'>Cron job to check for RAID disk failure</title><content type='html'>Linux's software RAID handling is fantastic, but how do you &lt;i&gt;know&amp;nbsp;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;if one of the disks have failed? RAID is designed to not have a&amp;nbsp;single point of failure which means that if one of your disks goes&amp;nbsp;West, you won't know about it. In a busy server environment you&amp;nbsp;probably don't have the time to keep checking your Linux kit. Linux&amp;nbsp;has a habit of running reliably for years and years until the&amp;nbsp;hardware fails or you need to upgrade the system.&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;div style="font-style: normal;"&gt;Well, fear not! Kieser.net to the&amp;nbsp;rescue! We have this neat little script that does and elementary&amp;nbsp;check for disk failure and then emails you if it detects a failure.&amp;nbsp;You should install it on your server as root, and &lt;i&gt;chmod 500&lt;/i&gt; so&amp;nbsp;that it is executable by cron. Of course, you also need to use&amp;nbsp;&lt;i&gt;crontab -e &lt;/i&gt;to make cron run it at a sensible frequency.&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal;"&gt;Here is the script for you to cut and&amp;nbsp;paste into a suitable file:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="font-style: normal; margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;b&gt;#!/bin/bash&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm; margin-left: 0.81cm;"&gt; &lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal; margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;b&gt;LOG_FILE=/tmp/raid_check_$$&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal; margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;b&gt;SYSTEM=`uname --nodename`&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal; margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;b&gt;MAILTO='root@kieser.net'&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal; margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;b&gt;echo "The $SYSTEM system has RAID failures on it." &amp;gt;&amp;gt;$LOG_FILE&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal; margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;b&gt;echo "Below is the output from /proc/mdstat" &amp;gt;&amp;gt;&amp;nbsp;$LOG_FILE&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal; margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;b&gt;echo "===========================================" &amp;gt;&amp;gt;&amp;nbsp;$LOG_FILE&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal; margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;b&gt;cat /proc/mdstat | egrep 'md.*raid' | fgrep -i '(f)' &amp;gt;&amp;gt;&amp;nbsp;$LOG_FILE&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal; margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;b&gt;if [ $? -eq 0 ]&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal; margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;b&gt;then&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal; margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;b&gt;cat /proc/mdstat &amp;gt;&amp;gt; $LOG_FILE&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="font-style: normal; margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;b&gt;echo "===========================================" &amp;gt;&amp;gt;&amp;nbsp;$LOG_FILE&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal; margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;b&gt;mail -s 'URGENT: RAID disk failure detected' $MAILTO &amp;lt;&amp;nbsp;$LOG_FILE&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal; margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;b&gt;fi&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal; margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;b&gt;rm -f $LOG_FILE&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal; margin-bottom: 0cm; margin-left: 0.81cm;"&gt;&lt;b&gt;exit 0&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Honeypot: &lt;a href="mailto:spam@kieser.net"&gt;spam@kieser.net&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6390279852945612246-5773536194865324916?l=linuxblog.kieser.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linuxblog.kieser.net/feeds/5773536194865324916/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://linuxblog.kieser.net/2010/01/cron-job-to-check-for-raid-disk-failure.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/5773536194865324916'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/5773536194865324916'/><link rel='alternate' type='text/html' href='http://linuxblog.kieser.net/2010/01/cron-job-to-check-for-raid-disk-failure.html' title='Cron job to check for RAID disk failure'/><author><name>Bradley Kieser</name><uri>http://www.blogger.com/profile/10723853755510927711</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://1.bp.blogspot.com/_iZ-YXgCJsC8/S1YnFCicyiI/AAAAAAAAAK4/t-ix9xqqeXc/S220/brad_smaller.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6390279852945612246.post-2324874755429035780</id><published>2010-01-19T10:53:00.000Z</published><updated>2010-01-19T10:53:56.406Z</updated><title type='text'>Recovering a RAID disk back into a RAID device</title><content type='html'>Okay, so you have been clever! You figured that with Linux you can&amp;nbsp;build a RAID using nice cheap IDE disks. Linux's fantastic software&amp;nbsp;RAID feature allows you to do this saving loads of money on harware&lt;br /&gt;RAID and expensive SCSI disks. Maybe you did the easy thing and used&amp;nbsp;a distribution like &lt;a href="http://www.linux-mandrake.com/" target="_blank"&gt;Mandrake&amp;nbsp;Linux&lt;/a&gt;&amp;nbsp;that makes it oh so easy to set up.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;Then disaster happened&lt;/i&gt;! Maybe you did a forced reboot,&amp;nbsp;maybe something else happened, but when the reboot had finished you&amp;nbsp;did &lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 0.56cm;"&gt;&lt;b&gt;dmesg | less&lt;/b&gt; &lt;br /&gt;&lt;br /&gt;&lt;/div&gt;and you saw something like this in the log:&lt;br /&gt;&lt;div style="margin-left: 0.58cm;"&gt;&lt;b&gt;hdf7's event counter: 00000006&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.58cm;"&gt;&lt;b&gt;hde5's event counter: 00000003&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.58cm;"&gt;&lt;b&gt;md: superblock update time&lt;br /&gt;inconsistency -- using the most recent one&amp;nbsp;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;b&gt;freshest: hdf7&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.58cm;"&gt;&lt;b&gt;md: kicking non-fresh hde5 from&amp;nbsp;array!&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.58cm;"&gt;&lt;b&gt;unbind&amp;lt;hde5,1&amp;gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.58cm;"&gt;&lt;b&gt;export_rdev(hde5)&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Oh boy! Quick as a flash you look into the status of the array:&lt;br /&gt;&lt;div style="margin-left: 0.58cm;"&gt;&lt;b&gt;cat /proc/mdstat&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;and it looks bad:&lt;br /&gt;&lt;div style="margin-left: 0.64cm;"&gt;&lt;b&gt;# cat /proc/mdstat&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.64cm;"&gt;&lt;b&gt;Personalities : [raid0] [raid1]&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.64cm;"&gt;&lt;b&gt;read_ahead 1024 sectors&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="margin-left: 0.64cm;"&gt;&lt;b&gt;md2 : active raid1 hdf7[1]&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.64cm;"&gt;&lt;b&gt;39262720 blocks [2/1] [_U]&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.64cm;"&gt;&lt;b&gt;md1 : active raid0 hde2[0] hdf6[1]&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.69cm;"&gt;&lt;b&gt;497792 blocks 64k chunks&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.69cm;"&gt;&lt;b&gt;md0 : active raid1 hde1[0] hdf5[1]&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.69cm;"&gt;&lt;b&gt;505920 blocks [2/2] [UU]&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.69cm;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;Now, in the above, /dev/md2 is the root partition on your machine&amp;nbsp;(of course this is only an example and it may NOT be this device but&amp;nbsp;some other /dev/md* device). It s&lt;i&gt;hould&lt;/i&gt; be a RAID level 1&amp;nbsp;(mirrored) but there is now only one disk in that array!&lt;br /&gt;&lt;br /&gt;What to do?&lt;br /&gt;&lt;br /&gt;Well, you need to restate the kicked out disk (in this case,&amp;nbsp;/dev/hde5). There is a useful command to do this:&lt;br /&gt;&lt;div style="margin-left: 0.71cm;"&gt;&lt;b&gt;raidhotadd /dev/md2 /dev/hde5&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-weight: medium; margin-left: 0.71cm;"&gt;&lt;i&gt;(&lt;/i&gt;&lt;b&gt;NOTE:&amp;nbsp;&lt;/b&gt;&lt;i&gt;you need need substitute your own correct devices. The above&amp;nbsp;is an example only)&lt;/i&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;That will rebuild the dirty mirror disk from the main mirror disk.&amp;nbsp;It will bring the RAID back to a fully flying 2-disk mirrored setup&amp;nbsp;provided, of course, that the disk doesn't have a fault making it&amp;nbsp;fail.&amp;nbsp;While the rebuild is happening, you can monitor the rebuild by:&lt;br /&gt;&lt;div style="margin-left: 0.76cm;"&gt;&lt;b&gt;cat /proc/mdstat&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.76cm;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;It &lt;b&gt;may&lt;/b&gt; be that your disk fails to join the araay and after&amp;nbsp;raidhotadd completes, you see something like this:&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 0.74cm;"&gt;&lt;b&gt;# cat /proc/mdstat&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.74cm;"&gt;&lt;b&gt;Personalities : [raid0] [raid1]&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.74cm;"&gt;&lt;b&gt;read_ahead 1024 sectors&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.74cm;"&gt;&lt;b&gt;md2 : active raid1 hde5[0](F)&amp;nbsp;hdf7[1]&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 0.74cm;"&gt;&lt;b&gt;39262720 blocks [2/1] [_U]&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;Note the (F) which means that the disk failed. Now hard drives are&amp;nbsp;extremely reliable and it us unlikely that your disk is toasted&amp;nbsp;(although you can always assume this to be safe). There is a great&amp;nbsp;Linux command, &lt;i&gt;badblocks&lt;/i&gt; that will scan your disk and mark off&amp;nbsp;the bad blcoks on it. You can then safely add it back into the array.&amp;nbsp;Please note though:&lt;br /&gt;&lt;div style="font-style: normal; margin-left: 0.74cm;"&gt;&lt;span style="color: #ff3333;"&gt;Only&amp;nbsp;run this on unmounted disks&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="font-style: normal; margin-left: 0.74cm;"&gt;&lt;span style="color: #ff3333;"&gt;It&amp;nbsp;takes a LONG time to run.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Simply run:&lt;br /&gt;&lt;div style="margin-left: 0.79cm;"&gt;&lt;b&gt;badblocks -f /dev/hd*&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;where /dev/hd* is the device name for your drive. In the &lt;i&gt;example&amp;nbsp;&lt;/i&gt;above this would be /dev/hde5. After the badblocks has run, try to&amp;nbsp;raidhotadd the disk back into the array again.&lt;br /&gt;&lt;br /&gt;You have to admit it: Linux is HOT!&lt;br /&gt;&lt;br /&gt;Honeypot: &lt;a href="mailto:spam@kieser.net"&gt;spam@kieser.ne&lt;/a&gt;&lt;a href="mailto:spam@kieser.net"&gt;t&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6390279852945612246-2324874755429035780?l=linuxblog.kieser.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linuxblog.kieser.net/feeds/2324874755429035780/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://linuxblog.kieser.net/2010/01/recovering-raid-disk-back-into-raid.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/2324874755429035780'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6390279852945612246/posts/default/2324874755429035780'/><link rel='alternate' type='text/html' href='http://linuxblog.kieser.net/2010/01/recovering-raid-disk-back-into-raid.html' title='Recovering a RAID disk back into a RAID device'/><author><name>Bradley Kieser</name><uri>http://www.blogger.com/profile/10723853755510927711</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://1.bp.blogspot.com/_iZ-YXgCJsC8/S1YnFCicyiI/AAAAAAAAAK4/t-ix9xqqeXc/S220/brad_smaller.jpg'/></author><thr:total>0</thr:total></entry></feed>
