Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 84628 - libgphoto2 /etc/hotplug/usb/usbcam and PAM
Summary: libgphoto2 /etc/hotplug/usb/usbcam and PAM
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Linux Gnome Desktop Team
URL:
Whiteboard:
Keywords:
: 99736 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-03-09 06:18 UTC by Christian Schmitt
Modified: 2008-01-30 16:16 UTC (History)
13 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
ebuild with pam_console USE flag (libgphoto2-2.1.5.ebuild,4.07 KB, text/plain)
2005-08-11 03:41 UTC, Rémi Cardona (RETIRED)
Details
patch for libgphoto2-2.1.5.ebuild (libgphoto2-2.1.5.ebuild.patch,931 bytes, patch)
2005-08-11 03:51 UTC, Rémi Cardona (RETIRED)
Details | Diff
based on the latest ebuild, but for version 2.1.6 (libgphoto2-2.1.6-r1.ebuild,4.07 KB, text/plain)
2005-09-13 15:18 UTC, Christian Schmitt
Details
patch for libgphoto2-2.1.6.ebuild (libgphoto.patch,1.06 KB, patch)
2005-10-06 16:18 UTC, Rémi Cardona (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Schmitt 2005-03-09 06:18:59 UTC
The file /etc/hotplug/usb/usbcam which libgphoto2 installs is responsible to set correct permissions on the USB camera device, however, this only works if the system is using PAM (USE=PAM). If this is not the case, the permissions are not set correctly. I solved the problem by using an example usbcam file from the gphoto documentation:

#!/bin/bash
# $Id: usbcam.group,v 1.3 2003/09/16 16:42:44 hun Exp $
#
# /etc/hotplug/usb/usbcam
#
# Sets up newly plugged in USB camera so that only members of the
# group

GROUP=usb

# can access it from user space. (Replace camera with the name of the
# group you want to have access to the cameras.)
#
# Note that for this script to work, you'll need all of the following:
# a) a line in the file /etc/hotplug/usermap that corresponds to the
#    camera you are using. You can get the correct lines for all cameras
#    supported by libgphoto2 by running "print-usb-usermap".
# b) a group "camera" where all users allowed access to the
#    camera are listed
# c) a Linux kernel supporting hotplug and usbdevfs
# d) the hotplug package (http://linux-hotplug.sourceforge.net/)
#
# In the usermap file, the first field "usb module" should be named
# "usbcam" like this script.
#

if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
then
    chmod o-rwx "${DEVICE}"
    chgrp "${GROUP}" "${DEVICE}"
    chmod g+rw "${DEVICE}"
fi

Maybe this should be changed in the ebuild?


Reproducible: Always
Steps to Reproduce:
1.Use a system without PAM support
2.Install libgphoto2
3.Plugin camera
Comment 1 Didier Link 2005-03-12 02:04:31 UTC
Additionnaly, with PAM-0.78-r2 and pam_console in USE, the script usbcam in /etc/hotplug/usb don't look at the right place for console.lock.

the script look for /var/{run,lock}/console.lock but it is in /var/run/console/console.lock

The fixe is easy and work well, just changing the path in the file !

Comment 2 Don Seiler (RETIRED) gentoo-dev 2005-05-02 07:21:31 UTC
I believe I suffer the same malady.  Only I don't have anything in my /var/run/console/ dir.
Comment 3 Don Seiler (RETIRED) gentoo-dev 2005-05-02 07:23:42 UTC
Of course I have -pam_console in USE.  :p

Anyway the script in portage is fubar.
Comment 4 Don Seiler (RETIRED) gentoo-dev 2005-05-02 08:58:14 UTC
Yes the user-provided script works great.  Is this what we used to do?  Just wondering when it stopped working.
Comment 5 gad.kadosh 2005-05-14 08:30:40 UTC
Obviously using pam_console to set the permissions is not a good idea, as udev should be in charge of setting device permissions. pam_console is really bad because not everyone is using it. 
Now, IMO the example brought here is also not optimal because again the permissions are set by hotplug instead of udev. And especially now that udev is the default in gentoo ...
Comment 6 Alastair Tse (RETIRED) gentoo-dev 2005-06-24 08:21:30 UTC
don't quite follow what is needed. does this mean we need a udev rule for cameras in libgphoto2?
Comment 7 Aquila 2005-07-08 11:51:22 UTC
I am having the same problem after upgrading to the latest stable pam: gphoto2 
won't set the right permissions any more. 
What's especially strange is the following comment in the current script:
# 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.
I don't have these files...
Comment 8 Andy Wang 2005-07-08 19:37:30 UTC
"Obviously using pam_console to set the permissions is not a good idea, as udev
should be in charge of setting device permissions. pam_console is really bad
because not everyone is using it."

Is this accurate here?  USB devices have their permissions set on not on their
dev node, but rather their entry in usbfs.  From what I understand, udev
maintains /dev, not USB file systems nodes.

I do find it weird that gentoo installs libgphoto's usbcam.console version
instead of the .group.  Why would/should the console user be required to use the
camera.  Plus combine that with the confusion of pam_console being disabled by
default it's kinda odd.
Comment 9 Mike Kelly 2005-07-09 11:06:11 UTC
I would agree that this is definitly frustrating. 

media-libs/libgphoto2 and media-gfx/gphoto2 have absolutely no dependencies on
PAM, but the default script put in /etc/hotplub/usb/usbcam requires pam...

While the above given script may not be perfect, it at least works for those of
us who do not use PAM... Maybe the ebuild should have a pam use flag to allow
people to choose?
Comment 10 Andy Wang 2005-07-09 13:51:24 UTC
Maybe that's a good solution.
Use the same pam_console USE flag.  If it's set, do what's currently done (copy usbcam.console).
If it's not set, use usbcam.group.

This would require that a camera group be added and user's be added to that group to get permissions to 
access it, but it's consistent with how gentoo handles usb scanners.
Comment 11 Jakub Moc (RETIRED) gentoo-dev 2005-07-21 00:30:03 UTC
*** Bug 99736 has been marked as a duplicate of this bug. ***
Comment 12 Rémi Cardona (RETIRED) gentoo-dev 2005-08-10 15:07:16 UTC
I'm trying out a small modification of the ebuild to add a pam_console USE flag.

So far things seem to emerge fine using usbcam.console with +pam_console and
usbcam.group otherwise. I looked at the sane-backends ebuild to see how they
added the "scanner" group, so I made this ebuild add a "camera" group.

I'll try things out with my Canon PowerShot tomorrow (batteries charging) and if
it works I'll post the ebuild here.

There are a number of questions I'm wondering right now (though it's quite late):
 - Are there any Gentoo policies regarding creating new groups, should someone
be contacted/notified about this ?
 - Should the group be created even if a user activates pam_console, in which
case the "camera" group is irrelevant ? (<= my biggest concern right now :)
 - I saw that the pam_console flag was only present in
/usr/portage/profiles/use.local.desc and so far only pam uses this flag. Again
can this flag be used without upsetting anyone or causing mayhem about Gentoo
policies I may not be aware of ?
 - Should I add PAM as a dep if pam_console is activated ?
 - ...

R
Comment 13 Rémi Cardona (RETIRED) gentoo-dev 2005-08-10 15:07:16 UTC
I'm trying out a small modification of the ebuild to add a pam_console USE flag.

So far things seem to emerge fine using usbcam.console with +pam_console and
usbcam.group otherwise. I looked at the sane-backends ebuild to see how they
added the "scanner" group, so I made this ebuild add a "camera" group.

I'll try things out with my Canon PowerShot tomorrow (batteries charging) and if
it works I'll post the ebuild here.

There are a number of questions I'm wondering right now (though it's quite late):
 - Are there any Gentoo policies regarding creating new groups, should someone
be contacted/notified about this ?
 - Should the group be created even if a user activates pam_console, in which
case the "camera" group is irrelevant ? (<= my biggest concern right now :)
 - I saw that the pam_console flag was only present in
/usr/portage/profiles/use.local.desc and so far only pam uses this flag. Again
can this flag be used without upsetting anyone or causing mayhem about Gentoo
policies I may not be aware of ?
 - Should I add PAM as a dep if pam_console is activated ?
 - ...

Rémi
Comment 14 Rémi Cardona (RETIRED) gentoo-dev 2005-08-11 03:41:58 UTC
Created attachment 65650 [details]
ebuild with pam_console USE flag

This ebuild works for me, it creates the "camera" group and gtkam works right
out.
Comment 15 Rémi Cardona (RETIRED) gentoo-dev 2005-08-11 03:51:40 UTC
Created attachment 65651 [details, diff]
patch for libgphoto2-2.1.5.ebuild

diff instead of whole ebuild ... my bad
Comment 16 Rémi Cardona (RETIRED) gentoo-dev 2005-09-11 09:51:03 UTC
it's been a month ... anyone to take a look and possibly comment ?
Comment 17 Christian Schmitt 2005-09-13 03:55:13 UTC
It works like a charm for me :-) I changed your ebuild to use libgphoto2-2.1.6
as currently in portage. Your ebuild should definately go into portage.
Comment 18 Christian Schmitt 2005-09-13 15:18:37 UTC
Created attachment 68393 [details]
based on the latest ebuild, but for version 2.1.6
Comment 19 Robert Scott 2005-09-18 09:56:17 UTC
This ebuild works nicely here. Certainly a much more elegant solution than the
pam_console mess. Also more consistant with how the system handles other libusb
devices.
Comment 20 Rémi Cardona (RETIRED) gentoo-dev 2005-09-21 21:05:20 UTC
what about proposing this ebuild through gentopia's overlay ? kinda fits their
goals. I'm ready to keep working on this if necessary but it'd be nice to have
some gentoo dev taking note of what's going on here.

Is there anyway of poking them (friendly) with a stick ?
Comment 21 Steev Klimaszewski (RETIRED) gentoo-dev 2005-09-22 00:10:35 UTC
shoot this stuff to me in an email (steev@gentoo.org) and ill take a look at it
tomorrow night after work (i only get an average of 2 hours online per day now)
and ill look at it when I get offline and get it going against my digicam and
add it to the overlay
Comment 22 Rémi Cardona (RETIRED) gentoo-dev 2005-10-06 16:18:28 UTC
Created attachment 70022 [details, diff]
patch for libgphoto2-2.1.6.ebuild

AllanonJL recommended to remove the pam_console flag altogether and default to
the group hotplug script.

Patch made against the latest 2.1.6 ebuild.
Comment 23 John N. Laliberte (RETIRED) gentoo-dev 2005-10-14 16:54:44 UTC
in CVS.
Thanks!