# camera works only as root

## blibbleage

Hi

I know there's a few threads around with the above title, but I've read all that I could find with no success.  As stated, my Kodak DX3600 camera only works (using gphoto2 --shell) as root.  I've tried editing /etc/hotplug/usb/usbcam to use "chmod 0666" instead of "0600" but that doesn't help.  Any ideas on what to try next would be great.

I'm using kernel 2.6 and udev, and the camera was working fine until about a week ago.  It might have been an update to udev that caused the problems, but I'm not sure about that.  If you want me to run further tests, I'm happy to - just say what you need.

Thanks!

----------

## blaster999

Are you a part of the "usb" group? Type "groups" to find out.

----------

## blibbleage

Yes, I am:

```

tew24@beast ~ $ groups 

wheel floppy audio cdrom video games cdrw usb users tew24 speech

```

----------

## all-inc.

no debug messages? perhaps gphoto2 has a --verbose option or similar

pls show us a ` dmesg | tail -n 15 `  :Wink: 

----------

## blibbleage

Sorry! I knew there was something I forgot to put in the post.  There are debug messages:

```

tew24@beast ~ $ gphoto2 --shell

gphoto2: {/home/tew24} /> ls                                                   

*** Error ***              

An error occurred in the io-library ('Could not claim the USB device'): Could not claim interface 0 (Operation not permitted). Make sure no other program or kernel module (such as sdc2xx, stv680, spca50x) is using the device and you have read/write access to the device.

*** Error (-53: 'Could not claim the USB device') ***

gphoto2: {/home/tew24} /> 

```

but as root, I get:

```

beast tew24 # gphoto2 --shell

gphoto2: {/home/tew24} /> ls                                                   

store_00010001/     store_00020001/                                            

gphoto2: {/home/tew24} /> 

```

also, dmesg reports:

```

[fglrx] max   Inv = 134217728

[fglrx] total Inv = 134217728

[fglrx] total TIM = 0

[fglrx] total FB  = 0

[fglrx] total AGP = 8192

TCP: Treason uncloaked! Peer 209.225.0.34:80/37039 shrinks window 2956757772:2956759228. Repaired.

TCP: Treason uncloaked! Peer 209.225.0.34:80/37039 shrinks window 2956757772:2956759228. Repaired.

TCP: Treason uncloaked! Peer 209.225.0.34:80/37039 shrinks window 2956757772:2956759228. Repaired.

usb 3-1: new full speed USB device using ohci_hcd and address 11

usb 3-1: USB disconnect, address 11

usb 3-1: new full speed USB device using ohci_hcd and address 12

usb 3-1: USB disconnect, address 12

usb 3-1: new full speed USB device using ohci_hcd and address 13

usb 3-1: USB disconnect, address 13

usb 3-1: new full speed USB device using ohci_hcd and address 14

```

----------

## all-inc.

hmm, because the debug messages doesn't show which /dev files are used by the program, run it as root, and then use lsof to see which files are opened by gphoto2.

-> emerge lsof

better, use

/usr/sbin/lsof -p $(pidof gphoto2)

and then, close gphoto2 and run

lsof | grep <interface name you got by the above command>

to see if any programs are still using this dev, for some weird reasons ^^

cya

----------

## blibbleage

Here's the relevant output text.  I wasn't sure if I should check for the /dev items or the /proc/bus/usb so I did both.

gphoto2 running at this stage....

```

beast tew24 # lsof -p $(pidof gphoto2)

COMMAND  PID USER   FD   TYPE DEVICE    SIZE     NODE NAME

gphoto2 3101 root  cwd    DIR   33,1    4096  3194947 /home/tew24

gphoto2 3101 root  rtd    DIR   33,1    4096        2 /

gphoto2 3101 root  txt    REG   33,1   74152 14632425 /usr/bin/gphoto2

gphoto2 3101 root  mem    REG   33,1   62432 15028605 /usr/lib/gphoto2/2.1.5/libgphoto2_ptp2.so

gphoto2 3101 root  mem    REG   33,1   38172 15026890 /usr/lib/gphoto2_port/0.5.1/libgphoto2_port_usb.so

gphoto2 3101 root  mem    REG   33,1   10904 22822976 /lib/libdl-2.3.4.so

gphoto2 3101 root  mem    REG   33,1 1229232   950415 /lib/tls/libc-2.3.4.so

gphoto2 3101 root  mem    REG   33,1   26180 14762301 /usr/lib/libpopt.so.0.0.0

gphoto2 3101 root  mem    REG   33,1   24616 15027937 /usr/lib/libgphoto2_port.so.0.5.1

gphoto2 3101 root  mem    REG   33,1  111616 15026964 /usr/lib/libgphoto2.so.2.0.3

gphoto2 3101 root  mem    REG   33,1  182968 14828780 /lib/libreadline.so.5.0

gphoto2 3101 root  mem    REG   33,1   78436 14811568 /usr/lib/libexif.so.9.1.2

gphoto2 3101 root  mem    REG   33,1  123778   950409 /lib/tls/libpthread-2.3.4.so

gphoto2 3101 root  mem    REG   33,1  120732 15124201 /usr/lib/libjpeg.so.62.0.0

gphoto2 3101 root  mem    REG   33,1  383060 14550915 /usr/lib/libslang-utf8.so.1.4.9

gphoto2 3101 root  mem    REG   33,1   19588 14697872 /lib/libgpm.so.1.19.0

gphoto2 3101 root  mem    REG   33,1  949282 21037985 /usr/lib/libX11.so.6.2

gphoto2 3101 root  mem    REG   33,1  161816   950403 /lib/tls/libm-2.3.4.so

gphoto2 3101 root  mem    REG   33,1  104532 14713076 /usr/lib/libaa.so.1.0.4

gphoto2 3101 root  mem    REG   33,1  308012 15220860 /lib/libncursesw.so.5.4

gphoto2 3101 root  mem    REG   33,1  210112 14700335 /usr/lib/libcdk.so.1.0.0

gphoto2 3101 root  mem    REG   33,1   91392 22822972 /lib/ld-2.3.4.so

gphoto2 3101 root    0u   CHR  136,3                5 /dev/pts/3

gphoto2 3101 root    1u   CHR  136,3                5 /dev/pts/3

gphoto2 3101 root    2u   CHR  136,3                5 /dev/pts/3

gphoto2 3101 root    3r   DIR   33,1    8192  1688556 /usr/lib/gphoto2/2.1.5

gphoto2 3101 root    4r   REG   33,1      45  4391811 /root/.gphoto/settings

gphoto2 3101 root    5u   REG   0,11      57 55083635 /proc/bus/usb/002/004

beast tew24 #

```

closed gphoto2 at this stage...

```

beast tew24 # lsof |grep /dev/pts

bash       3089 tew24    0u      CHR      136,3                    5 /dev/pts/3

bash       3089 tew24    1u      CHR      136,3                    5 /dev/pts/3

bash       3089 tew24    2u      CHR      136,3                    5 /dev/pts/3

bash       3089 tew24  255u      CHR      136,3                    5 /dev/pts/3

su         3093  root    0u      CHR      136,3                    5 /dev/pts/3

su         3093  root    1u      CHR      136,3                    5 /dev/pts/3

su         3093  root    2u      CHR      136,3                    5 /dev/pts/3

bash       3096  root    0u      CHR      136,3                    5 /dev/pts/3

bash       3096  root    1u      CHR      136,3                    5 /dev/pts/3

bash       3096  root    2u      CHR      136,3                    5 /dev/pts/3

bash       3096  root  255u      CHR      136,3                    5 /dev/pts/3

bash       3104 tew24    0u      CHR      136,5                    7 /dev/pts/5

bash       3104 tew24    1u      CHR      136,5                    7 /dev/pts/5

bash       3104 tew24    2u      CHR      136,5                    7 /dev/pts/5

bash       3104 tew24  255u      CHR      136,5                    7 /dev/pts/5

su         3108  root    0u      CHR      136,5                    7 /dev/pts/5

su         3108  root    1u      CHR      136,5                    7 /dev/pts/5

su         3108  root    2u      CHR      136,5                    7 /dev/pts/5

bash       3111  root    0u      CHR      136,5                    7 /dev/pts/5

bash       3111  root    1u      CHR      136,5                    7 /dev/pts/5

bash       3111  root    2u      CHR      136,5                    7 /dev/pts/5

bash       3111  root  255u      CHR      136,5                    7 /dev/pts/5

lsof       3123  root    0u      CHR      136,5                    7 /dev/pts/5

lsof       3123  root    2u      CHR      136,5                    7 /dev/pts/5

grep       3124  root    1u      CHR      136,5                    7 /dev/pts/5

grep       3124  root    2u      CHR      136,5                    7 /dev/pts/5

kded       4695 tew24   14u      CHR      136,0                    2 /dev/pts/0

opera      4783 tew24    0u      CHR      136,1                    3 /dev/pts/1 (deleted)

opera      4783 tew24    1u      CHR      136,1                    3 /dev/pts/1 (deleted)

opera      4783 tew24    2u      CHR      136,1                    3 /dev/pts/1 (deleted)

operaplug  4800 tew24    1u      CHR      136,1                    3 /dev/pts/1 (deleted)

operaplug  4800 tew24    2u      CHR      136,1                    3 /dev/pts/1 (deleted)

operamoti  4802 tew24    0u      CHR      136,1                    3 /dev/pts/1 (deleted)

operamoti  4802 tew24    1u      CHR      136,1                    3 /dev/pts/1 (deleted)

operamoti  4802 tew24    2u      CHR      136,1                    3 /dev/pts/1 (deleted)

bash      19864 tew24    0u      CHR      136,4                    6 /dev/pts/4

bash      19864 tew24    1u      CHR      136,4                    6 /dev/pts/4

bash      19864 tew24    2u      CHR      136,4                    6 /dev/pts/4

bash      19864 tew24  255u      CHR      136,4                    6 /dev/pts/4

gaim      20080 tew24    0u      CHR      136,2                    4 /dev/pts/2 (deleted)

gaim      20080 tew24    1u      CHR      136,2                    4 /dev/pts/2 (deleted)

gaim      20080 tew24    2u      CHR      136,2                    4 /dev/pts/2 (deleted)

operamoti 29238 tew24    0u      CHR      136,1                    3 /dev/pts/1 (deleted)

operamoti 29238 tew24    1u      CHR      136,1                    3 /dev/pts/1 (deleted)

operamoti 29238 tew24    2u      CHR      136,1                    3 /dev/pts/1 (deleted)

beast tew24 #

```

```

beast tew24 # lsof |grep /proc/bus/usb/002/004

beast tew24 # 

```

----------

## blibbleage

If it's any help, I've now tried it with another camera (the Sony DSC-W1) with exactly the same results (works as root, not as user)

----------

## all-inc.

hmm, alright

/dev/pts are the device files for your shell (you have three opened: stdin, stdout, stderr)

/proc/bus/usb/002/004 is the only file that seems to me being the one.

what showes ls -l /proc/bus/usb/002/004  ?

if only root can read/write, that's the trick, i guess.

perhaps lsof has another output when gphoto2 is just downloading pics from the camera.

if you can write at /proc/bus/usb/002/004 as normal user and the error occurs again, try lsof when downloading a pic.

otherwise just change the perms with 'chmod o+wr /proc/bus/usb/002/<current file>' or, if you are in the 'root' group(i hope you don't ^^) chmod g+rw ...

another idea is to start gphoto2 as normal user with xtrace...but let us first try the stuff above.

----------

## blibbleage

Here's the results of ls (it was assigned to a different number this time I plugged it in).

```

beast tew24 # ls -l /proc/bus/usb/002/007

-rw-r--r--  1 root root 57 Mar  9 16:37 /proc/bus/usb/002/007

beast tew24 #

```

I then did this:

```

beast tew24 # chmod a+rw /proc/bus/usb/002/007

beast tew24 # ls -l /proc/bus/usb/002/007

-rw-rw-rw-  1 root root 57 Mar  9 16:37 /proc/bus/usb/002/007

beast tew24 #

```

and can now access it as a normal user, so thank you, it works! However, I'd like a way to make this permanent, so that each time I plug a camera in, it has permissions set like this - any idea what I should do?

----------

## all-inc.

yeah, this is a job for the hotplug usb agent  :Smile: 

 */etc/hotplug/usb.agent, line 102-110 wrote:*   

> # used to run config scripts for user mode drivers (jPhoto, gPhoto2,
> 
> # rio500 tools, etc) ... instead of naming kernel modules, it names
> 
> # config scripts.  those could change $DEVICE permissions, etc.
> ...

 

when the camera is plugged in, make a cat /proc/bus/usb/devices to see the values you have to enter in usb/<camname>.usermap...

have a look at this for a detailed description how to set up hotplug to change the perm's.

----------

## blibbleage

Excellent, that works.  Thank you!

----------

## one-bit

Add group"camera" to gentoo box and your user to this group.

Utilize usbcam.group scripts

```

$> cp /usr/share/doc/libgphoto2-2.1.5/linux-hotplug/usbcam.group /etc/hotplug/usb/usbcam

$> chmod +x  /etc/hotplug/usb/usbcam

```

If you want utilize other group than "camera" edit  GROUP in /etc/hotplug/usb/usbcam

----------

## safeness

Thanks for the tip one-bit. This worked great for me!

----------

