SpaceFM & Udev
Below is an update on what’s happening with SpaceFM (and devmon) with regard to udev, udisks2, and related matters. None of this has hit release yet, but some of it is currently available on github for those who would like to help with early testing, or just give it a try.
Udisks is a layer that sits between udev and applications – it is supposed to make it easier for applications and user scripts to manipulate disks, detect device changes, mount removable devices without a root password, etc. Unfortunately this component is developed almost exclusively by Red Hat Gnome developers who are increasingly making it less than helpful. I’ve made no secret of what I think of udisks2. As soon as I saw it, I started exploring ways to remove it.
The next release of SpaceFM, which is currently available on github in the ‘next’ branch, replaces udisks with internal support for libudev, thus allowing SpaceFM to go directly to udev for its device manager needs. This includes three new custom components:
- A custom udev monitor has been added which connects to a udev socket. This monitor lets SpaceFM know when a device has a been added or removed, and when device properties have changed. Previously, SpaceFM used the udisks monitor function for this.
- A custom mount monitor has been added which monitors the system’s mount points and alerts SpaceFM to changes. This lets SpaceFM know when a device has been mounted or unmounted, even if it didn’t initiate the action. Because udev does not report these events, a separate monitor is needed which ties into /proc. Previously, SpaceFM used udisks for this – udisks included mount changes in its monitor function.
- Device information functions have been added to SpaceFM so it can use udev functions to lookup information about a device, such as whether the device is internal, removable, or optical, what media it contains or supports, what filesystem is on the device, the size of the device, etc. These functions were added using code excerpts from the udisks 1.0.4 sources, with a few fixes and improvements, and also some simplification. Previously, SpaceFM ran the udisks command line tool to obtain device information. However, the udisks2 command line tool is crippled – for example, you can no longer use it to determine if a drive is optical or not, what media it contains, as well as other deficiencies.
In initial tests, this code has been running well. There aren’t many noticeable changes – the new code duplicates most of what udisks used to provide. There is a little less information provided about special devices like encrypted drives, but SpaceFM did not use this information internally, it only displayed it in the device properties, and even then it was minimal. Another difference is that SpaceFM does not poll devices as udisks sometimes did. Some polling could be added if necessary, but thus far this hasn’t been an issue, even with my less-than-new hardware.
With these changes, SpaceFM doesn’t use udisks for anything except mounting and unmounting devices without a root password needed. As before, it runs the udisks command line tool to do so, and it now supports both udisks v1 and v2 for this. Also, two new options have been added to allow the user to set custom mount and unmount commands:
Thus, any use of udisks is optional, although still somewhat required if you want to mount without root. Mounting and unmounting without root cannot be handled internally by SpaceFM because something needs to run as root to do so (in udisks’s case, it runs a root daemon).
If you’d like to give the ‘next’ branch SpaceFM a try, just check the README for instructions (see the BUILD NEXT section) – just a few simple commands. Note that there are two new build dependencies for this version: libudev0 and libudev-dev
Because I don’t want udisks to be required at all (and because I don’t even want it installed on my system), I’m working on a small replacement tool for this. Basically, this will be a functional replacement for the udisks v1 command line tool.
Here are some design goals for this new tool (
which doesn’t have a name yet called udevil):
- It will use a combination of the udisks v1 and v2 command line usage, so it can emulate both. It will provide a limited set of functions, such as mount, unmount, monitor, info, and enumerate. Thus scripts like devmon will be able to use this tool rather than udisks. (The udisks APIs will not be provided, however, just the command line.)
- Its output will emulate udisks v1, so scripts designed to use udisks v1, such as devmon, will be able to use this tool instead.
- Because there is no real need for a daemon, root access will likely be done by setting the UID bit, which basically means the program can be run as root without the root password, relying on internal authentication and security checks. This allows you to control who can execute the program, and thus who can mount devices, by setting permissions and groups, rather than all the complexities (and bugs) of policykit/consolekit. Some additional security options will be available in a configuration file. Although some people have a knee-jerk reaction to setting UID, as it is sometimes used poorly, it is a legitimate method (for example, the passwd program uses it), and this is a perfect use for it. If done well, it will provide security without the overhead of a daemon. One of the biggest problems with udisks is its use of policykit and consolekit – many users disable the security rules just to get it working at all, which obviously isn’t helpful. IMO, these solutions create more problems than they solve. You can read more about suid in this article.
- It will optionally be able to use udisks v1 or v2 to perform mounting, in case a user prefers to have the udisks daemon handle root mounting, in which case the UID bit can be unset, but still wants to use this tool with a script like devmon.
- I would like this tool to extend on udisks abilities in a few areas, including the ability to specify a custom mount point when mounting, and the ability to mount ISO files as a non-root user.
Thus this small tool will replace all need for udisks, policykit, devicekit, and consolekit, for those who don’t want them installed. This tool will allow SpaceFM to be completely free of udisks and all the associated *kits, but will not be required. You will be able to use udisks v1, udisks v2, this tool, or any other program or script you want to mount and unmount devices in SpaceFM. For future versions of devmon, you will be able to use just this tool without any need for udisks and the *kits, or you can use udisks v1 alone, or use a combination of udisks v2 and this tool.
I already have a working prototype which nicely emulates udisks v1 monitor and info functions, including a mount monitor – this protoype was also part of SpaceFM’s recent changes. This prototype won’t be released, but it will be used to build a release version.
This tool aims to provide a lightweight replacement for udisks, particularly for those running lightweight desktops, and for situations where the use of the *kits is overkill and creates problems. Like anything, it will have its limitations, but I think another choice in this area will be helpful.
UPDATE May 22 2012:udevil is now available for testing
Sorry, the comment form is closed at this time.