Closed jaghatei closed 6 years ago
But as nrjavaserial is not platform specific I open it here.
The issue you describe does not seem to be "solution specific" either, so imho nrjavaserial would be the right place to address this. You are fully correct that such a Java library must not expect to have access rights in /var/run, so it should deal with that situation.
Is this the right place? https://github.com/NeuronRobotics/nrjavaserial/issues/108
I doubt that nrjava would pick it up as it does not provide any installation procedure. How should they know which OS user is effectively running nrjavaserial.jar? But https://github.com/NeuronRobotics/nrjavaserial/issues/81 would be the better link as this exactly describes my issue.
This issue NeuronRobotics/nrjavaserial#81 is about permission, can you give it a try, if it works, if you add the user openhab to the group dialout?
But actually, we already did that during installation: https://github.com/openhab/openhab-syno-spk/blob/master/scripts/installer.sh#L165
@jaghatei Can you please try once, if that helps with you? https://github.com/NeuronRobotics/nrjavaserial/issues/108#issuecomment-346688702
@kaikreuzer If it helps, can you include this in the config.properties? Or is this optional and should be in the documentation of the binding?
On my ds214play there is no such group. Neither dialout nor uucp are existing. /dev/... and lock dir belonged to root:root before I created the group "lock" and assigned openhab2 and root to it.
I will try if appending gnu.io to config.properties part has any effect. Maybe not as the nrjava is loading and was before the right adjustment. The error RXTX throws in case of this right issue is "no such port".
the current DSM upgrade to 6.1.4 has reverted my changes in the /dev and /run ownership and where 6.1.3 has set a=rw for /dev/ttyUSB0 6.1.4 is setting it for user only (go-rwx).
What are we to do in your opinion? What rights should be awarded where?
/dev is udev and /run a tmpfs / ramdisk, so any change like chmod / chown here will not stand a reboot.
To have the changes persistent I needed to set up a udev rule in /lib/udev/rules.d/ :
SUBSYSTEM=="tty", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", GROUP="lock", MODE="0660"
and adapt /etc/init/root-file-system.conf
from
/bin/mkdir -p /run/lock || true
to
/bin/mkdir -m 0775 -p /run/lock || true
/bin/chown root.lock /run/lock || true
The udev rule might not be possible in installation script as you do not know what USB device will be present, especially as it might not be present at installation time. But following steps should be part of installation:
@jaghatei I also see that an implementation in the installer.sh script is not possible. We do not know which USB devices a user has connected and if he wants to use them for OpenHAB as well. It would be great if you could create a pull request for the README.md file with the appropriate content. A check if group dialout or uucp is present is implemented, see: https://github.com/openhab/openhab-syno-spk/blob/master/scripts/installer.sh#L164 Implementation of /etc/init/root_file_system.conf is in my opinion not part of the package, because as mentioned above, we do not know which USB devices a user has.
You are trying to add openhab2 user to hopefully existing groups by --member option, but you are not checking for the result of the commands at all:
ash-4.3# synogroup --member dialout openhab2
Lastest SynoErr=[group_db_get.c:26]
SYNOGroupGet failed, synoerr=0x1800
ash-4.3# synogroup --get dialout
Lastest SynoErr=[group_db_get.c:26]
SYNOGroupGet failed, synoerr=0x1800
ash-4.3# synogroup --get uucp
Lastest SynoErr=[group_db_get.c:26]
SYNOGroupGet failed, synoerr=0x1800
ash-4.3# synogroup --add dialout openhab2
Group Name: [dialout]
Group Type: [AUTH_LOCAL]
Group ID: [65537]
Group Members:
0:[openhab2]
ash-4.3# synogroup --get dialout
Group Name: [dialout]
Group Type: [AUTH_LOCAL]
Group ID: [65537]
Group Members:
0:[openhab2]
If group is not present you would have to create it with --add instead of --member
and additionally you need to enable lock file creation by
/bin/chown root.groupname /run/lock
/bin/chmod 0775 /run/lock
and adapt /etc/init/root-file-system.conf accordingly to have this permanently in the system - at least hopefully... I do not know if a DSM update / upgrade would overrule this change to /etc/init/root-file-system.conf . The adaption to this file enables openhab2 to create lock files for any device used. It is not specific to special device.
The udev rule is, so I will open a corresponding pull request for README.md
@jaghatei The note was taken in the readme. Can we close the issue?
yes can be closed.
Not sure if this better belongs to nrjavaserial directly or to this syno package. But as nrjavaserial is not platform specific I open it here.
When using the nrjavaserial package the file rigths for the needed serial ports and for the directory /var/run/lock are not accessible for openhab2 user blocking the driver from opening the serial port as lock file creation fails.
I needed to create a group, add openhab2 to it and chgrp /var/run/lock to this group and the required serial ports in /dev/ also.