# Access USB device in jail as non root user



## LeoSum (Dec 15, 2015)

Hi there,
I am using FreeBSD 9.3 (FreeNAS 9.3 actually) where I am currently trying to configure FHEM (a home automation software) in a jail.

The software needs access to a USB stick (CUL from busware.de http://busware.de/tiki-index.php?page=CUL), which is accessed via /dev/cuaU0

I managed to access the device from within the jail as root user by adding in the file /etc/defaults/devfs.rules the following lines in the _[devfsrules_jail=4]_ section:


```
[devfsrules_jail=4]
add path 'cuaU*' unhide
add path 'cuaU*' mode 0777
```
Now if I ssh into the jail and after issuing the _su _command, I can _screen /dev/cuaU0_ and talk to the device.

However the FHEM software is executed as the user "fhem" which belongs to the group "fhem". FHEM is basically a perl script that is executed via `perl fhem.pl`.
(A question on the side: It doesn't make a difference if I execute the program manually after elevating via `su`, it is still run as fhem and not as root. Why is that? Is that a perl setting?)

In the FHEM logs I can read that access to /dev/cuaU0 is not permitted. And also if I try to connect to it from a shell as the fhem user manually via `screen /dev/cuaU0`, I don't have access.

So what do I need to do to allow the fhem user to use the device? So far, after reading

https://forums.freebsd.org/threads/solved-ezjail-cuse4bsd-webcamd-operation-not-permit.43938/
and
https://forums.freebsd.org/threads/...devices-with-non-root-user-inside-jail.49946/

I tried the following:
- adding the line to /etc/sysctl.conf of the host system:

```
vfs.usermount=1
```
- adding the lines to /etc/devfs.conf in the jail:

```
own   cuaU0  fhem
perm  cuaU0  fhem:fhem
```

But that didn't help.

What am I doing wrong? Any Ideas? I am grateful for any hint!


----------

