zen.org Communal Weblog

September 19, 2008

Using Ubuntu? Install dnsmasq and go faaaaaaaaaaaaast.

Filed under: — brendan @ 11:13 IST

Want to make your browsing go really quickly? Unless your host is running bind/named itself, you can make it stop asking another computer (possibly over in your ISP) every time you try to visit a site or download your mail. Sometimes there’s a pregnant pause at it’s looking it up—again.

The dnsmasq program is really fantastic and keeps a local cache of the addresses you’re asking about. Your computer has its own local place to scribble down things you’ll probably ask for again soon.

Instructions for setting it up are also available on an Ubuntu blog, with the quickest steps in its first comment.

P.S. It’s not just Ubuntu, actually—you could put it on all sorts of systems, including Macs running OS X.

Some people simply cannot allow themselves to get health insurance so they have choice to pay for the really expensive prescription drugs or trying to buy generic pills online. Generics produced in India are very good as other branded meds. Only reputable pharmacy produces them such as Sunrise remedies. Having this in top one is allowed to buy stromectol uk in generic pharmacy online with extremely affrodable shipping to any point in the world

September 17, 2008

Converting Windows .HLP files to a better format

Filed under: — brendan @ 11:28 IST

Some work I’m doing involved using a bunch of 3rd party tools. They come with .HLP files for user documentation, but I’m doing my development on a Linux host. I discovered a great tool called helpdeco which produced a few different files, on the basis that you may want to change things and regenerate the .HLP file.

For me, the RTF file it produced was exactly what I needed. I was able to get at the info I wanted, and didn’t have to reboot my laptop in order to read the help file. (It occurs to me that invoking some command under the wine emulator may have also worked. Another time. 🙂 )

Certain people may not get medical insurance and thus forced to pay for the expensive prescription pills or research how to buy generic medications online. Generic drugs are as safe as other branded counterparts. Only reputable pharmacy produces them such as Fortune healthcare. With this in head one can buy zyrtec uk in generic online drugstore including free shipping anywhere in the world

July 14, 2008

Java's toString() for perl

Filed under: — Sven @ 15:11 IST

I post it here so I can find it again if needed again. Sometimes I just want to see everything that is going on in a perl object. Sort of what Java’s toString() function does when printing out maps or lists. This is what I ended up with. Now it’s public domain!

our $join = ' ';
sub to_string{ # ug, java
    my $s = shift;
    my $out;
    if (ref $s) {
	if ($s =~ m/ARRAY/) {
	    $out .= '[' . join($join, map {
		to_string($_);
	    } @$_) . ']';
	} elsif ($s =~ m/HASH/) {
	    $out .= '{' . join($join, map {
		"$_=" . to_string($s->{$_});
	    } keys(%$s)) . '}';
	} else {
	    $out .= $s;
	    warn "How do i display '$s'?";
	}
    } else {
	$out .= quotemeta($s);
    }
    return $out;
}

Many people may not get medical insurance and thus forced to pay for the expensive prescription medications or research how to buy generic medications online. Generic drugs are as safe as other branded counterparts. Only reputable pharmacy produces them such as German Remedies. With this in head one can buy revia uk in generic online drugstore including free shipping anywhere in the world

March 29, 2008

Using postfix to block spam botnet traffic

Filed under: — brendan @ 11:48 GMT

A friend of mine is set up with a satellite Internet connection to his home in a not-all-that-rural part of Ireland. He’s been hosting his domain from there, with all email traffic and such going to his local server. Until recently, it was a perfectly workable solution, even with the normal supply of spam, virus, and other junk mail arriving.

But nearly two weeks ago, his domain came under attack from a bunch of spam botnets. Uncountable messages were forged to various places, all of which set up with the Sender: header to be totally random addresses @domain.ie. Unfortunately his ISP said they would not help block the traffic. (As opposed to could not.)

The workaround we came up with pushed his traffic through a virtual-hosted system I have set up over in the US with johncompanies.com (yes, a blatant plug, but I really like their service). There were a few steps I had to take in configuring Postfix before they added the MX record for his domain to reroute everything. (This is on a system running Debian GNU/Linux version 4.0, codenamed etch, using postfix 2.3.7.)

  • In main.cf, add his domain to relay_domains (which already existed for other domains I MX with).
  • Since he uses a lot of different email addresses (to make it easy to catch re-use and selling of them), I didn’t set up a relay_recipient_maps hash table. That would have been even cooler with its ability to block every single address except for the few that are in fact valid. In this case, however, he had a number of variants of addresses he used so it wasn’t a practical choice.
  • Add to smtpd_recipient_restrictions the line
    check_recipient_access hash:/etc/postfix/maps/access_recipient

    and created the file /etc/postfix/access_recipient containing

    postmaster@domain.ie  REJECT
    MAILER-DAEMON@domain.ie       REJECT

    and then ran postmap access_recipient as root. I should note I did not put a line like domain.ie OK which would have let all other mail for the domain go through—but usurped any other rules that smtpd_recipient_restrictions may try to do after my access_recipients entry.

  • I created a /etc/postfix/access_sender file with the lines below. The first was used because his server will never receive mail from someone in his domain.
    domain.ie       REJECT
    MAILER-DAEMON@  REJECT
    MailerDaemon@   REJECT
    abuse@          REJECT
    admin@          REJECT
    Administrator@ REJECT
    autoresponder@  REJECT
    bounce@         REJECT
    info@           REJECT
    majordomo@      REJECT
    Majordomo-Owner@ REJECT
    nobody@         REJECT
    postmaster@     REJECT
    savrequest@     REJECT
    senderchallenge@ REJECT
    spam@   REJECT
    vacation@       REJECT
    

    Then I had to run postmap access_sender as root. In main.cf, for smtpd_sender_restrictions I added

    check_sender_access hash:/etc/postfix/access_sender

    as well.

  • I found I wanted to add some rules that used regular expressions. After installing the postfix-pcre Debian package, I created a new file /etc/postfix/access_sender.pcre with the lines
    /.*bounces\@/   REJECT
    /confirm-return.*\@/    REJECT

    and in main.cf gave smtpd_sender_restrictions yet another entry of

    check_sender_access pcre:/etc/postfix/access_sender.pcre
  • Following the hints from a post by Justin Mason, I created a new file /etc/postfix/header_checks and gave it the lines
    /^Content-Type: multipart\/report; report-type=delivery-status\;/       REJECT no third-party DSNs
    /^Content-Type: message\/delivery-status; /     REJECT no third-party DSNs

    A second file, /etc/postfix/null_sender, had

    <>      550 no third-party DSNs

    In main.cf I gave the smtpd_sender_restrictions list the new entry of

    hash:/etc/postfix/null_sender

    and also added a new line defining header_checks as

    header_checks = regexp:/etc/postfix/header_checks

    Finally I had to run postmap null_sender as root.

  • In master.cf I had to adjust the smtp unix and relay unix entries to only do 2 processes, not the default of 20, since having my machine try 20 simultaneous connections to his machine wouldn’t help. Under each, respectively, I had to add
    -o smtp_destination_concurrency_limit=2

    and

    -o relay_destination_concurrency_limit=2

    I’m still not positive if the maximum of 2 processes would make these options necessary. I should note that this particular system I was setting up did no other mail delivery, so this change was okay. If you’re doing this on a fully production-level host, you might find a different way to throttle the delivery connections going to a specific host, instead of this change which makes all outgoing mail connections happen only two-at-a-time.

  • He’s closed port 25 on his router to try to at least stop the flood. Instead, he’s opening a random port number (like 1767) and having it listen there for new mail. I’ve made postfix deliver it by creating a /etc/postfix/transport file with the lines
    # 20080327 help fight the flood, tunnel the mail to its real destination, e.g., his server is 1.2.3.4
    domain.ie     :[1.2.3.4]:1767
    .domain.ie    :[1.2.3.4]:1767

    and ran postmap transport as root. Into main.cf I added

    transport_maps = hash:/etc/postfix/transport
  • After all of this was done, I had to do postfix restart

The end result, with Justin’s rules in particular, has had thousands and thousands of attempts get blocked trying to get through the door. Some still trickle through, even after the amavis/clamav/spamassassin content filter has processed them.

This is the final accumulation (with a few I already had):


smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/access_sender,
check_sender_access pcre:/etc/postfix/access_sender.pcre,
hash:/etc/postfix/null_sender

header_checks = regexp:/etc/postfix/header_checks

## Steps from http://www.akadia.com/services/postfix_spamassassin.html
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks,
reject_unauth_destination,
reject_unauth_pipelining,
reject_invalid_hostname,
reject_non_fqdn_hostname,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_unknown_sender_domain,
reject_unknown_recipient_domain,
check_recipient_access hash:/etc/postfix/access_recipient,
check_recipient_access pcre:/etc/postfix/access_recipient.pcre,
check_policy_service inet:127.0.0.1:60000,
permit

(The check_policy_service line is for my use of postgrey, another simple step which drastically reduced the amount of spam my own server was getting.)

Please let me know if any of the instructions above prove to not work out properly for you.

P.S. A command I found handy watching the logs to see what was getting through for attempted delivery, even after everything above:

sudo tail -f /var/log/mail.log | egrep -v '((RCPT|connect(ion)?).* from |smtpd_peer_init)'

Big amount of citizens can`t afford health insurance so they have choice to pay for the really expensive prescription meds or look after cheap generic drugs online. Generics are potent and safe as other branded meds. Only reputable pharmacy produces them such as Cipla. Having this in mind one may buy lotensin uk in generic online pharmacy with free shipping worldwide

March 26, 2008

Paying Irish VAT using a Linux system

Filed under: — brendan @ 14:56 GMT

For the longest time I’ve been sticking with having to only ever visit www.ros.ie using W1ndow$ on my laptop. Being self-employed, every two months I have to give some tax to The Man.

This time, I decided to look again to see if anyone has discovered a way to do this without that other OS. Luckily, I found some notes by Andrew S. Townley explaining exactly how. He’s found the link into the ros.ie site to get at the actual KCrypto Java applet that it uses (and claims fails to start).

As described, I put it into /usr/lib/jvm/java-6-sun-1.6.0.03/jre/lib/ext and restarted Firefox. Now the login page on the site worked fine, and I could get in. Yay!

P.S. I’m doing this under Ubuntu 7.10 (Gutsy Gibbon).

Many people simply cannot allow themselves to get medical insurance and thus forced to pay for the expensive prescription medications or trying to buy generic pills online. Generics produced in India are very good as other branded counterparts. Only reputable pharmacy produces them such as Sunrise remedies. With this in top one is allowed to buy levaquin uk in generic pharmacy online with extremely affrodable shipping to any point in the world

March 11, 2008

Fixing our true Unicodeness

Filed under: — brendan @ 12:34 GMT

We recently moved zen.org to a different server, and in the process my dump and reload of our MySQL database worked—mostly. However any posts with UTF-8 Unicode characters didn’t get displayed correctly.

After spending too much time trying to figure out how to make mysql and mysqldump help me, I realized I should look around for others who’ve had the same problem.

Voila, Jonkepon in Japan gave the fix for exactly the problem we had. The fix has to do with the collation of the entries in the database, not the actual dumping and importing of the content itself.

Since the newer WordPress already does their first step with SET TABLE, I just had to go in via phpMyAdmin. For each of post_content in wp_posts and comment_content in wp_comments, I changed the collation of each to binary (noting the type of LONGTEXT or TEXT) and saved it. Then I edited them again and set each to utf8_unicode_ci, and saved them.

Bingo! All is happy and good again. The other tables are all still latin1_swedish_ci (?!), but I’ll leave them alone until we bump into somewhere else that it’s a problem.

Certain people can`t afford medical insurance and thus forced to pay for the expensive prescription pills or look after cheap generic drugs online. Generics are potent and safe as other branded counterparts. Only reputable pharmacy produces them such as German Remedies. With this in mind one may buy zyrtec uk in generic online pharmacy with free shipping worldwide

November 13, 2007

Ripping CDs

Filed under: — Sven @ 02:15 GMT

I’m happy with my Dell Dimension C521 running Kubuntu, and now that I can write to the NTFS partition I can rip all kinds of CDs (NTFS is good for something). Four tops, no problem. India.Arie, Jill Scott, no ploblem. Lars Winnerbäck, Mel TormĂ©, Moby, Pete Fountain, Sublime, easy. Eagles, Nirvana, buzz! Out of a whim I try in on the old Quantex PII, was zen before the tree, no problem! I even tried it on the Dell at Ă—2. What does the old PII have that the AMD64 don’t?

Some people may not get health insurance so they have choice to pay for the really expensive prescription drugs or research how to buy generic medications online. Generic drugs are as safe as other branded meds. Only reputable pharmacy produces them such as Adjanta. Having this in head one can buy propecia uk in generic online drugstore including free shipping anywhere in the world

October 16, 2007

Stupid Perl Trick

Filed under: — Sven @ 15:08 IST

Where I work we have to processes files from many sources, we have found three different line endings: “\n”, “\r\n”, and “\r”. We didn’t want to process all the files before, er, processing them so I wrote the following:

#!/usr/bin/perl
use warnings;
use strict;

until (($/ = getc(STDIN)) =~ m/[\r\n]/) {
die “no new line!” if (eof(STDIN));
};
if ($/ eq “\r”) {
$/ .= “\n” if (getc(STDIN) eq “\n”);
}
seek(STDIN,0,0); # rewind()

This will set $/ to which ever of the three file endings we have so you can then process them without thinking. Well, almost no thinking, you will need to use chomp instead of chop. I’m sure it could be nicely abstracted too, bit I didn’t.

Big amount of citizens simply cannot allow themselves to get health insurance so they have choice to pay for the really expensive prescription meds or trying to buy generic pills online. Generics produced in India are very good as other branded meds. Only reputable pharmacy produces them such as Sunrise remedies. Having this in top one is allowed to buy lotensin uk in generic pharmacy online with extremely affrodable shipping to any point in the world

October 3, 2007

The fine art of spam writing

Filed under: — alice @ 16:03 IST

This arrived in my mailbox just a few minutes ago; couldn’t resist sharing:

“Dear Customer
We are coorporate lenders. we give out loans to A very honest and reliable
personalities. we give out our loans at low interest rate and moderate values as cheap as
4% rate. Becuase of scam we tender our qualifications if it satisfies, you can continue
with the transaction, but if you are not satisfied you can go to another lender. Channel
your reponse to this email.
jamespeter16@gmail.com
Greatest Regards
Marketing Manager

Mr Peter James.”

Some people can`t afford health insurance so they have choice to pay for the really expensive prescription drugs or look after cheap generic drugs online. Generics are potent and safe as other branded meds. Only reputable pharmacy produces them such as German Remedies. Having this in mind one may buy stromectol uk in generic online pharmacy with free shipping worldwide

September 22, 2007

iTunes on the wireless network

Filed under: — brendan @ 11:39 IST

After a little difficulty, I’ve got it working! The music on the Mac Mini upstairs is coming out of the speakers of our 15 year-old Aiwa stereo in the diningroom downstairs.

My laptop’s got a Belkin TuneCastII FM Transmitter plugged into its headphone jack. The laptop (booted into WindowsXP) is running iTunes, playing a song—right now, “The Devil Went Down to Georgia” by The Charlie Daniels Band. And the laptop’s connected over our wireless network.

The Linksys WRT54G in the livingroom is running DD-WRT, a replacement firmware giving it a lot more oompf than what comes on the box by default. I specifically put it on to solve the continuous problem of Mac laptops losing their association with it after a few hours or a day.

Anyway, it turns out the only thing preventing the iTunes on my laptop from seeing the shared music off the mini upstairs was that I’d left the “SPI Firewall” enabled. Since I’ve got the wireless already as tight as I can get it (no broadcast, mac filter, wep encrypted and soon wpa), it’s probably not particularly useful since anything connected via an Ethernet cable wouldn’t be protected by it either.

With that firewall disabled, the packets (to whatever port(s)) made it through and can finally play music on my laptop!

Our 9 month-old boy doesn’t seem to like “Let It Roll”, the next song in that album. Let’s see if he likes The Eagles…

Big amount of citizens may not get health insurance so they have choice to pay for the really expensive prescription meds or research how to buy generic medications online. Generic drugs are as safe as other branded meds. Only reputable pharmacy produces them such as Cipla. Having this in head one can buy orlistat uk in generic online drugstore including free shipping anywhere in the world

Powered by WordPress