2008-04-15 17:13

Pop quiz!

Q: What happens if you have a SMTPA server, and you have a user called info, and then set its password to info?


[[email protected] ~]# qmail-qstat
messages in queue: 151369
messages in queue but not yet preprocessed: 9


  • Yes, there is a reason why those passwords are not available by default.
  • I really should limit the per-account outgoing mail by default in all servers. Let's start working on it.

2008-04-15 16:14

Linux as a windows crutch: Sending SMS

Suppose you want to send SMS messages from windows through a bluetooth connection to a phone.

I am sure you can make it work. On the other hand, I already had it working on Linux... so you can just use this on a friendly Linux box, and send SMS messages by accessing a special URL:

#!/usr/bin/env python
from colubrid import BaseApplication, HttpResponse, execute
import os

class SMSApplication(BaseApplication):

  def process_request(self):
      numero = self.request.args.get('numero')
      mensaje = self.request.args.get('mensaje')
      [entrada,salida]=os.popen4('/usr/bin/gnokii --sendsms %s'%numero,mode='rw')
      response = HttpResponse(msg)
      response['Content-Type'] = 'text/plain'
      return response

if __name__ == '__main__':
  execute(SMSApplication,debug=True, hostname='mybox.domain.internal', port=8080,reload=True)

If someone opens http://mybox.domain.internal:8080/?numero=1234?mensaje=hola%20mundo it sends "hola mundo" to the 1234 number.

I suppose I could call this a web telephony service or somesuch, but it's actually just the 5'solution that came to mind.

It uses a silly little not-a-web-framework called colubrid instead of something you may know, because I wanted to keep it simple, and it doesn't get much simpler than this.

2008-04-09 14:06

A simple memcache memoizer for python>=2.2

Just a snippet of code because every once in a while I need something like the classic memoize decorator but am working on a CentOS 4 bix (with python 2.3!)

I am still testing it, and am not even sure it really works, but it should be close.

cache=memcache.Client([''], debug=0)

def memoize(fun):
    def inner(*args, **kwargs):
        cached = cache.get(key)
        if cached is None:
            val = fun(*args, **kwargs)
            print "Setting: ",key, "to: ",val
            return val
        return cached
    return inner

And later inside a class:

def myfun(self,arg):

And that's it. The basic idea I stole from a blog who was inspired by a Paul Graham book. It can be trivially turned into a decorator, of course (but then only works on 2.4 and later).

2008-04-04 11:41

This is why Linux is not ready for the desktop

If you delete the empty directory /var/lib/xkb, then enable the KDE keyboard layout switcher, the up-arrow key works like print-screen.

At least on my box it does. It took me a month to figure it out.

2008-04-02 10:08

My company has a website now

And you can see it at http://www.netmanagers.com.ar.

It's spanish only right now, but that will change in a week or so.

It was an interesting job, because we are using three web apps written in three different languages (php/python/perl) and I wanted to provide our customers with a single login for all three.

It was a bit of effort, but educational :-D

On other news, there is now a "Tipit" link on each post. What's that for? Well, you can use it to give me money. You get to be listed as "guy that gave Roberto money", too (as soon as there is one ;-).

2008-03-11 14:23

Good News: Linux gives life to old hardware. Bad News: Maybe in some cases it shouldn't.

I was in one of my customer's datacenters the other day, and while I do most work remotely, I had to take this opportunity to take some snapshots of their proxy server.

This post is just a bit of fun. This is not supposed to be their server, it was just a stopgap measure because of multiple hardware failures. This is a large, well managed company, and this irregular situation will be fixed soon. And anyway, it is working just fine.

As you know, Linux can do that kind of job easy without much hardware requirements. After all, it has to handle at most about 3Mbps of data, and this box has 2GB of ram, so there's plenty of room for a speedy cache.

So, let's go for some good news/bad news.

Good news: It's a true-blue IBM Server! Bad news: It's a IBM Netfinity 5000 (model 3Ry)!


Here is some tech info from IBM about it.

Good news: It has 2 CPUs! Bad news: They are two 450Mhz Pentium II CPUs.

Good News: it has hot-swappable SCSI discs! Bad news: you have no discs for that controller, so we will use this 8GB IDE (PATA) disk!


And will leave it just sitting there by the CD unit, besides the huge gaping hole in the front where the SCSI discs would be.

Bad News: it has a tendence to overheating! Good News: You have a place to keep your coffe warm!


2008-03-09 12:54

Playing with GIT

The guys at http://github.com have been nice enough to add me to their beta program, so I am doing a little project there, to figure out if I like git or not.

Since everyone raves about it, I suppose I will, and then will have to turn my numerous googlecode SVN repos into git mirrors or whatever the correct terminology is.

2008-03-07 07:43

New qmail plugin idea: overload

It should not happen but it does: Your qmail server is overloaded. Maybe you are under a DOS attack, or there is a reason why you are getting 10x your usual amount of mail.

But then you start seeing how your "not preprocessed" queue starts growing, and growing...

This can also mean things like clamav or spamassassin, which need to check the mail before it gets queued are not keeping up with the mail flow, or maybe some IO performace issue.

But what can you do righ now to fix it?

Well, you can disable spamassassin, or, in extreme cases, shutdown SMTP so the system has a chance to catch its breath so to speak.

Of course, closing SMTP means your own users can't send email either, which sucks.

Now there is a lighter alternative: shutdown SMTP for those who are not your users.

Here's the trivial code, implemented as a SPP plugin, fit to be used in the [mail] section:


if [ -f /var/qmail/control/overloaded ]
      if [ -z "$SMTPAUTHUSER" ]
              echo R451 Temporary Failure: Server overload
              echo overload: $PPID Temporary Failure: Server overload >&2

And if you are daring and want to make your system self-correcting, maybe you should cron something like this:

* * * * * if [ `qmail-qstat  | tail -1 | cut -d: -f2` -gt 100 ];\
then touch /var/qmail/control/overloaded ;\
else rm -f /var/qmail/control/overloaded; fi

I will probably code it again in C and make it part of ra/plugins.

2008-02-28 19:19

Me and the subte.

I moved to Buenos Aires (BA) almost exactly 8 years ago. For those who have never been here, let me tell you some things about it. It's large. Do you know Sao Paulo? A bit smaller. Much smaller than Mexico DF. About the same size as New York. Twice the population of the Randstad. About the same as greater Paris or Istanbul. So figuring out a way to move around it was important.

Vista dos Aires

The way most natives do it is by bus. There is a pretty extensive and efficient network of buses which will take you anywhere. There are maybe 150 different lines, but if you don't know the city, specially the place you are trying to reach, they are a recipe for getting lost, because you can (will) miss your stop and end anywhere else.


To make it worse, I get dizzy on buses. The braking and starting makes me really sick. I can control it, as long as I look out the window, or straight forward, and breath really carefully.

So, since I don't drive, and cabs are relatively expensive, I always preferred the subway, or, as it is called here, the subte. Plus, on trains and subways I can even read and not get dizzy. I always tried to live close to a station, I had almost one hour to read while traveling and we got along great.

The subte is pretty old. The first in Latin America, and still the only one in a few million nearby square miles. But it's also ... quirky.

For instance, I lived in Belgrano, close to the D line. Which had japanese cars. How did I know they were japanese cars? Well, they had all these things written on the windows in Japanese. Sadly, I can't find pictures of that, and in a recent trip I didn't see them, so it may be that after maybe 20 years someone decided to rub them off. That's a pity. I always imagined they said interesting stuff, even if they probably said "keep your hands inside the car, you idiot".

There's also the boletería-kiosco. A kiosco is a sort of mini drugstore, where you can buy candy, a soda, maybe a comb, or condoms. A boletería is a palce where you buy tickets to ride the subte. And in some places, you can do both things. Because they turned the ticket booths into kioscos.

El hombre del Kiosco

Tere is the line at Retiro station, in the C line. There's 4 or 5 boleterías. When you get there, often there's 40 or 50 people in line on the first one. And you can walk just beside them and buy a ticket in the 4th or 5th booth, where there's noone waiting.

And of course, a classic, the one every tourist sees. The A line. The original BA subte, opened 90 years ago or so... and still using the same cars. Yes, you can ride antique, wooden cars to work on that line. With incandescent bulbs on glass tulips. With manual doors (manual opening only, they close automatically with bone crushing force).

Empty train car

Sure, it's hot. There's no air conditioning, and BA can get pretty hot in summer. But it's nice in winter! It's fast, you can't get lost, and it's just so BA.

2008-02-25 18:31

Weird Django/PyODB bug

I am finishing my first large-ish Django app from scratch [1].

To login a user you can do something like this:

[root@wally app]# python manage.py shell
Python 2.3.4 (#1, May  2 2007, 19:26:00)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyodb import *
>>> import django.contrib.auth
>>> print django.contrib.auth.authenticate(username='user',password='pass')

And then you use that user object for django.contrib.auth.login

Some of the authentication data is available on a Microsoft SQL Server, and I get it via pyodb. And this happens when I try to authenticate the user (assume user and pass are valid, this is the smallest snippet that triggers the bug):

[root@wally app]# python manage.py shell
Python 2.3.4 (#1, May  2 2007, 19:26:00)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyodb import Connect
>>> import django.contrib.auth
>>> c1=Connect("sqlserver",uid="user",pwd="pass")
>>> print django.contrib.auth.authenticate(username='user',password='pass')

As you can see, the pyodb stuff should not interfere with the django stuff at all. I am only importing one function and connecting to the DB, I don't even execute any SQL or use any data from the SQL connection. But the calls to authenticate fail.

How are you supposed to debug this? I worked around it by moving the PyODB stuff to another module, but it's weird.

[1] It's a list server. Discussion groups, moderation features, subscriptions, the works. Like google groups, but yours and not ajaxy. It's not Open Source software, but if you want something similar, I am sure my customer will license it to you :-D

Contents © 2000-2019 Roberto Alsina