Page 1 of 1

Permission denied: /dev/ttyUSB0

Posted: Mon Mar 05, 2012 5:17 pm
by ^rooker
[PROBLEM]
While writing a serial-to-html interface for a video A/D converter, I ran into the following problem:
My serial interface was FTDI-based, so it appears as "/dev/ttyUSB0".
Nice, but by default, the access rights for this device are like this:
crw-rw---- 1 root dialout 188, 0 2012-03-01 16:10 /dev/ttyUSB0
Even if you change the rights manually, every time you unplug/replug the device, they will be reset to this :(

Although usually, you'd just assign the user to access that device to the group "dialout", in my case I wasn't too comfortable doing so, because I'm accessing the serial device from Apache/PHP. So the user is "www-data". This means that that user would be able to access *any* device, the user "dialout" is allowed to write to. And we're talking about a WEB interface here...

[SOLUTION]
So I've decided to only grant access to /dev/ttyUSB0:

As "udev" is responsible for these access rights, you can simply create a new rule file in /etc/udev/rules.d, called "80-ttyusb.rules" (for example) - with the following content:

Code: Select all

KERNEL=="ttyUSB0", MODE="0666"
Now, unplug/replug the device and it should show up with read access for anyone:
crw-rw-rw- 1 root dialout 188, 0 2012-03-05 16:01 /dev/ttyUSB0