Hello,
I use R-Pi with Openhabian. I am trying to execute bash script /home/openhabian/exectest.sh using “exec binding” addon but I get “permission denied” error in my logs…
2021-12-03 17:33:58.231 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'garage-5' failed: For input string: "/home/openhabian/exectest.sh: 3: cannot create /home/openhabian/logs: Permission denied
Script /home/openhabian/exectest.sh is whitelisted according to exec binding docs.
After running sudo -u openhab /home/openhabian/exectest.sh from localhost (via ssh as root) I get also permission denied report.
How can I allow user “openhab” to execute whitelisted scripts? My script is set to have “chmod +x” is that not enough?
The problem is your script wants to create a folder in /home/openhabian. /home/openhabian is owned by the user openhabian and only the user openhabian and root have permission to write there. When openHAB calls your script, that script will be running as user openhab. openhab is not openhabian so it doesn’t not have permission to create a folder in /home/openhabian.
So you can:
run the script as root using sudo though you’ll have to configure sudo to work for the openhab user
create that log folder manually and change the permissions on it so any user can write to it
create that log folder manually and change the ownership (see @anon71759204’sa response) of that folder so it’s owned by openhab.