javier arturo rodríguez

Archive for the 'General' Category

Link: JSESSIONID considered harmful

Thursday, April 16th, 2009

Craig Condit makes a strong case against JSESSIONID in JSESSIONID considered harmful. And I just learned that it is disabled by default in Grails 1.1.

uHOWTO: Force script recompilation in embedded Perl Nagios

Tuesday, April 14th, 2009

nagiosI just implemented elwell’s notify_via_jabber and it did not work at first. I got the following message in nagios.log:

[1237223883] **ePN failed to compile /usr/local/bin/notify_via_jabber: “Can’t locate Net/XMPP.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.8.8 /usr/local/sh
are/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .) at (eval 1) line 14,
BEGIN failed–compilatio” at /usr/lib/nagios2/p1.pl line 157.

I promptly apt-get installed libnet-xmpp-perl but the problem persisted — with the exact same error message. But Net::XMPP was now there!!
Well it happens that Embedded Perl Nagios (ePN) caches the compiled script and does not try to recompile it until its timestamp changes. So I touched(1) the script and this time the dependency was resolved correctly and the script was compiled sucessfully.

This is probably documented somewhere, but I could not find any reference to this kind of problem with Nagios cached scripts so I tought I would share this simple recipe.

A dubious cure for shyness

Monday, April 6th, 2009

paxil As it turns out, there is a “cure” for shyness. Seth Stevenson’s story “Extroverted Like Me” is a journey into the world of coolness through chemical aids but it quickly turns into a cautionary tale for those willing to overcome their social awkwardness through the use of mood-altering drugs.
Chocolate still seems safe.

U2 360º

Wednesday, April 1st, 2009

In other news, I just got my tickets for U2s’ first concert of the 360º tour in Barcelona!!! *Yay!*. Thanks, Jordi!

uHOWTO: Recover an empty Podcast playlist in iTunes

Monday, March 30th, 2009

PodcastOur main iTunes box had flaky RAM -a heck of a problem to debug by itself- so it used to BSOD quite a lot during the past couple of months. One of the most common side effects was that the iTunes Podcast playlist would appear empty every now and then. Luckily this is addressed in the Apple Knowledge Base and the solution amounts to using File|Add Folder to Library to add the {iTunes Music folder}/podcast folder to the library. Then you will have to re-activate your subscriptions by pressing the “Subscribe” button for all your favorite podcasts.

uHOWTO: Recover stuck modified keys from VMware Player or Workstation

Thursday, January 15th, 2009

If you use VMware Player or VMware workstation under Linux and you’re an alt-tab fan like me, you might end up with stuck modifier keys, so you can’t use keys like Ctrl, Alt or Shift outside of VMware. Xiao Feng has written a nice script to recover from this annoying condition without having to reboot, and I tought I’d share it with everyone out there:

#!/bin/sh
# Xiao Feng’s "Recovering from stuck modifier keys caused by VMware"
# http://bitubique.com/tutorials/recovering-from-stuck-modifier-keys
/usr/bin/xmodmap – << fixme
clear shift
add shift = Shift_L Shift_R
clear lock
add lock = Caps_Lock
clear control
add control = Control_L Control_R
clear mod1
add mod1 = Alt_L Alt_R
clear mod2
add mod2 = Num_Lock
clear mod3
clear mod4
add mod4 = Super_L Super_R
clear mod5
add mod5 = Scroll_Lock
fixme
xset r on
xset m 3.5 4
xset b off
xset s off

A brief note about Spamhaus Policy Block List

Tuesday, December 9th, 2008

After getting in closer-than-usual acquaintance with my mail server logs I thought I’d share a brief note I found in the Spamhaus PBL FAQ:

The first thing to know is: THE PBL IS NOT A BLACKLIST.

Oh, and since you’re already there you may want to linger a bit in this warning:

WARNING! Some post-delivery filters use “full Received line traversal” or “deep parsing”, where the filter reads all the IPs in the Received lines. Legitimate users, correctly sending good mail out through their ISP’s smarthost, will have PBL-listed IPs show up in the first (lowest) Received header where their ISP picks it up. Such mail should not be blocked! So, you should tell your filters to stop comparing IPs against PBL at the IP which hands off to your mail server! That last hand-off IP is the one which PBL is designed to check. If you cannot configure your filters that way, then do not use PBL to filter your mail. Instead, you may wish to use sbl-xbl.spamhaus.org, but even that may have unacceptable “false positive” filtering, for example when a an exploited end-user machine sends legitimate mail out through the ISP smarthost, or when the dynamic assignment changes the IP to an uninfected machine. Do not use PBL or XBL if you do not understand the issues of “deep parsing”.

(Emphasis mine)
So if your top-of-the-line multi-thousand-dollar antispam appliance starts blocking all my email just because there’s a dynamic IP address somewhere in the header and there’s no freaking way to turn it off please go ask for a refund. And stop bouncing my messages.
Oh and by the way the default SpamAssassin configuration in Debian assigns a 0.905 score if the last hop is in PBL.

score RCVD_IN_PBL 0 0.509 0 0.905

header RCVD_IN_PBL              eval:check_rbl(‘zen-lastexternal’, ‘zen.spamhaus.org.’, ‘127.0.0.1[01]‘)

And yes, SpamAssassin does the right thing and checks only the *last* external address — I’ve seen the code:

package Mail::SpamAssassin::PerMsgStatus;

    # If name is foo-lastexternal, check only the Received header just before
    # it enters our internal networks; we can trust it and it’s the one that
    # passed mail between networks
 

So once again kudos to Open Source — and Common Sense.

uHOWTO: Use your N95 8G as a bluetooth modem under Linux with Telcel

Tuesday, September 30th, 2008


For completeness, here’s a followup to my post about using a Nokia N95 as a bluetooth modem under Linux. This is a working wvdial configuration for use with Telcel in Mexico.
Remember to enter your SIM’s PIN in pin-telcel, and refer to my previous post for complete instructions.

[Dialer pin-telcel]
Modem = /dev/rfcomm0
Baud = 460800
Init1 =AT+Cpin=XXXX

[Dialer telcel]
Phone = *99***1#
Username = telcel
Password = telcel
Stupid Mode = 1
Dial Command = ATDT
Check Def Route = on
Dial Attempts = 3
Modem = /dev/rfcomm0
Baud = 460800
Init2 = ATZ
Init3 = ATQ0 V1 E0 S0=0 &C1 &D2 +FCLASS=0
Init4 = AT+CGDCONT=1,”IP”,”internet.itelcel.com”
ISDN = 0
Modem Type = Analog Modem

To use it, enter

# wvdial vodafone-pin
# wvdial vodafone

Enjoy!

HOWTO: Use your Nokia N95 Cellphone as a Bluetooth modem for Linux

Sunday, September 28th, 2008

Did you know that you can use your data-enabled N95 to get a thethered Internet connection from Linux? The access mode and speed will depend on your actual coberture, and as usual YMMV, but I’ve been using this setup for a few months and it works fine.

$ sudo -s
# apt-get install bluetooth bluez-pin bluez-utils kdebluetooth wvdial

Now in user mode use KBlueMon to find out the Bluetooth address of your device and write it down.
Then go ahead and initiate an OBEX file transfer to make sure that you can actually link to your phone and to establish a trust relationship. In your phone add the Laptop to your trusted device list, so it won’t nag you whenever you establish a link.
Now edit /etc/bluetooth/rfcomm.conf :

rfcomm0 {
bind yes;
device 00:21:09:XX:XX:XX;
channel 2;
}

Replace your own device address after “device”.
Now edit /etc/wvdial to add these two entries:

[Dialer pin-vodafone]
Modem = /dev/rfcomm0
Baud = 460800
Init1 =AT+Cpin=XXXX

[Dialer vodafone]
Phone = *99***1#
Username = vodafone
Password = vodafone
Stupid Mode = 1
Dial Command = ATDT
Check Def Route = on
Dial Attempts = 3
Modem = /dev/rfcomm0
Baud = 460800
Init2 = ATZ
Init3 = ATQ0 V1 E0 S0=0 &C1 &D2 +FCLASS=0
Init4 = AT+CGDCONT=1,”IP”,”ac.vodafone.es”
ISDN = 0
Modem Type = Analog Modem

You can give them any name you want. I have defined several providers, to avoid confusions and to use the provider at hand. Replace the “XXXX” in Init1 with your SIM’s PIN.
Now to use them restart the Bluetooth subsystem:

# /etc/init.d/bluetooth restart

And use wvdial to dial out:

# wvdial vodafone-pin
# wvdial vodafone

You should get an Internet link, complete with an IP, a default route and a couple of DNS servers. If it doesn’t, reboot your phone liberally.
Please note that this might get expensive quite quickly unless you get a data plan from your provider. Go ahead and make their day.
Enjoy!

Assign a consecutive number to each row in a mySQL table

Sunday, August 31st, 2008

Say that you need to add a unique index to an existing catalog table, so you decide to add a new column with a consecutive number in it. You may make it an auto_increment column, but that would work only for new inserts. How would you populate the column for the exisiting rows?
If you’re using mySQL you may try this little recipe:
First let’s add the column that we’ll use later as primary key.

ALTER TABLE mytable ADD COLUMN id integer first;

Now we declare a counter and use it to populate each row.

SET @i = 0;
UPDATE mytable SET id=(@i:=@i+1);

Finally, we transform the new column into the primary key.

ALTER TABLE mytable MODIFY COLUMN id integer AUTO_INCREMENT PRIMARY KEY;

There you go. A new auto-increment primary key that has been correctly populated for all existing rows.

Solved mysterious Firefox 3.0.1 crashes

Friday, August 29th, 2008

A few months ago I installed a Firefox 3 beta in my Linux laptop to… well you know, just to fool around. And it crashed spectacularly. I tried again with RC1. No such luck. When 3.0 came around I installed it in several machines –including my wife’s– but it still refused to run in mine.
Today I decided I had enough and ran FF under strace and generally whacked it around hoping to make it work without much luck. I finally decided to apt-get install iceweasel 3.0.1 expecting to have apt-get iron out any possible library conflict but the problem persisted. If anything Firefox crashed even harder because Debian’s Iceweasel does not include Mozilla’s Crash Reporter — it suggests that you install bug-buddy instead. I obligued dutifully and much to my surprise, bug-buddy’s crash report had an extensive and very useful stack trace that revealed libpango as the real culprit.

#0 0xffffe410 in __kernel_vsyscall ()
#1 0xb7db91ab in waitpid () from /lib/i686/cmov/libc.so.6
#2 0xb6382865 in gnome_gtk_module_info_get () from /usr/lib/libgnomeui-2.so.0
#3 0xb7113e2d in XRE_LockProfileDirectory () from /usr/lib/iceweasel/xulrunner/libxul.so
#4
#5 0xb2d94c77 in TtfUtil::GetNameInfo () from /usr/lib/libgraphite.so.3
#6 0xb2d94ebb in TtfUtil::Get31EngFamilyInfo () from /usr/lib/libgraphite.so.3
#7 0xb2d940bc in gr::Font::UniqueCacheInfo () from /usr/lib/libgraphite.so.3
#8 0xb2d9308c in gr::Font::initialiseFontFace () from /usr/lib/libgraphite.so.3
#9 0xb2d93278 in gr::Font::RenderRangeSegment () from /usr/lib/libgraphite.so.3
#10 0xb2dbeeb0 in gr::RangeSegment::RangeSegment () from /usr/lib/libgraphite.so.3
#11 0xb383899e in graphite_PangoGlyphString (text=0xbfb73e88 ” Ã<8A>ø¶”, length=1, xftfont=0xb36e6000, glyphs=0xb2cad800, language=0xb7b58a94 “en”) at pangographite.cpp:183
#12 0xb38393c0 in graphite_engine_script_shape (engine=0xb2c35a80, font=0xb36e6000, text=0xbfb73e88 ” Ã<8A>ø¶”, length=1, analysis=0xbfb73e94, glyphs=0xb2cad800) at graphite-module.c:155
#13 0xb6c89e9a in pango_coverage_new () from /usr/lib/libpango-1.0.so.0
#14 0xb6c9c94a in pango_shape () from /usr/lib/libpango-1.0.so.0
#15 0xb7897e96 in gfxPangoFontGroup::SetGlyphs () from /usr/lib/iceweasel/xulrunner/libxul.so
*snip!*

After zapping libpango I had a working Iceweasel and a few seconds later I was running FF 3.0.1 as well. Now I will check the status of my 23 installed extensions (or at least of those I just can’t live without) and consider Firefox 3.0.1 seriously for my everyday browsing.

X forwarding through SSH in HP-UX

Thursday, August 28th, 2008

If you try to do X forwarding by SSHing to an HP-UX host, you may get the dreaded “Can’t get IP address for X11 DISPLAY.” error. This is more common than you might think, and the reason is that an out-of-the box installation of HP-UX has four or five /etc/nsswitch.conf *examples* for you to install, but not an actual /etc/nsswitch.conf file. I guess this is buried somewhere on the documentation — hey, it might even be a FAQ, but I guess that shipping with a reasonable default wouldn’t hurt.
Well anyway, the following minimal /etc/nsswitch.conf should do for the vast majority of scenarios I can imagine:

# echo “hosts: files dns” > /etc/nsswitch.conf

Now SSH X forwarding should work and a myriad other disasters waiting to happen will surely be averted.

update…where id in (select…) and mySQL ERROR 1093

Tuesday, August 26th, 2008

What’s wrong with this picture?

mysql> UPDATE IGNORE flight SET intl=1 WHERE id IN (SELECT f.id AS id FROM flight f LEFT JOIN airport a ON a.id=f.origin WHERE a.country<>‘mx’ FOR UPDATE);
ERROR 1093 (HY000): You can‘t specify target table ‘flight‘ for update in FROM clause

This construct is invalid in mySQL
According to the manual,

You can use a subquery for assignment within an UPDATE statement because subqueries are legal in UPDATE and DELETE statements as well as in SELECT statements. However, you cannot use the same table (in this case, table t1) for both the subquery’s FROM clause and the update target.

The equivalent multi-table update does the same and works as intended:

UPDATE flight f LEFT JOIN airport a ON a.id=f.origin SET f.intl=1 WHERE a.country<>‘mx’;

Whitespace Matters

Friday, August 31st, 2007

Mark Jason Dominus just released SuperPython 0.91, “a Perl source filter for the SuperPython language, allowing SuperPython code to be embedded into Perl programs”.
In terms of language, it goes way beyond python itself to give proper semantics to whitespace. For instance, here is the Hello World program written in SuperPython:

#!/usr/bin/perl
use SuperPython;

Ain’t it neat? Naturally, the result is

$ ./hello.spy
Hello, world.

just as would be expected.
If you want to try this program yourself you might be surprised to find out that copy+paste won’t work, but that’s a small price to pay in exchange or the benefits of the richness of syntax and expresiveness of the language, and anyway you may download the source code for hello.spy right here.
Mark is very optimist in contributing the new features of SuperPython back to python itself, and has kindly offered to work closely with the Python community to see this happen.
Congrats Mark, and keep up the good work!

Attansic L1 Gigabit Ethernet driver for Debian

Friday, July 20th, 2007

m2v.jpegI just got a new ASUS M2V motherboard to replace a braindead server that would lock up on POST about 75% of the time. The new motherboard has a built-in Attansic L1 Gigabit Ethernet Adapter that is supported in Linux >= 2.6.21, but its driver is still missing from the daily Debian netinst CDs.

04:00.0 Ethernet controller [0200]: Attansic Technology Corp. L1 Gigabit Ethernet Adapter [1969:1048] (rev b0)
Subsystem: ASUSTeK Computer Inc. Unknown device [1043:8226]
Flags: bus master, fast devsel, latency 0, IRQ 25
Memory at fbcc0000 (64-bit, non-prefetchable) [size=256K]
Expansion ROM at fbca0000 [disabled] [size=128K]
Capabilities: [40] Power Management version 2
Capabilities: [48] Message Signalled Interrupts: Mask- 64bit+ Queue=0/0 Enable-
Capabilities: [58] Express Endpoint IRQ 0
Capabilities: [6c] Vital Product Data

I tried David Johnson’s pre-compiled driver for AMD64 but it didn’t work right away, so I compiled AtL1Linux_v1.0.41.0 for the stock 2.6.18-4-486 kernel in the official Debian 4.0 netinst CD and tested it. Although it was supposed to work right out of the box I kept getting “invalid module format” messages. So I stripped out the version information with

$ objcopy -R .modinfo atl1.ko

and it worked immediately. I completed the installation and I will upgrade the server to 2.6.21-2-amd64 over the weekend. So here is a atl1.ko for 2.6.18-4-486 that should work just fine.

By the way, I stripped the version information off David’s atl1.ko but I didn’t get a chance to test it because I was in a hurry. Here it is anyway in case someone finds it useful: atl1.ko for 2.6.18-4-amd64.
Oh, by the way, the M2V has four PCI slots but no built-in VGA adapter, and most PCI-e video cards are so thick that the first slot becomes unusable. Since I bought this motherboard precisely to maximize the number of available PCI slots in the server… well, it just sucks.

Gecko/20070601 C64/Commodore

Monday, July 9th, 2007

firefox-c64.jpegI tought this was just a SpreadFirefox stunt, but I just found the most strange User-Agent in an Apache server log

Mozilla/5.0 (X11; U; Commodore64; en-GB; rv:1.9.0.10) Gecko/20070601 C64/Commodore OS C64

*heh!* I guess it takes another Commodore fan to appreciate this kind of humor.

I’m a Dad!

Friday, June 8th, 2007

MagditaMagdalena Rodríguez Delgado was born last Tuesday, June 5th 2007, sometime around 18:05 GMT. At birth she was 49cm long and weighed 3.220Kg. Just like her mother, she has a strong, commanding voice and powerful lungs behind it.
In the strange state I’m on right now -neither asleep nor awake, with hardly any sleep on the last three days- I can barely believe that I’m a Dad. And I’m completely, absolutely, positively happy.

Tags: ,

Fix Adobe Acrobat Reader’s “expr: syntax error” message

Friday, June 1st, 2007

After I upgraded a few system libraries Adobe Acrobat stopped working and started to print an endless lethany of “expr: syntax error” messages. A quick google search later I found the fix detailed in at least a couple of places: Find acroread (it’s a shell script, probably in /usr/local/bin or under whichever-directoy-you-specified-during-installation/bin) and apply this patch:

— acroread.old        2007-06-01 18:18:49.000000000 -0500
+++ acroread    2007-06-01 18:20:57.000000000 -0500
@@ -415,7 +415,7 @@
            return 1
         fi

-               echo $mfile| sed ’s/libgtk-x11-\([0-9]*\).0.so.0.\([0-9]\)00.\([0-9]*\)\|\(.*\)/\1\2\3/g’
+               echo $mfile| sed ’s/libgtk-x11-\([0-9]*\).0.so.0.\([0-9]*\)00.\([0-9]*\)\|\(.*\)/\1\2\3/g’
         return 0
     fi

Or just fire up vi(1) and add an asterisk after the second [0-9] block in line 418.
Even tough the problem has been solved, now this is kind of moot. See, I’d rather use acroread than xpdf any day because its navigation is a lot more natural than xpdf’s, and just to be honest xpdf is showing its age and is just plain ugly. However Adobe is starting to piss me off with its inclusion of the Yahoo toolbar in Acrobat Reader and its pitiful insistence to install n upgrades every single freaking time I open a PDF file. So I’ve started to use kpdf instead which feels a bit slower but starts up in a blink, looks a lot cleaner, doesn’t include spyware and displays the PDFs I’ve fed to it with decent antialiasing.

$ echo “alias acroread=kpdf” >> $HOME/.bashrc

So -just to be clear- in my opinion the best way to fix this problem is to stop using acroread and just use something else. Adobe: thank you for screwing up one of your nicer products, and see you never.

Hello, Planeta Linux!

Saturday, May 19th, 2007

planetalinux-small.pngAnd now for something completely different: This site is now syndicated in Planeta Linux Mexico.
If you haven’t heard about Planets, they are sites that publish aggregated news feeds around certaint themes in the now all-too-familiar reverse chronologic order. Planets are a great way to feel the pulse and hear the buzz of a community without having to maintain individual subscriptions manually. Throught the years I’ve become reliant in several Planet feeds, most notably Planet Perl, Planet Python and Planet Debian.
A few weeks ago Beco introduced me to Planeta Linux -now I’m an avid reader- and kindly offered to talk to Damog and get this blog’s RSS feed into the site.
If you are one of my three regular readers, go visit Planeta Linux, I’m sure you’ll find it as enjoyable as I do. And if you are a Planeta Linux reader, well… Hello!

09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0

Tuesday, May 1st, 2007

What’s so special about this number? How is it different from -say- 0×09F911029D74E35BD84156C5635688BF or from 0×09F911029D74E35BD84156C5635688C1? More importantly: can someone copyright a freaking number? Read rudd-o’s Spread this number post and find out why 0×09F911029D74E35BD84156C5635688C0 is so important.

22 queries. 0.196s  $Revision: 1.6 $
Use Any Browser! Valid XHTML 1.0   Powered by WordPress Powered by Apache Web Server Hacker Emblem