From 501cc4dbc980d1e625bbf8cf4ef2d730056dacd9 Mon Sep 17 00:00:00 2001 From: Ignacio Vazquez-Abrams Date: Jul 07 2005 23:02:41 +0000 Subject: Added Per Bjornsson's hotplug files --- diff --git a/libifp.hotplug b/libifp.hotplug new file mode 100644 index 0000000..3c560be --- /dev/null +++ b/libifp.hotplug @@ -0,0 +1,50 @@ +#!/bin/bash +# +# /etc/hotplug/usb/libifp +# +# Cloned off the usbcam hotplug script that is shipped by +# Red Hat with gphoto2. In principle we could just call that one, +# but it's ugly to depend on a camera driver in order to talk +# to an audio player... +# +# Sets up newly plugged-in iRiver iFP device so that the user who owns +# the console according to pam_console can access it from user space +# +# Note that for this script to work, you'll need all of the following: +# a) a line in the file /etc/hotplug/usb/libifp.usermap that corresponds +# to the iFP device you are using. +# b) a setup using pam_console creates the respective lock files +# containing the name of the respective user. You can check for that +# by executing "echo `cat /var/{run,lock}/console.lock`" and +# verifying the appropriate user is mentioned somewhere there. +# c) a Linux kernel supporting hotplug and usbdevfs +# d) the hotplug package (http://linux-hotplug.sourceforge.net/) +# +# All of the above are expected to be true on recent Red Hat and Fedora +# distributions in the default install. +# +# In the usermap file, the first field "usb module" should be named +# "libifp" like this script. +# + +if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ] +then + # New code, using lock files instead of copying /dev/console permissions + # This also works with non-gdm logins (e.g. on a virtual terminal) + # Idea and code from Nalin Dahyabhai + if [ -f /var/run/console/console.lock ] + then + CONSOLEOWNER=`cat /var/run/console/console.lock` + elif [ -f /var/lock/console.lock ] + then + CONSOLEOWNER=`cat /var/lock/console.lock` + else + CONSOLEOWNER= + fi + if [ -n "$CONSOLEOWNER" ] + then + chmod 0000 "${DEVICE}" + chown "$CONSOLEOWNER" "${DEVICE}" + chmod 0600 "${DEVICE}" + fi +fi diff --git a/libifp.spec b/libifp.spec index cbf269a..d77bf95 100644 --- a/libifp.spec +++ b/libifp.spec @@ -7,6 +7,8 @@ Group: System Environment/Base License: GPL URL: http://ifp-driver.sourceforge.net/ Source0: http://dl.sourceforge.net/ifp-driver/%{name}-%{version}.tar.gz +Source1: libifp.hotplug +Source2: libifp.usermap BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: libusb-devel doxygen @@ -37,6 +39,8 @@ make %{?_smp_mflags} rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT find $RPM_BUILD_ROOT -name \*.la -exec rm {} \; +install -D -m 0755 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/hotplug/usb/libifp +install -D -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/hotplug/usb/libifp.usermap %clean rm -rf $RPM_BUILD_ROOT @@ -49,6 +53,7 @@ rm -rf $RPM_BUILD_ROOT %doc ChangeLog COPYING README TODO %{_bindir}/* %{_libdir}/*.so.* +%{_sysconfdir}/hotplug/usb/* %files devel %defattr(-,root,root,-) @@ -58,5 +63,8 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man3/* %changelog +* Thu Jul 7 2005 Ignacio Vazquez-Abrams +- Added Per Bjornsson's hotplug files + * Wed Jun 29 2005 Ignacio Vazquez-Abrams 1.0.0.1-1 - Initial RPM release diff --git a/libifp.usermap b/libifp.usermap new file mode 100644 index 0000000..4cf656d --- /dev/null +++ b/libifp.usermap @@ -0,0 +1,37 @@ +# This file is shipped with libifp (based on a similar file in +# the libsane package as shipped by Red Hat). +# +# The entries below are used to detect an iRiver iFP portable music +# player when it is plugged in and then run the libifp hotplug script to +# change the ownership and permissions on the "device node" used by +# libusb. +# +# The 0x0003 match flag means the device is matched by its vendor and +# product IDs. +# +# Sample entry (replace 0xVVVV and 0xPPPP with vendor ID and product ID respectively) : +# libifp 0x0003 0xVVVV 0xPPPP 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +# +# usb module match_flags idVendor idProduct bcdDevice_lo bcdDevice_hi bDeviceClass bDeviceSubClass bDeviceProtocol bInterfaceClass bInterfaceSubClass bInterfaceProtocol driver_info +# +# +# The following list already contains the known iRiver iFP devices, with the +# product IDs copied from the header file for libifp. +# If it doesn't work for yours, try adding an appropriate entry. + +# iRiver iFP-1XX +libifp 0x0003 0x4102 0x1001 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +#iRiver iFP-3XX +libifp 0x0003 0x4102 0x1003 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +#iRiver iFP-5XX +libifp 0x0003 0x4102 0x1005 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +#iRiver iFP-7XX +libifp 0x0003 0x4102 0x1007 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +#iRiver iFP-8XX +libifp 0x0003 0x4102 0x1008 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +#iRiver iFP-9XX +libifp 0x0003 0x4102 0x1009 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +#iRiver iFP-10XX +libifp 0x0003 0x4102 0x1010 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +#iRiver N10 +libifp 0x0003 0x4102 0x1011 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000