Monthly Archive for January, 2005

Adding DSPAM to my mail setup

It’s about frickin’ time that I added support for DSPAM to my mail server. I use a Postfix+Courier+IMAP+MySQL combination for mail administration as I have a fair deal of domains and users in the system (Read more about the mail setup here).

I will document my steps in trying to fit DSPAM into this mix on this page in the hopes that it will help me or you! :) Btw, I’m doing this on a machine running Fedora Core 1, but I guess it’d work fine with most Linux setups.

Firstly, download DSPAM (I choose the latest beta, v3.4-BETA 1, always living on the edge)

I tested my luck with ./configure, but it just threw an error my way:

checking sqlite.h usability... no
checking sqlite.h presence... no
checking for sqlite.h... no
configure: error: Required version of libsqlite not found

So, I actually had to RTFM, at least the README.

Figured I would use MySQL as the backend and I tried the following: ./configure --with-storage-driver=mysql_drv --enable-daemon --enable-virtual-users --enable-preferences-extension. This gave me a new error:

checking where to find MySQL headers... compiler default paths
checking mysql.h usability... no
checking mysql.h presence... no
checking for mysql.h... no
configure: error: Required version of libmysqlclient not found

Oh well, using ./configure --with-storage-driver=mysql_drv --enable-daemon --enable-virtual-users --enable-preferences-extension --with-mysql-includes=/usr/include/mysql/ --with-mysql-libraries=/usr/lib/mysql/ *puuh*, made all the difference.

Now just run make && make install and watch the magic happen.

Next, create a new database in MySQL and create a new user that has privileges to this database. Run the enclosed .sql-scripts (found under src/tools.mysql_drv/. Which ones you run will depend on your version of MySQL and whether or not you want to use virtual users with DSPAM. I chose to use mysql_objects-speed.sql and virtual_users.sql.

Next I chmod‘ed and chown‘ed the /usr/local/var/dspam/ directory so both the postfix and the apache user can use the files therein.

Also made sure to edit /usr/local/etc/dspam.confset trusted user to myself, root, apache and postfix and also set the correct MySQL settings:

MySQLServer     /var/lib/mysql/mysql.sock
MySQLPort
MySQLUser               dspamuser
MySQLPass               secretpassword
MySQLDb                 dspam
MySQLCompress           true

Next we create /etc/maildroprc like so:

SHELL="/bin/bash"

if (/^X-Spam-Status: Yes/:h || /^X-DSPAM-Result: Spam/:h)
{
        # See if the Spam folder exists.
        `test -d "./Maildir/.Spam/"`
        if ($RETURNCODE != 0)
        {
                # If not, create directories
                `mkdir ./Maildir/.Spam/`
                `mkdir ./Maildir/.Spam/cur`
                `mkdir ./Maildir/.Spam/new`
                `mkdir ./Maildir/.Spam/tmp`
        }
        to "./Maildir/.Spam/."
}

Now chmod and chown the file so the postfix user can run the file.

Add dspam_destination_recipient_limit = 1 to /etc/postfix/main.cf.

Dynamic JavaScript includes

I got asked by Tim at Perfect Fools to help out with a problem of including an ASP-file into an XSL/XML-generated output from a closed program.

He had access to an XSL-file that he could modify, and he needed his ASP-file parsed and included.

We tried a few different strokes, and I just thought I’d share my finds. This was done on IIS to the best of my knowledge.

The first version we tried was

but that failed with the following in the logs:

0b04 050128 10:00:23 Error 150, pIXSLTemplate putref_stylesheet method failed
0b04 050128 10:00:23 XML Error (150) : pIXSLTemplate putref_stylesheet method failed
0b04 050128 10:00:23 Error 150, pStyleSheet load xsl failed

Ok, next try:

But lo and behold, that failed as well. The code was not even processed (probably because this was in an XSL file, and the code in question ought to be in an XML-file).

So, that left us to try the weird and desparate, and there it was. We decided to include the file using JavaScript like this:

Well, almost anyhow. This solution requires the included file to be a JavaScript, so I made a little hack in Java/JSP to help him out. The following code reads an URL and generates a simple JavaScript to echo the code to the page:

<%@ page import="java.net.*" %>
<%@ page import="java.io.*" %>
<%!
public String getUrlAsString(String url_) throws Exception {
    URL url = new URL(url_);
    BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
    StringBuffer buffer = new StringBuffer();
    String readLine = null;
    while ((readLine = reader.readLine()) != null) {
        buffer.append(readLine);
    }
    reader.close();
    return buffer.toString();
}
%><%!
public String getParam(String parameterName, String defaultValue, HttpServletRequest request) {
    if ((request.getParameter(parameterName) == null) || (request.getParameter(parameterName).equals(""))) {
        return defaultValue;
    } else {
        return request.getParameter(parameterName).toString();
    }
}
%><%
String url = getParam("url","http://www.cnn.com",request);
String resultString = getUrlAsString(url).replaceAll(""", """);
%>

Now it’s just a simple matter of including any page like this:

This was kind of a weird solution, but it works out, so we’re pleased for the moment! :)

Crappy in Explorer?

I just noticed that this site looks like crap in MS Internet Explorer. That’s not good, since at least half of my visitors use that.

Will try to pin it down for ya, but I think it’s the code-snippets that do it.

If enough of you spam me about it, I will fix it sooner rather than later.

Store bookmarks with WebDAV in Firefox

I just found the sweetest plugin for Firefox yet: Bookmarks Synchronizer.

Bookmarks Synchronizer is a Mozilla Firefox extension that let you connect to an FTP/WebDAV server and synchronize your bookmarks that are stored in an XML file. Setup is easy; just write in your FTP/WebDAV server address, username, password and a name for the XML file.

This is awesome, now I can keep my precious bookmarks the same at home, at work and on my laptops (yes, I have two).

Now I just want to find a nice all-purpose WebDAV plugin to firefox for uploading any files I’d like. If you know of any, please leave a comment!

Problems running WoW?

I am at my girlfriend Ida’s parents place this weekend since we’re attending a 30-year birthday party for my friend Filip.

While we’re here, I thought I’d install the World of Warcraft Final Beta and give it a spin here as well. Now, they are using Windows 2000, and have a fairly old TNT2 graphics card on their system.

At first install I could not even start the game, it just exited with

==============================================================================
World of WarCraft: Assertions Enabled Build (build 3734)

Exe: D:World of WarcraftWoW.exe
Time: Aug 9, 2004 8:30:29.980 AM
User: prive
Computer: PRIVE-JTENOX8GI
------------------------------------------------------------------------------

This application has encountered a critical error:

ERROR #0 (0x85100000)
Program: D:World of WarcraftWoW.exe
File: C:buildbuildWoWENGINESourcegxCGxDeviceD3dCG xD3dState.cpp
Line: 376
Expr: streamSub <= m_caps.m_numStreams

WoWBuild: 3734

Now, this is no good, but it turns out there is a fix!

I found this at the Blizzard forums!

1. Open the World of Warcraft folder on your hard drive.
2. Open the WTF folder.
3. Open the Config.wtf file using a text editor, like Notepad.
4. Add SET gxApi “opengl” upfront
5. Save the file and start World of Warcraft again.

if “opengl” does not work try “direct3d”

Wonderful, it now loads! =)

Now I just need to set the resolution to something higher, or I won’t be able to make out my character from the surroundings! ;)

Apache and SELinux voes

I’m wrestling with an internal server at Eminds that will run the new version of Horde.

Thing is, this server will only answer on HTTPS (port 443) and will act as the backend for another server doing reverse-proxy requests to this server.

Thing is, directory browsing is on, but all I see are the folders, no files yet. If I give the URL to a single file, I get a 403 like this

Forbidden
You don't have permission to access /test.txt on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

This was a real twister! The file even had chmod 777 for testing, but I still got the error. All folders were 777 as well.

Then my friend Johan Ekblad set me free! We are running SELinux on this server (a Fedora Core 3 box), and since the file was not created by teh apache user, the ownership was not ok. No matter that I set apache as owner using chown.

The solution was a one-liner:
chcon -R -h -t httpd_sys_content_t /path/to/htdocs

Restart httpd, and … voilá! It works again! :)
Thanks a bunch to Johan for this one!

WoW Final Beta!

Wow. WoW european final beta is out!
Yeah, this was WAY OLD news, but I’ve been to busy playing since it came out this sunday, that I didn’t even think of posting this info.

I’m playing on the EN 2 Final Beta server and my name is Abalioz.

PM me in-game and win a prize! :)

xorg.conf for Dell X300

I had some troubles with getting the right screen resolution on my Dell X300 laptop after a recent reinstall, and had to do some xorg.conf surgery.

In case you also get stuck using 800×600, I’m enclosing the following to activate 1024×768 which the monitor is capable of. I also have a section that I use when I dock the laptop, and use my Dell 2001 FP digital flat screen at work.

Section "Device"
        Identifier  "Card0"
        Driver      "i810"
        VendorName  "Videocard vendor"
        BoardName   "Intel 852"
EndSection

Section "Monitor"
        Identifier   "Monitor0"
        VendorName   "Monitor Vendor"
        ModelName    "DELL3200MP"
        HorizSync    30.0 - 60.0
        VertRefresh  48.0 - 75.0
        Option      "dpms"
EndSection

Section "Screen"
        Identifier "Screen0"
        Device     "Card0"
        Monitor    "Monitor0"
        DefaultDepth     16
        SubSection "Display"
                Depth     16
                Modes    "1024x768" "800x600" "640x480"
        EndSubSection
        SubSection "Display"
                Depth     8
                Modes    "1024x768" "800x600" "640x480"
        EndSubSection
EndSection

As an added bonus, here’s how to setup a mouse and the Synaptics touchpad:

Section "InputDevice"
        Identifier  "Mouse0"
        Driver      "mouse"
        Option      "Protocol" "IMPS/2"
        Option      "Device" "/dev/input/mice"
        Option      "ZAxisMapping" "4 5"
        Option      "Emulate3Buttons" "yes"
EndSection

Section "InputDevice"
        Identifier  "Synaptics"
        Driver      "synaptics"
        Option      "Device" "/dev/input/mice"
        Option      "Protocol" "auto-dev"
        Option      "Emulate3Buttons" "yes"
EndSection

For the flat screen:

Section "Monitor"
        Identifier   "Monitor0"
        VendorName   "DELL"
        ModelName    "Dell 2001FP (Digital)"
        HorizSync    31.0 - 80.0
        VertRefresh  56.0 - 76.0
        Option      "dpms"
EndSection

Section "Screen"
        Identifier "Screen0"
        Device     "Card0"
        Monitor    "Monitor0"
        DefaultDepth     24
        SubSection "Display"
                Viewport   0 0
                Depth     24
                Modes    "1600x1200" "1400x1050" "1280x1024" "1280x960" "1152x864" "1024x768" "800x600" "640x480"
        EndSubSection
EndSection

No Host matches server name

This one had me scratching my head for over a day until i figured it out!

I am setting up a web server using Apache httpd 2.0.52, Tomcat 5.5, Java 5 (JDK 1.5) and mod_jk. I had it all working just fine with web applications that I deployed as .war-files, but when i tried to serve single JSPs, it bailed on me with the message “No Host matches server name”. Seems all the tips I found on Google had to do with something else, like wrong ownership of files.

Well, I finally broke it. I had to add an empty context to tomcat’s server.xml, like this:
<Context path="" docBase="." debug="0">
</Context>

Now, just restart tomcat and you’re done!

Back at work

After a long holiday vacation, I’m back at work today.

The holiday has been good, but of course overshadowed by the tsunami disaster. My aunt just managed to escape, and is now home safe.

If you feel for the victims, do a good deed and donate today.