Cant set permissions correctly

I am trying to set up the demo for my first openhab install (on a raspberry pi) by following this tutorial and i cant seem to get the permissions correctly set to transfer the files to it from my mac.

sudo chown -R openhab /var/lib/openhab/
sudo chown -R openhab /var/log/openhab/
sudo chown -R openhab /etc/openhab/
sudo chown -R openhab /usr/share/openhab/

And it seems to have set the owner correctly. But when log into my rasperry pi by going to Finder -> Go -> Connect to Server -> smb://openhab@raspberrypi.local and login, i am not allowed to delete the OpenHab Config folder.

I am allowed to modify the addons folder inside /usr/share/openhab but not allowed to modify anything inside /etc/openhab it seems.

Here is ls -al of the two directories

pi@raspberrypi:/ $ ls -al /etc/openhab/
total 44
drwxr-xr-x   4 openhab openhab 4096 Feb  7 23:05 .
drwxr-xr-x 109 root    root    4096 Feb  4 13:22 ..
drwxr-xr-x   6 openhab openhab 4096 Feb  7 21:45 configurations
-rwxrw-rw-   1 openhab openhab 4096 Feb  7 23:05 ._.DS_Store
-rwxrw-rw-   1 openhab openhab 6148 Feb  7 23:06 .DS_Store
drwxr-xr-x   4 openhab openhab 4096 Feb  4 13:17 jetty
-rw-r--r--   1 openhab openhab 2583 Feb  2 15:23 logback_debug.xml
-rw-r--r--   1 openhab openhab 2311 Feb  2 15:23 logback.xml
-rw-r--r--   1 openhab openhab  145 Feb  2 15:23 login.conf
-rw-r--r--   1 openhab openhab  302 Feb  2 15:23 quartz.properties

pi@raspberrypi:/ $ ls -al /usr/share/openhab/
total 60
drwxr-xr-x   7 openhab openhab  4096 Feb  7 22:47 .
drwxr-xr-x 182 root    root     4096 Feb  4 13:17 ..
drwxrwxrwx   2 openhab openhab  4096 Feb  1 11:21 addons
-rwxrw-rw-   1 openhab openhab  4096 Feb  7 22:47 ._addons
drwxr-xr-x   2 openhab openhab  4096 Feb  4 13:18 bin
lrwxrwxrwx   1 openhab openhab    27 Feb  2 15:23 configurations -> /etc/openhab/configurations
lrwxrwxrwx   1 openhab openhab    27 Feb  2 15:23 contexts -> /etc/openhab/jetty/contexts
-rwxrw-rw-   1 openhab openhab  4096 Feb  7 21:49 ._.DS_Store
-rwxrw-rw-   1 openhab openhab  6148 Feb  7 23:05 .DS_Store
lrwxrwxrwx   1 openhab openhab    22 Feb  2 15:23 etc -> /etc/openhab/jetty/etc
-rw-r--r--   1 openhab openhab 11232 Feb  2 15:23 LICENSE.TXT
-rw-r--r--   1 openhab openhab   652 Feb  2 15:23 README.TXT
drwxr-xr-x   6 openhab openhab  4096 Feb  4 13:18 server
drwxr-xr-x   2 openhab openhab  4096 Feb  4 13:18 sounds
drwxr-xr-x   4 openhab openhab  4096 Feb  4 13:18 webapps

so you can see that openhab clearly owns everything, but when i login using samba it cant change anything on /etc/openhab

EDIT: I forced the demo into the folders with root, and when i go to http://raspberrypi.local:8080/openhab.app?sitemap=demo i get ERR_CONNECTION_REFUSED.

So now i have two problems: 1) how do i fix my permissions and 2) Why is this connection refused error popping up now that those files are in place?

EDIT 2: I fixed the ERR_CONNECTION_REFUSED, turns out openhab wasn’t starting on its own because i am running Jessie Raspbian, so the defaults.rc method for starting up doesnt work. I need to use

sudo systemctl daemon-reload
sudo systemctl enable openhab

So back to one problem: Why wont my samba share let me modify /etc/openhab?

By default and every time openHAB runs the permissions on your configuration files are set to give write permissions to only the openhab user. To edit them you either need to edit them as root, temporarily change their permissions so “other” can write to them (it will get set back the next time openHAB restarts), connect to your raspberry pi as the openhab user or as root.

thanks for the reply! I swear I am connecting to the pi as the user openhab. When i use samba to connect to it I am connecting to smb://openhab@raspberrypi.local which is supposed to connect as the openhab user right?

I’m not an expert with Samba so I can’t say, but unless you created the openhab user yourself rather than relying on apt-get to create it the openhab user is a special user which you cannot log into. For example, you cannot ssh to the machine using the openhab user. This might be interfering with samba’s ability to use the openhab user when it connects.

Also, by default the openhab user does not have a shell in /etc/password which also could be causing problems for samba.

I suppose it is also posible that smb://openhab@raspberrypi.local doesn’t work the way we think it does and indeed it doesn’t connect as the openhab user. My experience with samba is limited to getting it set up initial years ago and mainly connecting from Windows machines. So I’m not going to be much help troubleshooting this one.

You are right, i cannot ssh into the pi as openhab, only connect to it via samba.

SOLVED:

Samba has security issues following symlinks which is what i was trying to change

there is a workaround by adding

follow symlinks = yes
wide links = yes

in the global options of samba

explain more please :relieved:

Such a question on a 5 years! old post!
I would suggest to use an openhabian image on a raspberry. All problems discussed above would be solved.

you are right but I use this because I need to run media server beside openhab