Openhab user permission for "exec binding" addon

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?

sudo chown openhab exectest.sh

1 Like

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:

  1. run the script as root using sudo though you’ll have to configure sudo to work for the openhab user
  2. create that log folder manually and change the permissions on it so any user can write to it
  3. create that log folder manually and change the ownership (see @anon71759204’sa response) of that folder so it’s owned by openhab.

I recommend either 2 or 3.

1 Like

Using sudo chown openhab exectest.sh worked. I will use this method in future. Thanks.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.