HAL-0.5.9.1

Introduction to HAL

HAL is a hardware abstraction layer, which is a piece of software that provides a view of the various hardware attached to a system. In addition to this, HAL keeps detailed metadata for each piece of hardware and provides hooks such that system and desktop-level software can react to changes in the hardware configuration in order to maintain system policy.

The most important goal of HAL is to provide plug-and-play facilities for UNIX-like desktops with focus on providing a rich and extensible description of device characteristics and features. One example of the functionality provided by HAL is when you plug in a USB storage device. HAL can automatically create a mount point in /media and mount the device.

Package Information

Additional Package Download

Required Hardware Data

HAL Dependencies

Required

D-Bus GLib Bindings-0.74 and XML::Parser-2.34

Recommended

Optional (to Build hal-device-manager)

Python-2.5.2

Optional (to Create Documentation)

libxml2-2.6.31 and xmlto

Optional

GTK-Doc-1.8, libusb-0.1.12, Parted*, libsmbios, PolicyKit, and intltool-0.35.5

* Use the following command after changing into the HAL source directory to modify the package configure script if you have Parted version 1.8.7 installed.

sed -i -e   's%, 1.8.6%&, 1.8.7%' \
       -e   's% or 1.8.6%/1.8.6 or 1.8.7%' \
       -e   's%6))%6) ||\
            (major == 1 \&\& minor == 8 \&\& micro == 7))%' \
    configure

User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/hal

Installation of HAL

You must create a dedicated user and group before installing the package. Though the default BLFS instructions run the HAL daemon as the root user, a configuration file is installed which has the dedicated user's name hard-coded in it. This causes a confusing message to be generated when starting the D-BUS daemon. Issue the following commands as the root user:

groupadd -g 19 haldaemon &&
useradd -c "HAL Daemon User" -d /dev/null -u 19 \
        -g haldaemon -s /bin/false haldaemon

Install HAL by running the following commands:

./configure --prefix=/usr \
            --sysconfdir=/etc \
            --libexecdir=/usr/lib/hal \
            --localstatedir=/var &&
make

To test the results, issue make check.

Now, as the root user:

make install

Install the HAL hardware data with the following commands:

tar -xf ../hal-info-20070618.tar.gz &&
cd hal-info-20070618 &&
./configure --prefix=/usr

Finally, as the root user:

make install

Command Explanations

--libexecdir=/usr/lib/hal: This parameter forces the installation of libexec files to /usr/lib/hal instead of /usr/libexec.

--localstatedir=/var: This parameter forces the creation of the pid file to /var/run/hald instead of /usr/var/run/hald.

--enable-docbook-docs --docdir=/usr/share/doc/hal-0.5.9.1: If libxml2-2.6.31 and xmlto are available, these parameters enable the HAL specification documentation to be built.

Run-Time Dependencies

A few more packages enable more functionality in HAL at run-time. These include Eject, ConsoleKit, dmidecode, Device-mapper, Cryptsetup-LUKS, and pm-utils.

The hal-device-manager program requires several additional Python modules to be available at runtime. These are D-Bus Python Bindings-0.82.0, PyGTK-2.10.6 (including the gtk and gtk.libglade modules), and Gnome-Python-2.18.2 (including the gnome.ui module).

Configuring HAL

Config Files

/etc/dbus-1/system.d/hal.conf, /etc/dbus-1/system.d/halusers.conf and /etc/hal/*

Configuration Information

Allowing users to invoke HAL methods

The default setup for HAL is to allow only certain users to invoke methods such as Mount(). These are the root user and the user determined to be at the active console using pam_console. If you are not set up to use Linux-PAM-0.99.10.0 and pam_console, create a group that is allowed to invoke HAL methods with the following commands:

groupadd -g 61 halusers &&
cat > /etc/dbus-1/system.d/halusers.conf << "EOF"
<!DOCTYPE busconfig PUBLIC
 "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>

 <!-- Allow users in the halusers group invoke HAL methods -->
 <policy group="halusers">
  <allow send_interface="org.freedesktop.Hal.Device.SystemPowerManagement"/>
  <allow send_interface="org.freedesktop.Hal.Device.LaptopPanel"/>
  <allow send_interface="org.freedesktop.Hal.Device.Volume"/>
  <allow send_interface="org.freedesktop.Hal.Device.Volume.Crypto"/>
 </policy>

</busconfig>
EOF

Now add the users you would like to the halusers group to use HAL.

usermod -a -G halusers <username>

Note that these users still need to have appropriate permissions to access the devices that HAL will invoke its methods on.

With the above configuration in place, authorized users now have the ability to unmount disk partitions mounted at non-standard locations such as /pub. If you'd like to restrict this policy to only drives which are considered removable or hotpluggable, add the following configuration file as the root user:

cat > /etc/hal/fdi/policy/no-fixed-drives.fdi << "EOF"
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- -->

<!-- Don't allow HAL methods on disks that are not
     removable or hotpluggable -->

<deviceinfo version="0.2">
<device>
  <match key="@block.storage_device:storage.hotpluggable" bool="false">
    <match key="@block.storage_device:storage.removable" bool="false">
      <merge key="volume.ignore" type="bool">true</merge>
    </match>
  </match>
</device>
</deviceinfo>
EOF
Installing mount helpers

HAL only provides the methods such as Mount() to act on hardware. In order to take advantage of these, a HAL event handler such as gnome-volume-manager-2.17.0 or Ivman should be installed.

Changing default mount options

In some cases, it is necessary to specify some default mount options for filesystems. E.g., in non-English environments, the iocharset and codepage options are needed for filesystems of Windows origin in order to show national characters correctly. Also, due to a bug in the Linux kernel version in LFS (2.6.22.x), you may want to pass the usefree option to vfat filesystems in order to reduce the time needed to determine the amount of free space on the filesystem.

Google search results for “hal default mount options” are still full of recommendations to create *.fdi files mentioning either volume.policy or storage.policy keys. Such recommendations worked for HAL-0.4.x only and are invalid now. For HAL-0.5.9.1, mount options are expected to be handled as follows:

  • An event handler from the desktop environment receives an event describing the newly-added storage device.

  • If the storage device is not already mentioned in /etc/fstab, mount options are fetched from a database of user preferences, which is specific to the desktop environment, and passed back to HAL. This process can be influenced by the filesystem type and possibly other volume properties available from HAL.

  • If the options are in the list of permitted ones, HAL mounts the volume.

The important point above is that the configuration procedure is desktop-specific. However, as of December, 2007, only GNOME allows the user to set default mount options on a per-filesystem basis, as described in the next paragraph. KDE allows the mount options to be set only on a per-volume basis, not per-filesystem, which is a bug, because, as mentioned in the report, “for every new device (let's say your friend's USB stick) you have to first not mount it, then change options and then mount”. Xfce, if compiled with HAL support, hard-codes the mount options without any means to override them, which is even worse. In KDE and Xfce, if the built-in default mount options are not suitable, it is needed to mention every possible removable storage device in /etc/fstab with the correct options, thus mostly defeating the point of installing HAL.

In order to adjust the default mount options, GNOME users should change the /system/storage/default_options/[fs_type]/mount_options GConf key either using GConf Editor-2.18.0, or from the command line, as demonstrated in the following example:

gconftool-2 --type list --list-type=string \
    --set /system/storage/default_options/vfat/mount_options \
    "[shortname=mixed,uid=,usefree,iocharset=koi8-r,codepage=866]"

See more details in the gnome-mount(1) manual page.

Adding allowed mount options

The list of mount options permitted in the default HAL configuration resides in the /usr/share/hal/fdi/policy/10osvendor/20-storage-methods.fdi file. GNOME and KDE users may want to use options not in this list (in the above example, this applies to the usefree option). In this case, as root user, create a custom policy file that mentions unknown mount options:

cat > /etc/hal/fdi/policy/user-options.fdi << "EOF"
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- -->

<!--
This file is used to set custom options to the HAL policy settings.
The default policy settings are defined in files contained in the
/usr/share/hal/fdi/policy subdirectories. User defined customizations
should be in files contained in the /etc/hal/fdi/policy directory.
-->

<deviceinfo version="0.2">
<device>

<!-- this is to be able to mount media in drives we cannot poll,
     e.g. IDE Zip Drives and PC style floppy drives -->
<match key="storage.media_check_enabled" bool="false">
  <match key="storage.no_partitions_hint" bool="true">
    <append key="volume.mount.valid_options" type="strlist">usefree</append>
    <!-- Insert other options here -->
  </match>
</match>

<match key="volume.fsusage" string="filesystem">

  <!-- allow these mount options for vfat -->
  <match key="volume.fstype" string="vfat">
    <append key="volume.mount.valid_options" type="strlist">usefree</append>
    <!-- Insert other options here -->
  </match>
</match>

</device>
</deviceinfo>
EOF

Boot Script

To automatically start the hald daemon when the system is rebooted, install the /etc/rc.d/init.d/haldaemon bootscript from the blfs-bootscripts-20080816 package.

[Important]

Important

If the system-wide D-BUS daemon was running during the installation of HAL, ensure you stop and restart the D-BUS daemon before attempting to start the hald daemon.

make install-haldaemon

Contents

Installed Programs: hal-device, hal-device-manager, hal-disable-polling, hal-find-by-capability, hal-find-by-property, hal-get-property, hal-is-caller-locked-out, hal-lock, hal-set-property, hald and lshal
Installed Libraries: libhal.{so,a} and libhal-storage,{so,a}
Installed Directories: /etc/hal, /usr/include/hal, /usr/lib/hal, /usr/share/doc/hal-0.5.9.1, /usr/share/hal, /var/cache/hald, /var/lib/hal, and /var/run/hald

Short Descriptions

hal-device

is used to create, remove or show a HAL device.

hal-device-manager

shows a graphical representation of all the devices HAL is aware of. Here is a screenshot of hal-device-manager communicating with the HAL daemon and displaying a tree of device objects. The shown properties in the screenshot are for a device object representing a hard disk.

hal-disable-polling

can be used to to disable and enable media detection on drives with removable storage.

hal-find-by-capability

prints the Unique Device Identifiers for HAL device objects of a given capability.

hal-find-by-property

prints the Unique Device Identifiers for HAL device objects where a given property assumes a given value.

hal-get-property

retrieves a property from a device.

hal-set-property

attempts to set property for a device. Note that, due to security considerations, it may not be possible to set a property.

hal-is-caller-locked-out

determines if a specific caller is locked out of a specific D-Bus interface on a specific device.

hald

is the HAL daemon program.

lshal

shows all devices and their properties. If the --monitor option is given then the device list and all devices are monitored for changes.

libhal.{so,a}

contains the API functions required by the HAL programs.

libhal-storage.{so,a}

contains the API functions required by the HAL storage and volume utility programs.

Last updated on 2008-08-11 19:15:25 -0500