Long live Debian!

After the Lenny release, nobody can say that Lenny is not a rock-solid OS. Furthermore, nobody can say that sid(unstable) is not bleeding edge enough. Especially after kde4.2 made it into sid. The kde4.2 upgrade process succeeded smoothly on my place. I've also "upgraded" my Lenovo X61 laptop from Ubuntu to Debian sid with a surprising success. I really feel better now, with Debian.

Still, when trying to convince people why Debian is superior than Ubuntu, it's hard to find the rational reasons. After all, Ubuntu is a Debian with more money and a larger community. After some thought, I've caught two possible reasons:

  1. Expert community: the average debian bug report is much more professional than an ubuntu bug, which is sometimes just a mess made of dozens of people saying "ohh it also happens to me!! please fixxx!". In other words, Debian users seem to be more tech savvis.
  2. KDE is quite a stranger in ubuntu. Kubuntu is quite uncommon, which makes it a little less intensively developed. In Debian there's no such partition. Debian is KDE as much as it's GNOME. I like KDE, so it feels more native to use Debian.

What do you think, why is Debian superior in your opinion? (or is it not..)

Vim whole word search

In perl regexp syntax, \b (b means bareword) can be used for searching a whole word. I.e. \btext\b:

Will match: text, @text, <space here>text!, etc

Won't match: textile, mytext.

I've been looking for a similar feature in vim for months, with no luck, until today. I've found out how to do that, the syntax is simply  \<text\>. Works for search mode (/,?), substitute (:s), and probably for other modes as well.

Actually that's what the #, * keys do (search for the under-the-cursor whole word), and that's how I found that out.

Goodie.

A global ZoneEdit DNS update problem?

Update: Manually updating it in the web gui seems to fix the issue. I wonder if it's a temporary issue that was solved..

yet another an Is-it-just-me-or-is-it-a-global-problem? post:

A lightning had struck nearby and killed the power at around 03:00UTC. I've turned the computer back on at 09:22UTC (yes I know, I slept too much), and ddclient updated zoneedit.com with my new IP.

According to zoneedit's web gui, my IP got updated. But their DNS servers still give the old IP. (It's been 10hrs since my update, for it's 17:00UTC now)

I mailed their support, no reply yet (I'll update in this post, when there's news). Is anybody else experiencing the same problem?

14hrs without a functioning mail. Everything is so quiet and peaceful 🙂

/dev permissions hell

[... This post got too long for no good reason, feel free to jump to the conclusions ...]

The problem
On my CentOS 5 server, the default sound device (/dev/snd/*) permission was root:root 0600.
This means that other users simply cannot play music. Annoying.

The solution ought to be simple...
So, I've ran groupadd sound and added all the relevant users to the new group.

Then, I went to /etc/udev/rules.d/90-alsa.rules, and added this line, to tell that anything that is sound related, should be fully accessible to "sound" group:

SUBSYSTEM=="sound", GROUP="sound", MODE="0660"

Fanatic problem solving mode: ON
But.. not working. Then I've switched into "fanatic problem solving" mode. This means: trying everything without too much thought, modifying every possible file with any possible way.. But no luck. /dev/snd/* files are still root-only-accessible.

A-HA!
Then I've tried to really think.. Running the following command and really inspect its output:

udevtest /devices/audio/subsystem/timer

(udevtest needs the /sys path and not /dev path, quite annoying)

The output shows the list of rules that udev would run for this device. Then I've noticed the last line

main: run: '/sbin/pam_console_apply /dev/snd/timer '

PAM! Of course it's guilty. Then a quick grep revealed the following in /etc/security/console.perms.d/50-default.perms:

<console> 0600 <sound> 0600 root

I commented it out, and ... viola! All works.



In short...

Linux, or at least RedHat 5, has two conflicting mechanisms for setting /dev file permissions:
1. udev: the service responsible for /dev directory content.
2. pam: the service (well, not quite a service but something similar) responsible for system's security.

Udev actually calls the pam service on new device (on rules.d/95-pam-console.rules), so in effect, pam might actually override Udev permission settings. The relevant PAM config files are in /etc/security/console.perms.d).

Great, 1.5hrs got wasted. at least I've learned something.

A truly lame KDE 4 issue (or: command keyboard shortcuts not working)

Hi,

A few days ago, I've installed KDE 4 on my Ubuntu laptop, as I wanted to replace GNOME. The GUI and default styles are really beautiful (finally someone realizes that black-based colors are best. like good old console).

One of the first things I always do when customizing a new environment, is assigning a keyboard shortcut for running konsole. After a little struggling & googling, I realized that setting a command shortcut is not available through the keyboard settings, nor through the "properties" menu of the desktop icon, because there's no such menu anymore. I think that it's a bad design, but that's one thing.

The right way for setting a command shortcut is through the menu editor (right click on K menu). After choosing an application from the menu, it's possible to assign it a shortcut key.

... Or so it seems! I've chosen my favorite key combination (ctrl+space), and it didn't work. Some googling revealed that it's a known bug with a normal severity, which will only be fixed on KDE 4.2.

Bottom line: KDE 4.1 (sounds like a mature version to me..) does not support assigning keyboard shortcuts to commands although the option is present with no warnings, and nobody is going to fix that for 4.1. This is, what I call LAME (read: unprofessional).

On my Debian desktop I still have KDE 3.5 (which is a great product), because sid is still in a deep freeze. Maybe it's good, after all.

The most annoying Office feature can be disabled

I find the Autocorrect feature very annoying. Especially the annoying auto-capitalization thing, which prevents me from writing a single lowercase letter. All these years of wrestling with office are now over!

  • OpenOffice 2.4 (maybe 3.x as well): Tools -> Autocorrect -> Options tab
  • Office 2007: Round office button on top -> Word options -> Proofing -> Autocorrect options -> Autocorrect tab

Huh! I disabled them all.

I'm still looking for the "Disable all annoying behavior" checkbox..

Xorg config silently got better

Since my first XFree86 (v3), I got used to the annoying /etc/X11/XF86Config file (now /etc/X11/xorg.conf), and I didn't notice that editing this file already belongs to the dinosaurs era. Quite silently, new features emerged and gave better ways to configure X, in particular screen resolutions. I'll sum up what I've found out today, in a bullet fasion:

  • The modern xorg actually no longer needs the xorg.conf file. xorg simply knows what to do automagically :). xorg.conf file can be used though, for overriding the defaults. Still, only the overrided stuff can be written, and the file is still small and readable.
  • xrandr --mode changes the resolution on the fly (not permanently though), from a list of given resolution. Thank you, HP, this time you did something good 🙂
    • xrandr --newmode , xrandr --addmode: add new resolutions to that list.
    • Still, X may have an upper resolution limit which it won't let you pass. It can be increased by adding a "Virtual" line to xorg.conf (Screen section -> Display subsection). i.e. "Virtual 1280 768" would set a maximum resolution of 1280x768.
  • cvt is a cool tool for generating Mode Lines, simply amazing! Needed for xrandr --newmode command.
  • Setting a new resolution permanently: this Ubuntu howto suggests to simply add the correct xrandr commands (i.e. xrandr --mode 1280x768) to the ~/.xprofile script. These commands would run right after each X login for that specific user. (There's probably a system-wide equivalent)
    • GNOME (and probably KDE as well) has its own resolution settings, which seems to override the xrandr change. So if using GNOME, configuration should be simply changed from within the GNOME tools..

Good stuff. It's always nice to see how things got better in few years. Still, in my opinion xorg has many problems (and slow development cycle), and might be the weakest link on Linux desktops. Goodbye!

/etc/mtab weirdness

There are many ways to fetch the list of currently-mounted-devices: read the files /etc/mtab, /proc/mounts, or exec /bin/mount, /bin/df.

I've been arguing with a colleague (Yaniv), that relying on /etc/mtab is no much worse than relying on /proc/mounts. But after we inspected it on Linux & Solaris (/etc/mnttab), I figured out that I was pretty wrong, and learned some new surprising facts:

On Linux:

  • /proc/mounts is a read-only, kernel-generated file.
  • /etc/mtab (Linux) is a regular file. It's kept up-to-date because the mount/umount commands modify it. It can be modified by a root user, moved and even deleted!
  • df command is using /etc/mtab, thus after rm'ing /etc/mtab, df would stop functioning.
  • mount command doesn't care about /etc/mtab, probably uses /proc/mounts or some internal kernel structure.

On Solaris (prepare for some weird stuff now):

  • Solaris has got /etc/mnttab, but no /proc/mounts equivalent.
  • /etc/mnttab is a mounted filesystem, of the mntfs type. So it's somewhat similar to /proc/mounts on Linux. It cannot be modified.
  • /etc/mnttab is actually a directory! (a mount point has to be a directory..)
  • /etc/mnttab can be unmounted, renamed, rmdir'd (when unmounted) and mounted anywhere else.
  • both df and mount rely on /etc/mnttab, thus not functioning when it's absent

On HP-UX:

  • /etc/mnttab, which is a regular file, is similar to /etc/mtab on Linux.

And on another, non-related subject: looks like Debian Lenny has got only 80 bugs to go (as of 19/01/09)! Go Lenny!

Radio Buttons: a bad design?

Just a thought: once a user clicks on some radio button, it'll be selected, but the user will have no standard way to remove/undo this selection. The only possibility is to switch to another radio button on the same radio button group. As far as I know*, this behavior occurs on all popular GUIs, including web, windows forms, qt and gtk, and probably others.

It's been like that for so many years, isn't it time to add a "deselect radio button" standard? Just like a checkbox, a single click would be a simple enough way to undo a selection. For special cases, a "ForceSelection" property may indicate that this radio button group cannot be deselected, to preserve the current behavior.

* I merely researched this topic, it's a just-a-thought kind of post and might be inaccurate.

HTML "name" attribute, Firefox misbehaves

It's been a long time since I wrote something about web-dev, that's because I code less web-stuff recently 🙂

"id" vs. "name" attributes

so far, I thought that "id" should be used for unique IDs, and "name" can be used for non-unique names, i.e. multiple HTML tags with the same name. I've been using document.getElementsByName(str) to get an array of elements with the same name.

Today I've figured out that it's only partially legal: the name attribute can be used only for specific elements (such as INPUT), but cannot be used on many elements (such as DIV). For some reason, Firefox accepts the name tag for any HTML element, while IE follows HTML 4.01 and doesn't accept name tags for "illegal" HTML tags.

Proof of concept

The next piece of JS/HTML code, gives different results on both browsers:

<div name="foo">bla</div>
<script type="text/javascript">
alert(document.getElementsByName("foo").length)
</script>

Results:

  • Firefox 3: 1
  • IE 7: 0

Here is a nice explanation with a full list of "name"-allowed HTML tags.