gnome-web-photo segfaults! OH NOES!

February 24th, 2010

We capture images from beautiful web pages all over the world by exposing the gnome-web-photo package through a simple web service. After moving the service to a new server today gnome-web-photo suddenly started segfaulting.

Running the application as the same user as the web server worked (after fixing the home directory so that gconf etc was able to create its files), but when running in the web server process itself things segfaulted.

The next attempt was to run both the working and non-working version through strace and see what the difference were, and apparently things segfaulted when the working process accessed <home directory>.mozilla/. This was the first access to anything inside the home directory of the user, which provided the solution:

When the process was running under the web server, the HOME environment variable was not set, but while running under the user from the shell (through su -), it was present. gnome-web-photo (or Firefox?) apparently does not feature any sort of fallback if the HOME environment variable is missing and segfaults instead.

Maybe that could be a patch for the weekend, but hey, the Olympic Games are on!

Fixing dpkg / apt-get Problem With Python2.6

February 7th, 2010

While trying to upgrade to Python 2.6 on one of my development machines tonight I was faced by an error message after running apt-get install python2.6:

After unpacking 0B of additional disk space will be used.
Setting up python2.6-minimal (2.6.4-4) ...
Linking and byte-compiling packages for runtime python2.6...
pycentral: pycentral rtinstall: installed runtime python2.6 not found
pycentral rtinstall: installed runtime python2.6 not found
dpkg: error processing python2.6-minimal (--configure):
 subprocess post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of python2.6:
 python2.6 depends on python2.6-minimal (= 2.6.4-4); however:
  Package python2.6-minimal is not configured yet.
dpkg: error processing python2.6 (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python2.6-minimal
 python2.6
E: Sub-process /usr/bin/dpkg returned an error code (1)

Attempting to install python2.6-minimal wouldn’t work, attempting to install python2.6 proved to have the same problem.

Luckily the Launchpad thread for python-central provided the answer: Upgrade python-central first!

:~# apt-get install python-central
[snip]
Setting up python2.6 (2.6.4-4) ...
Setting up python-central (0.6.14+nmu2) ...
:~#

A Quick Introduction to chmod and Octal Numbers

January 22nd, 2010

Someone asked what the difference between doing a chmod 777 and chmod 755 is today, and hopefully this short, informal post will provide you with the answer (if you want to jump straight through to the conclusion, man chmod).

Octal Numbers

The number you provide as an argument to chmod is an octal number telling chmod what access you want to provide to a file (or a directory, device, etc – an entry on the file system). The number are in fact three discreet values, 7, 5 and 5. Each of the values correspond to a set of three bits, either one being zero or one. Three bits makes up a value from 0 – 7, hence an octal number (a decimal number has the digits 0 – 9 for each digit, an octal number has 0 – 7, a binary number has 0 – 1, a hexadecimal number has 0 – F (15)).

If you tried to count from 0 to 10 (decimal) in octal, it’d be: 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12. 12 in octal is the same value as 10 in decimal. The big difference is that both octal and decimal maps very neatly on top of binary numbers, being exactly three or four bits.

The usual way to write an octal number in a programming language is by appending a zero in front of it, such as 0755. This tells the compiler that the number is written in octal notation, and the value is then parsed as such. chmod parses all numbers as octal, and does actually handle four digits. Since missing digits are considered to be zero, the first digit is usually not included (or simply as a zero – which will look the same as the representation used in certain programming languages). The first, usually unused digit, have a special meaning, setting the “set user id” (suid), “set group id” (guid) or the “restricted deletion” or “sticky” attributes (you can read more about these options in the manual page).

File permissions

Now that we know what an octal number is, it’s time to look at how the file permissions work. Each file has three sets of permissions, one set for the user owning the file, one set for the group owning the file and one set for anyone else. If you want to take a look at these values on a unix based system, simply type ls -l to list files in a verbose way. Your result will look something like:

-rw-r--r--  1 mats mats        35 2008-08-23 20:24 IMPORTANTFILE

The permissions are listed in the first column, containng “-rw-r–r–”. The first character “-” indicates if the file is a directory (d), if the suid or guid bits are set etc.

This leaves us with “rw-r–r–” – the three sets of permissions. “rw-” is for the user owning the file, “r–” is for the group owning the file and the last “r–” are for anyone else (or ‘other’ as it’s called). The “r” means read, the “w” means write and the currently missing letter is “x”, which means execute (for files) or search (for directories). The “execute” setting is used to let bash (or another shell) attempt to run the file as a script, attempting to parse the first line as a path to the interpreter for the file (i.e. #!/usr/bin/python).

We have three flags (read, write, execute) that can be either on or off. This should remind us of three bits, either being 0 (not set) or 1 (set). And an octal digit is exactly three bits. This means that an octal digit maps exactly to the bit sequence needed to set permissions for a file. A 7 is “111″, a 5 is “101″, a 4 is “100″ and so on. Mapping this to permissions:

7 = 111 = rwx
6 = 110 = rw-
5 = 101 = r-x
4 = 100 = r--
3 = 011 = -wx
2 = 010 = -w-
1 = 001 = --x
0 = 000 = ---

When calling chmod 755 on a directory we’re telling chmod to “set the read, write and search bits for me, the read and search bits for the group and the read and search bits for other users” (‘search’ for directories, ‘execute’ for files).

Another example is 644 that maps to 110 100 100, which again maps to “rw-r–r–” which usually is the standard access mode for files (and 755 for directories).

Handling Permissions With Symbols

I’m now going to eliminate the need for remembering everything I’ve written so far in the post, but at least you’ll know what people are talking about when they’re telling you to chmod something this-or-that.

You can also use the symbols directly with chmod, either adding, removing or setting the permissions for one of the three groups.

Examples:

To remove all access for other users (but leaving group and user intact)
chmod o-rwx file

To give everyone read access
chmod a+r file

To give everyone read – and search – access
chmod a+rx directory

To set particular user modes for each group
chmod u=rw,g=w,o=w file (a file that the user can read, but anyone can write to)

And with that I chmod this post a+r.

Making Spotify, Wine and PulseAudio Play Together

January 16th, 2010

In what has now become a series on this marvellous blog, we’re diving into how to make PulseAudio play nice with Spotify running under Wine. After yesterday’s article about getting any sound through PulseAudio at all, the next issue that surfaced was that the output from Spotify running under Wine were just garbled noise. This worked with the previous ALSA or OSS setup, but with PulseAudio everything went haywire!

Luckily the massive wisdom of teh intarwebs came to the rescue again, this time through an almost three year old post by Paul Betts: “Make Wine and PulseAudio Get Along“.

The solution is to first use padsp winecfg to configure padsp for a specific process, then use padsp to redirect any access to /dev/dsp while the provided application runs.

First run:

padsp winecfg

Then add padsp to your spotify startup script (or if you do this manually, just .. remember to type it. OK?):

padsp wine "C:\program files\spotify\spotify.exe"

Restart Spotify and enjoy the massive collection of great music!

Missing Devices or Sound Card in Pulse Audio

January 15th, 2010

After getting the missing sound control panel in Ubuntu back yesterday, the next problem that turned up was that no actual applications would play any sound – other than the annoying beep! beep! beep!

The reason is that after the pulseaudio configuration has been installed, pulseaudio it self may be missing all it device drivers and other packages.

The solution for this issue can be found at the page for PulseAudio at the Ubuntu Wiki.

Install the missing PulseAudio packages through APT:

sudo apt-get install libasound2-plugins "pulseaudio-*" paman padevchooser paprefs pavucontrol pavumeter

Restart the application that needs sound support and everything should work. If you’re still not getting any sound, check the PulseAudio device configuration (by default installed under Applications, Sound and Video, PulseAudio Device Chooser) and that your device shows up there (mine didn’t before installing the above packages).

When the Ubuntu Sound Control Panel Doesn’t Show Up

January 14th, 2010

After upgrading from Ubuntu 9.0 to 9.10 the other day, I suddenly got a very annoying beep every time I saved a file in NetBeans. Horrible stuff! Disabling it in NetBeans seems impossible (and Firefox makes the same sound when it encounters an error), so removing it in the Ubuntu Sound Configuration Panel sounded (!) like the best option.

One problem: The Sound Control Panel (when selecting System -> Preferences -> Sound) didn’t open. It attempts to load, but then disappears without a trace. I couldn’t find a notice in any of the logfiles either, so my only hope of a remedy was the global debugging power of teh intarwebs.

This was actually harder than I imagined, as I had to wade through large amounts of documentation of how to open the control panel at all. I had found the menu item, but it didn’t work.

Luckily someone had documented several issues at a page named “Sound Solutions for Ubuntu 9.04“, and while I didn’t have the exact problems listed there, they mentioned the required packages for pulseaudio and the GUIs.

Installing the padevchooser package should pull in all the dependencies:

root@ubuntu:~# apt-get install padevchooser

(Use sudo apt-get install padevchooser if you’re not root)

At the same split second the installer finished, the sound configuration dialog opened and I were able to switch to the NO SOUND scheme in Ubuntu. No beeps!

Keyboard Not Working in Xorg After Booting Ubuntu

May 28th, 2009

I’ve had a weird issue a couple of times on my work computer, where the keyboard and the mouse does not respond in Xorg after rebooting. As I only reboot my work computer every 80 days or so, I tend to forget the reason why it happens between each boot sequence.

The reason why the mouse and keyboard does not work after rebooting at my computer is that HAL or DBUS failed to start. I’ve not dug further into this issue, as it doesn’t happen very often. The solution:

(you can switch to a text console by pressing ctrl+alt+f1, your keyboard will work there)

  1. /etc/init.d/dbus start
  2. /etc/init.d/hal start

Restart X / GDM:

  1. /etc/init.d/gdm restart

Switch back to the Xorg terminal (alt+f7) and hopefully your keyboard and mouse will yet again work!

Mouse Stuck in Lower Right Corner in Ubuntu Intrepid under VMWare?

August 1st, 2008

If your mouse pointer is stuck in the lower right corner after upgrading to the current alpha version of Ubuntu, Intrepid, the reason is that the vmmouse driver got borked somewhere between Hardy and the current version of Intrepid. This means that you’ll only see “Moving to desktop 2″ (or whatever desktop you have in the lower right corner). The fix is to change the reference to ‘vmmouse‘ in /etc/X11/xorg.conf to ‘mouse‘. This is not as good (you’ll not be able to move your mouse pointer from your host to your vmware machine seamless any longer), but at least it works.

You can track the current progress over at trackpad: Ubuntu Bug #248521.