Access to openHAB share (incl. via VSCode)

  • Platform information:
    • Hardware: Raspberry Pi 3 Model B Rev 1.2_
    • Host: rpi3ohv2 Kernel: 5.4.51-v7+ armv7l bits: 32 Console: tty 2
    • Distro: Raspbian GNU/Linux 10 (buster)
    • OpenJDK Runtime Environment (Zulu 8.31.1.122-linux_aarch32hf) (build 1.8.0_181-b122)
  • Version: 2.5.11 (Build) (apt-get), text-based config
    • binding = astro, exec, logreader, network, ntp, systeminfo, fritzboxtr0641, expire1, mqtt1, weather1
    • ui = paper, basic, classic, restdocs
    • persistence = rrd4j, mapdb
    • action = mail, mqtt
    • transformation = map, javascript, xslt, scale, jsonpath

I had a look at the docs, on how to install the samba share to access the OH config. I have the same config; and it has been working for a while… but no longer does… and I can’t figure out what the problem is.
The docs also say how to mount it on Windows and Mac, but not Linux. :slight_smile:

The openHAB pi (rpi3ohv2) has this share:

[OpenHAB Config]
  comment = openHAB site config
  path = /etc/openhab2
  browseable = yes
  writeable = yes
  only guest = no
  public = no
  create mask = 0777
  directory mask = 0777
  force user = openhab
  force group = openhab

The OH directory shows this:

# [2021-04-03 13:42] maxg@rpi3ohv2 /etc/openhab2 $ 
la
total 76
drwxr-xr-x  17 openhab openhab  4096 Feb  2 12:29 .
drwxr-xr-x 100 root    root    12288 Mar 13 13:23 ..
drwxrwxrwx   7 openhab openhab  4096 Apr  3 11:23 .git
drwxrwxrwx   2 openhab openhab  4096 Feb  9  2019 helpers
drwxr-xr-x   3 openhab openhab  4096 Feb  2 05:29 html
drwxr-xr-x   3 openhab openhab  4096 Jan  1  2019 icons
drwxr-xr-x   2 openhab openhab  4096 Feb  2 05:29 items
drwxr-xr-x   2 openhab openhab  4096 Apr 21  2020 misc
drwxr-xr-x   2 openhab openhab  4096 Feb  2 05:29 persistence
drwxr-xr-x   2 openhab openhab  4096 Feb  2 05:29 rules
drwxr-xr-x   2 openhab openhab  4096 Feb  2 05:29 scripts
drwxr-xr-x   2 openhab openhab  4096 Feb  2 21:10 services
drwxr-xr-x   2 openhab openhab  4096 Feb  2 05:29 sitemaps
drwxr-xr-x   2 openhab openhab  4096 Feb  2 05:29 sounds
drwxr-xr-x   2 openhab openhab  4096 Feb  2 05:29 things
drwxr-xr-x   2 openhab openhab  4096 Feb  2 05:29 transform
drwxrwxrwx   2 openhab openhab  4096 Nov 12 20:26 .vscode

I used to version-control the OH config via VScode, but get this error when saving:

> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file -
error: insufficient permission for adding an object to repository database .git/objects
error: insufficient permission for adding an object to repository database .git/objects
error: Error building trees

The ./git directory looks like this:

# [2021-04-03 13:43] maxg@rpi3ohv2 /etc/openhab2 $ 
la .git/
total 116
drwxrwxrwx   7 openhab openhab  4096 Apr  3 13:45 .
drwxr-xr-x  17 openhab openhab  4096 Feb  2 12:29 ..
-rwxrw-rw-   1 openhab openhab    18 Apr  3 13:45 COMMIT_EDITMSG
-rwxrw-rw-   1 openhab openhab   130 Aug 26  2019 config
-rwxrw-rw-   1 openhab openhab    73 Aug 26  2019 description
-rwxrw-rw-   1 openhab openhab    23 Aug 26  2019 HEAD
drwxrwxrwx   2 openhab openhab  4096 Aug 26  2019 hooks
-rw-rw-r--   1 pi      pi      70998 Apr  3 09:51 index
drwxrwxrwx   2 openhab openhab  4096 Aug 26  2019 info
drwxrwxrwx   3 openhab openhab  4096 Aug 26  2019 logs
drwxrwxrwx 253 openhab openhab  4096 Dec 13 10:22 objects
drwxrwxrwx   4 openhab openhab  4096 Aug 26  2019 refs

My remote machine (a PC running Mint) uses fstab to mount the OH share:

# [2021-04-03 12:55] maxg@maxg-pc-mint ~/openhab $ 
cat /etc/fstab
# /etc/fstab: static file system information.
# 
# <file system>                                <mount point>           <type>  <options>          <dump>  <pass>
UUID=9c2109ea-b7d9-4508-8843-e4e5cc455e69      /                       ext4    errors=remount-ro  0       1
UUID=c461a998-27f0-44b6-bde1-31feae231902      none                    swap    sw                 0       0

# 191103-1921 MaxG: added "Data SSD" to auto-mount; see \040 to express the space
UUID=3C1E04101E03C23E                         /media/maxg/Data\040SSD   ntfs   auto               0       0

# 180419-2051 MaxG: permanently mount the hpserver SAMBA shares (this works)
//HPSERVER/Music      /home/maxg/hpserver/music      cifs  vers=1.0,username=Administrator,password=xxxxx,uid=1000,gid=1000

192.168.1.5:/etc/openhab2         /home/maxg/openhab      nfs4    _netdev,auto    0    0

When I list the OH folder on the local machine, I see this:

# [2021-04-03 13:06] maxg@maxg-pc-mint ~/openhab $ 
la
total 68
drwxr-xr-x 17 dnsmasq avahi-autoipd 4096 Feb  2 12:29 .
drwxr-xr-x 75 maxg    maxg          4096 Apr  3 09:49 ..
drwxrwxrwx  7 dnsmasq avahi-autoipd 4096 Apr  3 13:45 .git
drwxrwxrwx  2 dnsmasq avahi-autoipd 4096 Feb  9  2019 helpers
drwxr-xr-x  3 dnsmasq avahi-autoipd 4096 Feb  2 05:29 html
drwxr-xr-x  3 dnsmasq avahi-autoipd 4096 Jan  1  2019 icons
drwxr-xr-x  2 dnsmasq avahi-autoipd 4096 Feb  2 05:29 items
drwxr-xr-x  2 dnsmasq avahi-autoipd 4096 Apr 21  2020 misc
drwxr-xr-x  2 dnsmasq avahi-autoipd 4096 Feb  2 05:29 persistence
drwxr-xr-x  2 dnsmasq avahi-autoipd 4096 Feb  2 05:29 rules
drwxr-xr-x  2 dnsmasq avahi-autoipd 4096 Feb  2 05:29 scripts
drwxr-xr-x  2 dnsmasq avahi-autoipd 4096 Feb  2 21:10 services
drwxr-xr-x  2 dnsmasq avahi-autoipd 4096 Feb  2 05:29 sitemaps
drwxr-xr-x  2 dnsmasq avahi-autoipd 4096 Feb  2 05:29 sounds
drwxr-xr-x  2 dnsmasq avahi-autoipd 4096 Feb  2 05:29 things
drwxr-xr-x  2 dnsmasq avahi-autoipd 4096 Feb  2 05:29 transform
drwxrwxrwx  2 dnsmasq avahi-autoipd 4096 Nov 12 20:26 .vscode

If I want to create a file on the mounted remote OH system I get a permission error.

# [2021-04-03 13:53] maxg@maxg-pc-mint ~/openhab $ 
touch delete.me
touch: cannot touch 'delete.me': Permission denied

Any hints appreciated.

[edit1] Just to be sure it is not the local machine, I ran:

sshfs maxg@rpi3ohv2:/etc/openhab2 /home/maxg/oh

… on my notebook, which can also not create a file on the remote OH share.
[/edit1]

[edit2] I forgot to say that I (maxg) am a member of the openhab group on the OH machine.
I also changed the file rights (from 755) to 775… which did not change the outcome.

I also forgot to say that I can in VSCode modify existing files, but cannot create new ones.
[/edit2]

Just a guess:

I am really not that expert on the linux side to be honest, but i can not see, that you are connecting the shares with the openhab user. (Or it is due to my limited knowledge of fstab)
This was a problem on windows for me too once.
When i connected the share using the correct credentials, it worked for me on windows.

And it looks like you are using special credentilas for the hpserver too, so that could be worth a try.

Thanks… I will update the post that I am a member of the group openhab on the remote (OH) machine.

My installation is from yonks ago; hence, I can’t remember the openhab user password. Its samba password is known; maybe it is the same as for the karaf console. I tried these to no avail.

I also changed the file rights to 775 (instead of the 755 it had); which also did not change the behaviour (as in allowing me as maxg to write to the share).

That fstab entry has been there for yonks too… and worked until Aug/Dec implied by the file timestamps I can see int the .git and .vscode directories.

What I completely forgot to say is: I can modify the .items and .rules via VScode though…

Unable to write file '/home/maxg/openhab/rules/delete.me' (NoPermissions (FileSystemError): Error: EACCES: permission denied, open '/home/maxg/openhab/rules/delete.me')

… but can modify existing files… (go figure)… :man_facepalming:

Well, I took a shotgun approach and gave the ‘world’ rwx.
This will solve this in the interim.

For any other user: this is not a proper solution!

1 Like

The uids/gids on your openhab host and your local machine are not reserved for openhab in the same way. uid: openhab on PI = dnsmasq on localhost; gid: openhab on PI = avahi-autopid on localhost.
What about user max and his group ?
User max, openhab resp. the groups need to be defined in the same way on both hosts.

Because it’s a somewhat silly idea to use CIFS (a Windows technique) to share between UN*X boxes.
See Amanda README (search for ‘CIFS’) for details.

Long story short: use NFS for this.

hm, there are two entries in Max’s fstab file one using cifs the other one using nfs. As far as I understood the problematic one is the nfs one. The cifs one is not mentioned in the problem description.

Correct :slight_smile:

The CIFS goes to a Windows HomeServer; the last entry to 192.168.1.5 is the rPi OH machine.

I thought, if maxg is a member of the openhab group (and so is openhab) on the OH machine, then I should be able to access the files.

Well your post was misleading then as you were starting with a Samba config sniplet.

Read the Amanda docs nonetheless look for root_squash (from memory).

Not sure what is misleading in my post?!

I can’t write to a samba share, the share is the OH config. I showed what the samba config is for this share, what rights I see when I list the directory, what the OH shows in the same directory.
I provided what I thought to be relevant information; please tell me what is ‘misleading’ and I am happy to update my post accordingly.

Your description is confusing. If I understand it right you have a UNIX server 192.168.1.5 with a directory /etc/openhab2 that you ATTENTION: NFS -mount on another Linux client and cannot properly access it there.
You don’t try to write to a Samba share. You try to write to an NFS exported directory (or “NFS share”), that is a directory on a remote machine, not a “Samba share”. Samba has nothing to do with that.
So why do you keep quoting Samba config that is misleading.

While I work with Linux as an end user, (hence, many problems are solved by googling and not necessarily understanding them) and all works as expected; except this share…

Do I gather from your reply that

192.168.1.5:/etc/openhab2         /home/maxg/openhab      nfs4    _netdev,auto    0    0

… should be set up as CIFS ‘entry’ (for a better word) in fstab. (Similar to the HPSERVER connections, and which supplies username and password?)

Is this the reason I cannot write to the share?
Or in other words: maybe my fstab entry is the mistake, rather than misleading?

No.
NFS4 is fine, but you probably need to export it with the no_root_squash option on the server side.

No.

1 Like

as stated above as far as I understand linux permissions the problem is that users on the two systems have different name to id defintion. max on one system is a different user than max on the other system. Similar for the groups. If they would match it should work.

Right. Google for as I said no_root_squash.

To answer the need for a samba share:
I used to connect to OH from a Windows machine. However, I switched to Linux on the desktop and, hence use Linux to access Linux. I thought Linux can access a samba share as much as Windows can.

It seems to me that I should have used a fstab line to access OH from Linux on a samba share that looks syntactically like the HPSERVER entry (which is a share on a Windows server).

From what I gather, if I were to use NFS, I would have to install a NFS server and client, and configure the lot. which I have never (or had to do, because I was using samba shares) for both Windows and Linux clients.

That’s a quite common mistake but still a mistake. And now that you moved the client to Linux the need for Samba is gone isn’t it.

I think it’s just the nfs-kernel-server package yes you have to google a bit but it’s not difficult.

1 Like