how to use HAL to set permissions for Garmin GPS usb device

Asked by Ulf Mehlig

On Ubuntu Jaunty (x86_64), I have difficulties with file permissions of my Garmin GPSmap device. A number of older postings recommend vaguely that HAL + policykit should be used to set the respective file permissions.

lshal for the GPS device yields

udi = '/org/freedesktop/Hal/devices/usb_device_91e_3_noserial'
  info.linux.driver = 'usb' (string)
  info.parent = '/org/freedesktop/Hal/devices/usb_device_1d6b_1_0000_00_1d_2' (string)
  info.product = 'GPSmap (various models)' (string)
  info.subsystem = 'usb_device' (string)
  info.udi = '/org/freedesktop/Hal/devices/usb_device_91e_3_noserial' (string)
  info.vendor = 'Garmin International' (string)
  linux.device_file = '/dev/bus/usb/004/010' (string)
  linux.hotplug_type = 2 (0x2) (int)
  linux.subsystem = 'usb' (string)
  linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:1d.2/usb4/4-1' (string)
  usb_device.bus_number = 4 (0x4) (int)
  usb_device.can_wake_up = false (bool)
  usb_device.configuration_value = 1 (0x1) (int)
  usb_device.device_class = 255 (0xff) (int)
  usb_device.device_protocol = 255 (0xff) (int)
  usb_device.device_revision_bcd = 1 (0x1) (int)
  usb_device.device_subclass = 255 (0xff) (int)
  usb_device.is_self_powered = false (bool)
  usb_device.linux.device_number = 10 (0xa) (int)
  usb_device.linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:1d.2/usb4/4-1' (string)
  usb_device.max_power = 300 (0x12c) (int)
  usb_device.num_configurations = 1 (0x1) (int)
  usb_device.num_interfaces = 1 (0x1) (int)
  usb_device.num_ports = 0 (0x0) (int)
  usb_device.product = 'GPSmap (various models)' (string)
  usb_device.product_id = 3 (0x3) (int)
  usb_device.speed = 12.0 (12) (double)
  usb_device.vendor = 'Garmin International' (string)
  usb_device.vendor_id = 2334 (0x91e) (int)
  usb_device.version = 1.1 (1.1) (double)

Based on informations I gathered from googling around I created the following fdi files:

/etc/hal/fdi/information/10-gps-devices.fdi :

<?xml version="0.2">
  <device>
    <match key="usb_device.vendor_id" int="0x91e">
      <match key="usb_device.product_id" int="0x3">
        <append key="info.capabilities" type="strlist">gps</append>
        <merge key="gps.platform" type="string">garmin</merge>
        <merge key="gps.garmin.interface" type="copy_property">linux.device_file</merge>
      </match>
    </match>
  </device>
</deviceinfo>

/etc/hal/fdi/policy/10-gps-devices.fdi

<?xml version="1.0" encoding="UTF-8"?>
<deviceinfo version="0.2">
  <device>
    <match key="info.capabilities" contains="gps">
      <match key="gps.platform" string="garmin">
        <append key="info.capabilities" type="strlist">access_control</append>
        <merge key="access_control.type" type="string">gps</merge>
        <merge key="access_control.file" type="copy_property">gps.garmin.interface</merge>
        <append key="access_control.grant_group" type="strlist">gps</append>
      </match>
    </match>
  </device>
</deviceinfo>

Afterwards, I used polkit-gnome-authorization to grant access to "Garmin GPS" to my user id. However, the device is still not accessible:

$ gpsbabel -t -w -i garmin -f usb: -o gpx -F test.gpx
Claim interfaced failed: could not claim interface 0: Operation not permitted

$ getfacl /dev/bus/usb/004/010
getfacl: Removing leading '/' from absolute path names
# file: dev/bus/usb/004/010
# owner: root
# group: root
user::rw-
group::rw-
other::r--

Do you have any suggestions how to fix this?
Thanks! Ulf

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Ulf Mehlig
Solved:
Last query:
Last reply:
Revision history for this message
Florian Diesch (diesch) said :
#1

I would create a rule for udev, see /etc/udev/rules.d/README and /lib/udev/rules.d/*

Revision history for this message
Ulf Mehlig (umehlig) said :
#2

Yes , but I read that udev is becoming obsolete ... There are indeed a number of descriptions how to get this working with udev, but I just wanted to know how it can be done with hal, if this is the way it ought to be done ...

Thanks a lot! Ulf

Revision history for this message
Ulf Mehlig (umehlig) said :
#3

Correction: HAL is becoming obsolete :-) In fact, the old udev rules that map devices to groups and use group access rights to read/write to the device in questions are obsolete, and udev-acls (package udev-extras in ubuntu) are apparently the upt-to-date tool ...

Ulf

Revision history for this message
Ulf Mehlig (umehlig) said :
#4

Martin Pitt informed me that udev-acls will be available in Ubuntu Karmic; he says that the respective udev rule should set ENV{ACL_MANAGE}="1" then. For now, the "old-fashioned" udev rules have to be used.

Ulf