# Permissions difficulties with USB camera

## krazykit

I'm trying to use my Canon Powershot a400 (a PTP device, NOT usb-mass storage) with digikam.  I had it working out the other day, and now it doesn't (computer pixies, I bet  :Wink: ).  The reason I think it's a permissions problem is that my camera will work when I run digikam as root, but not as user.

doing cat /proc/bus/usb/devices gives me (irrelevant stuff snipped)

```
T:  Bus=02 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  6 Spd=12  MxCh= 0

D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=32 #Cfgs=  1

P:  Vendor=04a9 ProdID=30b7 Rev= 0.01

S:  Manufacturer=Canon Inc.

S:  Product=Canon Digital Camera

C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=100mA

I:  If#= 0 Alt= 0 #EPs= 3 Cls=06(still) Sub=01 Prot=01 Driver=(none)

E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms

E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms

E:  Ad=83(I) Atr=03(Int.) MxPS=   8 Ivl=96ms

```

Any ideas on how to fix this problem?

----------

## krazykit

I suppose I could just always run the program in root, but that's really a cruddy solution.

----------

## krazykit

Well, perhaps it's time for a bump...  it really is a shoddy solution to have to chmod after transferring pictures...

----------

## fredgt

I've got the same camera and i had that problems to. It's a hotplug problems, it doesn't set the correct device file properties.

You can edit the hotplug script ( /etc/hotplug/usb/usbcam ) so the device file property of the you're normal user (for me 'arne'). I also added a few lines, because it still didn't work but now it does.

It's probably not completely by the book but you can give it a try. Don't forget to backup the script before you edit it, and don't forget to change the username.

```

#!/bin/bash

# $Id: usbcam.console,v 1.4 2002/09/12 16:50:18 hun Exp $

#

# /etc/hotplug/usb/usbcam

#

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 <nalin@redhat.com>

    if [ -f /var/run/console.lock ]

    then

        CONSOLEOWNER=`cat /var/run/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 arne:users "${DEVICE}"

        chmod 0666 "${DEVICE}"

    else

        chmod 0000 "${DEVICE}"

        chown arne:users "${DEVICE}"

        chmod 0666 "${DEVICE}"

    fi

fi

```

----------

## rizzo

I think I'm having the same problem.  I don't have either /var/run/console.lock or /var/lock/console.lock on my box.  Has anyone filed a bug on this?

----------

## Kern3lP4nic

those files are created by pam

----------

## pesche

Hi there

Try to find the file usbcam.group on your disk. If you have digicam / gphoto2 and the right libs installed, the file should be located in

```
/usr/share/doc/libgphoto2-2.1.5/linux-hotplug/
```

The contents of the file should look like this

```

#!/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=camera

# 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
```

Change the group variable according to the group you want to have access to the camera device. Copy the modified file to 

```
/etc/hotplug/usb/usbcam
```

Make a backup copy of the original file if needed. You have to chmod the usbcam file

```
chmod 775 /etc/hotplug/usb/usbcam
```

Plug in you camera and turn it on. Hotplug should now set the proper device permissions and you should be able to access your camera in digikam as a normal user. There are more example hotplug scripts, you can also create the device node with permissions e.g. only for one user, this is done in the file usbcam.user

Have a look at the files in 

```
/usr/share/doc/libgphoto2-2.1.5/linux-hotplug
```

Greetings,

Pesche.

----------

## iniTeX

hi there,

i had problems with my ixus400 yesterday.

i figured out that "usbcam" wants to set the owner according to /var/run/console.lock.

unless you don't have the use-flag "pam_console" set and pam compiled with it you don't have something like /var/{lock,run}/console.lock.

so i compiled pam with pam_console. then i saw that there was not  /var/run/console.lock but /var/run/console/console.lock.

i fixed usbcam with another elif-loop and i could download pictures from my camera again.

i don't now if this (use-variable and hacking a usbcam) was the right way to do it so i don't want to send in a bug report.

perhaps someone can enlighten me.

 greets, iniTeX

----------

## pesche

Hi Initex

As i have already written in my previous post, there's no need for any console.lock file or any other hacks. You just have to use the proper hotplug script (e.g. the one indicated in my post which works with groups...)

Greetings,

Pesche.

----------

## digitalboi

I have a similiar problem.  I have got the camera to detect after I modified the permissions of usbcam.group like pesche said.  However I have a wierd problem going on.  Let me give the scenario.

User A logs into kde.  Then User B logs into KDE.  User A activates his session and view the pictures on the camera through digikam.  Then User A leaves and User B activates her session to view the pictures however it says the camera is not hooked up, but User A has no problem viewing the pictures.  As soon as User A logs completely out then User B can view the pictures on the camera.  Also if user B logs in only, they have no problem viewing. I can't figure out what the problem is.

BTW when user B activates their session.  User A does close out digikam completely and the process is no longer running when user B tries to view pictures on the camera.  

Don't know if this has to anything to do with it, but when I try to view the camera thru konqueror using media://HP_M305 it gives an error saying it doesnt exist.  This happens with both users but not with root.  If someone can point me to the right file I would be grateful.  If anyone needs any configs posted let me know and I'll be glad to do it.  In the mean time I have to log out of my session everytime so the second person who logged in can view and import pictures off the camera. Please help.  Thanks in advance.

----------

## yfh2

ok, now, what if I don't use hotplug ?

I found that the camera is created under /proc/bus/usb/003/xyz where xyz is incremented each time the camera is plugged.

It is initialised with root only permissions.

Can I change this in any way ???

----------

## Pol

 *digitalboi wrote:*   

> 
> 
> Don't know if this has to anything to do with it, but when I try to view the camera thru konqueror using media://HP_M305 it gives an error saying it doesnt exist.  This happens with both users but not with root.  If someone can point me to the right file I would be grateful.  If anyone needs any configs posted let me know and I'll be glad to do it.  In the mean time I have to log out of my session everytime so the second person who logged in can view and import pictures off the camera. Please help.  Thanks in advance.

 

Same here ... In root it works, in user not ...

Anyone found a solution ?

----------

## seppelrockt

The usbcam script solution works fine here - I even had the file at the right place allready - all I had to change was the group. No PAM and no hotplug needed.

----------

## pkturner

There's a more thorough discussion of this problem in bug 84628.

----------

## Tarch

Hi all, i've tried with the usbcam script solution but I have a problem, I add the group camera and I add my user to the group camera, I substitute the script, but gphoto says me that I don't have the permissions to access the device. I think it's related to the user and group from which I executing the program but I don't know how to resolve it (a temporary workaround is to set the permission rw to other but I don't like it).

Bye and thank you!  :Shocked: 

P.S. Happy New Year.

----------

## pkturner

When I looked at this topic 3 months ago I didn't like any of the suggested solutions, since they didn't appear to be headed toward a permanent fix.

Happily, there's now a fix in libgphoto2-2.1.6-r1. The ebuild is still listed as unstable, so if you want that fix right away you'll need to add it to /etc/package.keywords.

----------

