Open thorgrimjansrud opened 1 year ago
I believe this is because udev is creating the ttys dynamically at each boot, and the default permissions to tty* interfaces is that root only has access. A quickfix is to run the container in privileged mode, which isnt really the way to go since the container gains root access to the host system.
Another solution is to add a new udev-rule which is executed at the creation of ttys (at boot).
Create a new file called /lib/udev/rules.d/99-serial.rules
, with the following content:
KERNEL=="ttySTM1",MODE="0666"
This will give read/write access to ttySTM1 for all users similar to your chmod ugo+rw
.
The rule can be changed to ttySTM[0-9]*
if you want it applied to all ttySTM.
After the file is created, changes can be seen by doing a reload of udev with
udevadm control --reload-rules && udevadm trigger
The rule will also be automatically executed at boot.
# Pre udev-reload:
ls -l /dev/ttySTM1
crw-rw---- 1 root dialout 247, 1 May 10 10:11 /dev/ttySTM1
# udev-reload
udevadm control --reload-rules && udevadm trigger
# Post udev-reload:
ls -l /dev/ttySTM1
crw-rw-rw- 1 root dialout 247, 1 May 10 10:11 /dev/ttySTM1
Thanks, we will have a look at it!
Telegraf reporting on startup (repower of controller): [agent] Failed to connect to [outputs.websocket], retrying in 15s, error was 'error dial: unexpected EOF' [inputs.modbus::MID] Error in plugin: permission denied
Must -> sudo chmod ugo+rw /dev/serial
Before: crw-rw---- 1 root dialout 247, 1 Mar 13 13:23 /dev/ttySTM1 lrwxrwxrwx 1 root root 12 Mar 13 13:10 /dev/serial -> /dev/ttySTM1
After: crw-rw-rw- 1 root dialout 247, 1 Mar 13 13:26 /dev/ttySTM1 lrwxrwxrwx 1 root root 12 Mar 13 13:10 /dev/serial -> /dev/ttySTM1
Why is the setting not saved?