Samba shares, openHAB Designer, file access or not :(

Relatively new to openHAB… had great help from this forum…
Initially installed OH 1.8.3 with the manual install on Raspberry Pi with Jessie; had it eventually all going…

Later found out that the apt-get method would have been better in order to have a consistent basis for support purposes.
OK, we managed to get this going once, why not a second time?!

Saved my config files, and re-imaged the rPi with the base image prior to OH, MQTT, and samba installs.
What I noticed during this install:
a) OH file ownership in /etc/openhab and /usr/share/openhab was root:root; changed it to openhab:openhab with
sudo chown -hR openhab:openhab /etc/openhab sudo chown -hR openhab:openhab /usr/share/openhab

b) since I log into the rPi as maxg, I added me to the group openhab

Once OH and MQTT was installed, they both were tested and deemed working.

Now here comes the twist: samba is giving me grief.

Installed samba: sudo apt-get install samba samba-common-bin
changed samba config: sudo nano /etc/samba/smb.conf
by making these changes:
uncommented:
workgroup = WORKGROUP

160611 MaxG changed from no to yes
wins support = yes

commented:
;[printers]
;[print$]

160611 MaxG changed from no to yes
read only = yes

160611 MaxG added:
[OpenHAB Home] comment = OpenHAB Home path = /usr/share/openhab browseable = yes writeable = yes only guest = no create mask = 0777 directory mask = 0777 public = no

[OpenHAB Config] comment= OpenHAB Site Config path = /etc/openhab browseable = yes writeable = yes only guest = no create mask = 0777 directory mask = 0777 public = no

ran:

testparm

added myself to samba

sudo smbpasswd -a maxg

checkedif service is up

sudo /etc/init.d/smbd status

… all good.

On Windows 10, I simply reused my previously working designer; pointed to new directory all good; as in it can see the config files.

However, and here starts the frustration (and it might be more a Linux question than one for openhab):
I can read/write to the configurations directory, but the the directories underneath; and have no clue why this is so.

The directories look like this:

[10:51:25] maxg@rpiautomation /etc/openhab $
ls -la
total 32
drwxrwxrwx   4 openhab openhab 4096 Jun 11 10:50 .
drwxr-xr-x 114 root    root    4096 Jun 10 21:42 ..
drwxr-xr-x   8 openhab openhab 4096 Jun 10 21:39 configurations
drwxrwxrwx   4 openhab openhab 4096 Jun 10 20:29 jetty
-rwxrwxrwx   1 openhab openhab 2583 May 23 05:44 logback_debug.xml
-rwxrwxrwx   1 openhab openhab 2311 May 23 05:44 logback.xml
-rwxrwxrwx   1 openhab openhab  145 May 23 05:44 login.conf
-rwxrw-rw-   1 maxg    maxg       0 Jun 11 10:50 New Text Document.txt
-rwxrwxrwx   1 openhab openhab  302 May 23 05:44 quartz.properties
[10:51:39] maxg@rpiautomation /etc/openhab $
ls -la configurations/
total 228
drwxr-xr-x 8 openhab openhab  4096 Jun 10 21:39 .
drwxrwxrwx 4 openhab openhab  4096 Jun 11 10:50 ..
drwxr-xr-x 2 openhab openhab  4096 Jun 10 21:45 items
-rw-r--r-- 1 openhab openhab 22423 Jun 10 21:43 openhab.cfg
-rw-r--r-- 1 openhab openhab 84565 Jun 10 21:43 openhab.cfg.orig
-rw-r--r-- 1 openhab openhab 84565 May 23 05:44 openhab_default.cfg
drwxr-xr-x 2 openhab openhab  4096 Jun 10 21:45 persistence
drwxr-xr-x 2 openhab openhab  4096 Jun 10 21:45 rules
drwxr-xr-x 2 openhab openhab  4096 Jun 10 21:45 scripts
drwxr-xr-x 2 openhab openhab  4096 Jun 10 21:45 sitemaps
drwxr-xr-x 2 openhab openhab  4096 Jun 10 20:31 transform
-r--r----- 1 openhab openhab    24 May 23 05:44 users.cfg

Maybe the questions should be:
Are my file permission correct? If not, what should they be?
Is it OK to log in as maxg as member of the group openhab? Or will this interfere with openhab (seeing a file owned by maxg when modified)?

Thanks :slight_smile:

Hi Max - I have taken a slightly different approach… I have created a separate ‘ohadmin’ group, which I grant the write privileges to. My local account, and my remote Samba user are both added to this group. I do not add the openhab user to this group - they just continue to hold read access to these files.

Only thing I haven’t sorted yet, is stopping OH overwriting these permissions on each startup (or getting it to set these specific permissions), but I just paste in the bottom two sets of the following commands for now…

//Create ohadmin group
sudo addgroup ohadmin

//Add User to ohadmin group
sudo usermod -a -G ohadmin samba_username
sudo usermod -a -G ohadmin local_username

//Change group ownership to ohadmin
sudo chgrp ohadmin /etc/openhab/configurations
sudo chgrp ohadmin /etc/openhab/configurations/openhab.cfg
sudo chgrp -R ohadmin /etc/openhab/configurations/items
sudo chgrp -R ohadmin /etc/openhab/configurations/persistence
sudo chgrp -R ohadmin /etc/openhab/configurations/rules
sudo chgrp -R ohadmin /etc/openhab/configurations/scripts
sudo chgrp -R ohadmin /etc/openhab/configurations/sitemaps
sudo chgrp -R ohadmin /etc/openhab/configurations/transform

//Grant write permission to ohadmin
sudo chmod 775 /etc/openhab/configurations
sudo chmod 775 /etc/openhab/configurations/openhab.cfg
sudo chmod -R 775 /etc/openhab/configurations/items
sudo chmod -R 775 /etc/openhab/configurations/persistence
sudo chmod -R 775 /etc/openhab/configurations/rules
sudo chmod -R 775 /etc/openhab/configurations/scripts
sudo chmod -R 775 /etc/openhab/configurations/sitemaps
sudo chmod -R 775 /etc/openhab/configurations/transform

The permissions are set with setpermissions.sh each time openHAB is (re)started. To omit this step, just comment out the call in the autostart script.

I really think this script is a mess, because ownership and permissions shouldn’t be changed at every startup at all. In fact, this script was introduced to minimize issues relating to wrong permissions…

1 Like

Where is the autostart script (or its name) so I can look for it? thanks.

And by the way: what should be the file permissions set to?
Is chmod -R -g=rwx /etc/openhab/ reflecting the correct permissions?

No worries with file permissions; figured it out:
chmod -R 775 /etc/openhab/

With the following smb.conf the samba share is working fine:

1 Like

That’ll do it too… I just didn’t start setting the recursive permissions at the top openhab level, as I had wanted to leave users.cfg with its original (limited) permissions. Not sure if this was necessary, or just paranoia…

:slight_smile:
@glen_m: Yes, but you could have used the recursive change at the openhab level and then reset user.cfg to what you want it to be…