# chmod USB device?



## mgswed (Sep 4, 2013)

Hello everyone.  I asked this question over at the FreeNAS forums but no one could answer me.  I have FreeNAS 9 and am running a jail with a USB I/O device attached.  I have a program that runs fine as root but not as an operator.  I would like to change the permissions for the USB device in the jail or outside the jail if need be.  It is attached at ugen2.2.  Any help would be much appreciated.


----------



## fonz (Sep 4, 2013)

Obligatory disclaimer: PC-BSD DesktopBSD *FreeNAS* NAS4Free m0N0WALL pfSense ArchBSD kFreeBSD JabirOS topics.

You may want to have a look at devfs.conf(5), if FreeNAS has that.


----------



## wblock@ (Sep 4, 2013)

devfs.conf is only read on startup, so it does not work for hot-plug devices connected later.  For that, entries have to be added to the files in /etc/devd.  For example, here's an entry from my /etc/devd/wb.conf:


```
# change permissions on foot pedal uhid device
attach 20 {
        device-name "uhid[0-9]";
        match "vendor" "0x05f3";
        match "product" "0x00ff";
        action "chmod g+w /dev/$device-name";
};
```


----------



## DutchDaemon (Sep 4, 2013)

There is a service devfs that can be restarted, though. Doesn't that re-[read|process] devfs.conf on a running system?


----------



## SirDice (Sep 4, 2013)

As far as I know that does indeed load the new rules and applies them. But you'd still need the devd(8) configuration to change it automatically when it gets plugged in. Perhaps a more elegant solution would be to use `service devfs restart` as an action, instead of the chmod(1).


----------



## wblock@ (Sep 4, 2013)

devfs.conf(5) is for settings at boot, devfs.rules(5) is for devices that are not available at boot.  But neither are very helpful for USB devices, which can be dynamically renumbered.  devd(8) has the ability to identify devices by vendor and product IDs.


----------



## mgswed (Sep 5, 2013)

Thank you for the info.  I will try it and post my results.


----------

