[SOLVED] Pi + Samba, access from mac

Hi Guys,

Having a little trouble. I’ve been designing rules for my automation, and I’ve been getting tired of editing in nano, because it takes forever to figure out which functions to use. So I’ve decided to start using eclipse home designer. This software works great! I’m just having one minor obstacle, which makes it impossible to use.

I use a mac (mainly), and I’d like to edit my rules on the raspberry pi 3 through samba. The only problem is, I can’t seem to get write permissions on the /etc/openhab2 folder!

I’ve added both the pi user and the openhab user to the smb password database with smbpasswd -a USER

I’ve decided to backup the pre-fab samba configuration and start bare-bones. I found these settings in another topic, but they didn’t work so I commented out what I thought wasn’t a necessity

[global]
;server string = Samba Server Version %v
security = USER
;log file = /var/log/samba/log.%m
;max log size = 50
;idmap config * : backend = tdb
;hosts allow = 10.0.1.0/24
;cups options = raw

[openhab2]
path = /etc/openhab2/
force user = openhab
;available = yes
;read only = no
;browseable = yes
;public = no
;writeable = yes
;create mask=0777
;directory mask=0777
;only guests=no

That’s probably because openhab wants to own /etc/openhab2. I modded permissions for the folder to see if pi was able to edit it, but it was not. I changed the owner back to openhab:openhab.

tried forcing user and group. Also tried forcing directory mode 2775 but it just won’t give me read& write permissions -_-

[global]

[openhab2]
path = /etc/openhab2/
#force user = openhab
available = yes
read only = no
browseable = yes
public = no
writeable = yes
create mask=0777
directory mask=0777
only guests=no
force user = openhab
force group = openhab
force directory mode = 2775

I’m starting to think I need to add the samba daemon to the sudo’ers file or something like that. I think the pi is not giving samba full access. Why? Because even when I connect to samba using the openhab user I don’t get write permissions.

Nope.

That will not make a difference. Samba doesn’t know how to use sudo.

Did you think about using openHABian? It includes all tools useful for openHAB, including a fully working samba configuration. Instead of hacking around yourself you can have a system up in less than one hour that is known to work reliably. Also if you find room for improvement, you can discuss this in the community and everyone will benefit from it.

Thanks for the tip on openhabian, but as I have invested many hours in my current pi configuration I prefer keeping that the way it is.

Furthermore, it shouldn’t make that much of a difference. I use raspbian, which should also run samba just fine as it’s also based on debian. Maybe I used the wrong apt-get command. I purged samba completely and am now reinstalling, maybe that helps. If that doesn’t fix it I will try using the openhabian config :slight_smile: thanks!

You can use the openhabian-config tool on an existing debian/ubuntu installation. If your system is a standard raspbian, there shouldn’t be an issue. Give it a try, then select samba and see what happens.

http://docs.openhab.org/installation/openhabian.html#manual-setup

You can also check out the samba config used by openHABian. Maybe that will help

From the documentation. http://docs.openhab.org/installation/linux.html#network-sharing
Make sure that whatever user you’re using to connect to the share with also has read/write access to the files on the pi. e.g. “ls -l” Just setting the Samba ACL level will not do any good if the filesystem is restricting access.

[openHAB2-userdata]
  comment=openHAB2 userdata
  path=/var/lib/openhab2
  browseable=Yes
  writeable=Yes
  only guest=no
  public=no
  create mask=0777
  directory mask=0777

[openHAB2-conf]
  comment=openHAB2 site configuration
  path=/etc/openhab2
  browseable=Yes
  writeable=Yes
  only guest=no
  public=no
  create mask=0777
  directory mask=0777

1 Like

Does seem to be a raspi bug.

  • I reinstalled samba, after purging it
  • I tried logging in as user pi, couldn’t write. I also tried to log in as user openhab, also couldn’t write.
  • I used the openhabian smb.cnf file, disabled all shares but /etc/openhab2, no success.
  • Tried using netatalk (AFP), same issue. No write permissions
  • Tried using windows through SMB. File properties say I can write, but when I open eclipse on windows and point it to the network directory, it won’t open the files I’m after
  • So I have the same or similar issues on all platforms.
  • I update && upgraded my raspi yesterday, so I’m running all the latest package versions.

Is there any way to find out where samba gets it’s permissions? A log file maybe?

Have you checked the actual permissions on your configuration folder?

ls -l /etc/openhab2

It may be worth just resetting the ownership on the entire folder just so that you know it’s at a consistent state.

sudo chown -R openhab:openhab /etc/openhab2

There are two sets of permissions you have to consider with a network share. The filesystem permissions that govern what users on the machine have access to what, and the samba permissions which govern the permissions on a network level.

You can set samba wide open at 777, but if the filesystem is set to 755 with the owner set to root your user still isn’t going to be able to modify the files.

FWIW, I use Samba with an RPi 3 and a Mac client with no problems. I don’t have time at the moment to review exactly how I configured but I think I just followed the instructions on openhab docs site.

Thanks, your link to the documentation helped fill in some blanks. I did not find them using google unfortunately.

I managed to get it running using ls -l. Found some inconsistencies (apparently chown -R does NOT recurse in to directories within a directory??) chowning all files to openhab:openhab again to be safe.

when I log in as openhab on samba I can now write the files.

It does. That’s how I fix up the owner:group on my Pi openHAB files.

One thing to watch for… I’ve had issues with openHAB trying to read a file before it’s been completely written over SMB. It results in strange errors in the log file, but the files load correctly if they are touched to trigger a reload.

That’s a useful tip, I’ll keep it in mind if I get any inexplicable errors :slight_smile:

Then I guess something went wrong when I chowned the first time