/* Rafkind, Jon */
Thursday 11, March 2010

Life

I downloaded thunderbird 3 beta 4 so that I could see if a few UI issues were fixed. In thunderbird 2 I currently have the following problems:
  • I can't accept SSL certificates permanently. Even though the dialog boxes have a "permanent" option I can't select it. This means each time I open thunderbird I have to accept every certificate I use. I have more than 5 email address and each certificate actually has two dialog boxes, so its quite annoying to click "ok" 10-20 times.
  • while a dialog box meant for accepting certificates is open it takes up 100% cpu. This is the most annoying bug for me and I saw that it was fixed for thunderbird 3 which is why I wanted to upgrade
  • when I come back from a resume after suspend thunderbird hangs. sometimes it manages to become responsive again but certain folders never refresh. I then have to restart thunderbird which leads me to the insane certificate dialog box extravaganza.


So I downloaded the thunderbird 3 beta 4 which nicely came in a precompiled form. The certificate issues seem resolved but I haven't tested the suspend/resume feature yet. A new annoying feature popped up, though: whenever I moved from one inbox to another thunderbird will pop up a dialog box asking if I want to do this and play a sound. Playing the sound is what annoys me since I move around inboxes so frequently. My first thought was to disable the sound in the thunderbird preferences so I went to edit->preferences and searched around. The only sound related option I could find was "play a sound when new message arrives". Well thats not the option I was looking for. Someone mentioned I could try looking at about:config and disable some internal sound related options but again I did not find anything that had an effect on the sound being played.

My next move was to inspect the thunderbird source code. Luckily (or unluckily maybe) half of thunderbird is written in javascript and XUL that comes with the binary distribution. Long story short, I grepped through the source code until I found that the C++ engine had something to do with it. I downloaded the entire source tree and grepped around some more until I found a likely candidate in EmbedPrivate.cpp dealing with gtk but that led nowhere. I asked in the #gtk+ irc channel about it and someone mentioned "gtk-enable-event-sound" as being related. Grepping through thunderbird's source some more I found mozilla/widget/src/gtk2/nsSound.cpp which does indeed look at "gtk-enable-event-sound" somehow. I don't really understand the internals of gtk but supposedly I should be able to override these settings in ./.gtkrc-2.0. I added the following line to ./.gtkrc-2.0
gtk-enable-event-sound = 0


But this had no effect. I wasn't sure that thunderbird was even reading ./.gtkrc-2.0 so I ran thunderbird through strace and saw that it was in fact reading ./.gtkrc-2.0 as well as ubuntu's Human gtkrc in /usr/share/themes/Human/gtk-2.0/gtkrc. I looked in Human's gtkrc file but saw no mention of gtk-enable-event-sound. I knew this stuff was configurable from ubuntu's system gui's so I went to system->preferences->sound. None of the available sounds were the ones thunderbird was playing but there was a "enable sounds" checkbox, so I unchecked that. Now there is no more annoying sound in thunderbird, hooray! I probably disabled all system wide sounds, though, which is not really what I wanted but I'd much rather have no sounds in thunderbird than not be able to hear some dumb login sound.

Thunderbird 3 should come with a way to disable gtk sounds, probably an about:config optino would suffice.

Life

Ah, my new motto:

I object to doing things that computers can do.
- Olin Shivers

And my own corollary:
Anything the computer can do should be obvious.

Life

This song is awesome

Life

firefox started crashing yesterday and I finally figured out why: a library (libbonobo2-0) was corrupt. But it took me quite a while to figure this out.. heres what happened.

Yesterday I clicked on a link in an email I was reading in thunderbird expecting it to open up a new firefox tab but when I clicked the link nothing happened. I thought I must have inadvertently changed some setting and so I didn't realize firefox was dead until I had to close and re-open it to reinitialize my vim firefox plugin which occasionally messes up. When firefox didn't restart I got worried so I opened up a terminal, ran firefox and saw
$ firefox Segmentation fault
Well thats pretty bad and I didn't change anything so I ran it through strace which had some lines about loading libgpg-error.so and then crashing. My first thought was that libgpg-error.so was corrupt because a few hours earlier I had to use the alt+sysrq+REISUB trick to reboot linux after it became unresponsive from a suspend I had issued. I tried reinstalling libgpg-error like so, but it didn't fix the problem.
$ sudo apt-get install --reinstall libgpg-error0
Next I hacked the firefox startup script to run the real firefox binary using gdb so I could get a stack trace. The output was similar to this, but without all the debug info. I got that later on
(gdb) #0 0xb7ef2410 in __kernel_vsyscall () #1 0xb5db5c90 in nanosleep () from /lib/tls/i686/cmov/libc.so.6 #2 0xb5db5ac7 in sleep () from /lib/tls/i686/cmov/libc.so.6 #3 0xb695dc3f in ah_crap_handler (signum=11) at nsSigHandlers.cpp:149 #4 #5 0xb7efdcec in ?? () from /lib/ld-linux.so.2 #6 0xb7f0466b in ?? () from /lib/ld-linux.so.2 #7 0xb7f005c6 in ?? () from /lib/ld-linux.so.2 #8 0xb7f03f4e in ?? () from /lib/ld-linux.so.2 #9 0xb6641c19 in ?? () from /lib/tls/i686/cmov/libdl.so.2 #10 0xb7f005c6 in ?? () from /lib/ld-linux.so.2 #11 0xb66422bc in ?? () from /lib/tls/i686/cmov/libdl.so.2 #12 0xb6641b51 in dlopen () from /lib/tls/i686/cmov/libdl.so.2 #13 0xb665ae63 in pr_LoadLibraryByPathname (name=0xb7ac2dc5 "libgnomeui-2.so.0", flags=1) at ../../../../../nsprpub/pr/src/linking/prlink.c:984 #14 0xb665ad28 in PR_LoadLibraryWithFlags (libSpec= {type = PR_LibSpec_Pathname, value = {pathname = 0xb7ac2dc5 "libgnomeui-2.so.0", mac_named_fragment = {fsspec = 0xb7ac2dc5, name = 0xb7ac2dc5 "libgnomeui-2.so.0"}, mac_indexed_fragment = {fsspec = 0xb7ac2dc5, index = 3081514437}, pathname_u = 0xb7ac2dc5}}, flags=1) at ../../../../../nsprpub/pr/src/linking/prlink.c:580 #15 0xb665ad91 in PR_LoadLibrary (name=0xb7ac2dc5 "libgnomeui-2.so.0") at ../../../../../nsprpub/pr/src/linking/prlink.c:604 #16 0xb69759c0 in nsNativeAppSupportUnix::Start (this=0xb56575b0, aRetVal=0xbfcf2b14) at ../../../toolkit/xre/nsNativeAppSupportUnix.cpp:217 #17 0xb696590c in XRE_main (argc=1, argv=0xbfcf2df4, aAppData=0xb5611380) at ../../../toolkit/xre/nsAppRunner.cpp:2865 #18 0x08048e52 in ?? () #19 0xb5d36450 in __libc_start_main () from /lib/tls/i686/cmov/libc.so.6 #20 0x08048a51 in ?? ()
The original stack trace didn't have all the nice debugging info that this one has (like the values of arguments and such) so I had to compile the firefox 3.0.8 source with debugging information turned on. That was sort of a pain because the Makefiles weren't set up to generate a proper debug build but after some hacking I made it work. The punchline from this is obvious, loading libgnomeui-2.so.0 causes a segfault. The next obvious step was to reinstall libgnomeui-2 just like I tried with libgpg-error but reinstalling did not fix firefox. If libgnomeui-2 wasn't the problem then I figured that one of its dependent libraries must somehow be the problem. I wrote a small program that called dlopen() on all the libraries related to libgnomeui-2 to figure out exactly which library was breaking.
#include <stdio.h> #include <dlfcn.h> #include <unistd.h> void try_load(char * name, int flags){ void * x = dlopen(name, flags); if (!x){ printf("could not load %s\n", name); } else { printf("loaded %s\n", name); } } int main(){ try_load("libart_lgpl_2.so.2", 1); try_load("libasound.so.2", 1); try_load("libatk-1.0.so.0", 1); try_load("libaudiofile.so.0", 1); ... }
   Everything listed in ldd /usr/lib/libgnomeui-2.so.0 I added to the program to try to load. Everything loaded except for libgnomeui-2.so.0 and libbonobo-2.so.0 but before I realized that it was libbonobo's fault I tried to build a debugged version of libc so that I could inspect the dlopen() call itself. I downloaded and tried to compile glibc 2.7 but the linking stage errored out due to a missing reference to __stack_chk_fail_local. Some guy in #glibc said it has something to do with my version of gcc automatically passing -fstack-protector. Eventually I just tried reinstalling libbonobo-2 and voila! firefox didn't segfault anymore.
   This is probably a bug in glibc. It should raise an error if a library is corrupt rather than crash.

Life

A quick howto on setting up a dhcp server.

First install the dhcp package (note that its not the dhcp client). On ubuntu it would be
$ apt-get install dhcp3-server
Now edit the dhcp configuration file for your needs. The configuration file is probably /etc/dhcpd.conf. This is a bare bones configuration file that gives out IP addressees 192.168.1.1 upto 192.168.1.254.
ddns-update-style none; option domain-name "my-domain"; default-lease-time 604800; max-lease-time 704800; subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.1 192.168.1.254; }
The numbers next to default-lease-time and max-lease-time are in seconds so the values I have there now are reasonably long, about a week or so. The ip address immediately after the word 'subnet' specifies a CIDR address and you must have a device with an ip address somewhere in that network. So I have listed 192.168.1.0 with a netmask of 255.255.255.0 so I need a device with an ip somewhere in the range 192.168.1.0 to 192.168.1.255. A quick look at my devices shows I have eth0 with address 192.168.1.4, so that will work out.
$ ifconfig eth0 Link encap:Ethernet HWaddr 00:16:EC:58:E7:A4 inet addr:192.168.1.4 Bcast:192.168.1.255 Mask:255.255.255.0 ... eth1 Link encap:Ethernet HWaddr 00:16:EC:58:E7:A5 inet addr:192.168.2.8 Bcast:192.168.1.255 Mask:255.255.255.0 ...
I also have another device, eth1, with an ip of 192.168.2.8. The dhcp server with the configuration above will only listen for requests on eth0 because eth0 is in the subnet specified by the configuration file. What happens if eth0 and eth1 are both in the same subnet? I'm not really sure.. either dhcp will throw an error or serve requests on both devices somehow. Anyway, multiple subnets can be added to the dhcpd.conf file so that dhcp can service eth0 and eth1. Lets say I added the following to the above configuration file.
subnet 192.168.2.0 netmask 255.255.255.0 { range 192.168.2.30 192.168.2.39; }
Requests that are heard from eth1 will receive an ip address in the range of 192.168.2.30 and 192.168.2.39. Thats only 10 ip addresses! Now you just need to start the server.
$ /etc/init.d/dhcpd restart


Thats about it for setting up a dhcp server in 30 seconds. There are a ton of options that you can put in dhcpd.conf, here are some good links for those.
dhcpd.conf
Another howto on setting up a dhcp server

Tip: if you have an internal network and don't want dhcp requests to get out onto the larger network you can use iptables to drop broadcast packets.
$ /sbin/iptables -A OUTPUT -j DROP -o eth9 -m pkttype --pkt-type broadcast -m physdev --physdev-out eth9
This is useful when you use bridging to set up networks and run a local dhcp server that should only deal with the bridged network.



Powered by PHPS.