egrep: character class syntax is [[:space:]], not [:space:]

Writing complex regex expressions can be daunting. And the task is sometimes exacerbated by strange error messages that you get from the tools. I was tweaking the configuration for logcheck and suddenly started to get this error:

egrep: character class syntax is [[:space:]], not [:space:]

Which is really not providing that much context and therefore very unhelpful. Not to mention that in this case [:space:] may mean any of [:alnum:], [:alpha:], [:digit:], [:space:], [:word:] and others. The error message is exactly the same whatever character class produced the error. So you know there is a problem somewhere but you don’t even know with which class.

The typical problem causing this sort of message is that when you write complex expressions you forget to enclose the class into square brackets. The square brackets are required, for example, for operators like ‘+’. So a correct expression would look like this:

[[:alnum:]]+ [[:digit:]]+

But it is easy to overlook a mistake when you write this:

[:alnum:]+ [:digit:]+

It still kinda looks okay because the square brackets are there but you are missing the extra pair and it is hard to spot. So it may be helpful to look for patterns like ‘:\][?+*]’ in your code with grep or vim search.

 … -->

continue reading →

spamassassin throws errors in amavis cron job

The spamassassin install uses a cron job to do sync and cleanup called amavisd-new-cronjob. This job throws up errors on the Debian 7.

error creating a DNS resolver socket: Network is unreachable at 
/usr/share/perl5/Mail/SpamAssassin/DnsResolver.pm line 235.
plugin: eval failed: error closing socket: Bad file descriptor at 
/usr/share/perl5/Mail/SpamAssassin/DnsResolver.pm line 568.

Looking into it the culprit is the check for whether Bayesian filtering is enabled at all, i.e. these lines:

if ! perl -MMail::SpamAssassin -e "my \$spamtest = Mail::SpamAssassin->new();
\$spamtest->compile_now (); \$spamtest->{conf}->{use_bayes} ? exit 0 : exit 1"
then
 #bayes is disabled - just exit
 exit
fi

Why it does not work and what precisely it needs, I have no idea and no desire to chase the error. Some Perl module or a plugin may be missing. Anyway, since Bayesian is enabled, I simply commented out the above lines in the /usr/sbin/amavisd-new-cronjob file and left it at that.

If you know how to fix it – let me know, please.… -->

continue reading →

ECC memory – what’s the deal?

I remember back in the nineties we were all trying to get the ECC memory for the computers we built. The ECC memory was expensive and we all discussed whether a particular configuration would justify the expense of ECC memory or might just survive without. The amounts of memory at the time were measured in megabytes, not gigabytes, like now. So we all thought that some time in the future, in five years or so, the ECC memory will cost the same as the non-ECC memory and all computers will finally come equipped with ECC memory by default, because the amounts of memory would simply require the use of error correction.

What is ECC memory?
Error-correcting code memory – Error Checking & Correction, ECC – is a type of computer memory that detects and corrects the most common data corruption as the data is passed in and out of the memory. ECC memory has additional memory banks that store checksums of data stored in the memory.

At the time, the calculations showed that with the “typical” desktop the error rate in the memory would be sufficiently low and not present a danger. However, the amount of memory in a typical computer has increased by several orders of magnitude since then. Only while we talked about a few hundred megabytes of memory the errors were negligible. Once you step over the gigabyte threshold, memory errors become a statistical reality. Without the ECC memory, we accumulate errors in our data and algorithms every single day.

It is surprising that with the current state of technology we are not using ECC memory everywhere, just as I thought back in the nineties we would. At least, for your own good, do get ECC memory on the computers you use.… -->

continue reading →