Having difficulties setting up samba or file permissions

Hello all

I’m trying to set up a samba share’s with a user with read only access and a user with read and write access, I can get read and write access working but not read only access.

I’m using linux mint in a VM and the shares are being accessed by windows.

This is what I’m working on so far.

sudo adduser --no-create-home --disabled-login readonly1

sudo smbpasswd -a mintvm
sudo smbpasswd -a readonly1

sudo groupadd share-1-ro
sudo groupadd share-1-rw

sudo usermod -aG share-1-rw mintvm
sudo usermod -aG share-1-ro readonly1

sudo mkdir /mnt/ssd2/share1

sudo chown root:share-1-rw /mnt/ssd2/share1

sudo chmod 2770 /mnt/ssd2/share1

sudo setfacl -b /mnt/ssd2/share1

sudo setfacl -m g:share-1-rw:rwx /mnt/ssd2/share1
sudo setfacl -m g:share-1-ro:rx /mnt/ssd2/share1
sudo setfacl -m m:rwx /mnt/ssd2/share1
sudo setfacl -d -m g:share-1-rw:rwx /mnt/ssd2/share1
sudo setfacl -d -m g:share-1-ro:rx /mnt/ssd2/share1
sudo setfacl -d -m m:rwx /mnt/ssd2/share1

share1

path = /mnt/ssd2/share1
browsable = yes
read only = yes
valid users = @share-1-ro @share-1-rw
read list = @share-1-ro
write list = @share-1-rw

share2

path = /mnt/ssd2/share2
browsable = yes
read only = yes
valid users = @mintvm
read list = @mintvm
write list = @mintvm

And so far this is what it does

share1
mintvm has access
readonly1 does not has read only access

share2
mintvm has access

I have tried to figure out what’s wrong but I just don’t know

In my example I don’t know why [share1] and [share2] look like that and I don’t know how to fix it.

After taking about a week break from this I decided to come back to it, I have since found and followed this “ Samba - Part 3 - Set Up Samba with Separate Read/Write Access ” but sadly no luck.

It seems pretty straightforward but I’m still failing somewhere.

1 Like

Did you ensure your share-1-ro user can read files in /mnt/ssd2/share1 on the server itself? I.e. switch to the share-1-ro user by running something like sudo su --shell /bin/bash share-1-ro and make sure files are accessible.

If you don’t need to keep info on which user created a certain file on the share you can also work around the whole (server-file-system) access rights issue by configuring force user = <some-server-user> (and possibly the same for force group) in smb.conf to make all file accesses done as that user on the server side (you can still configure read-only access for specific samba users in the share configs).

I all else fails, try running net cache flush on the server; there are long-standing bugs in samba relating to access rights that can be (temporarily) cleared by this command.

3 Likes

Thank you for your help
After switching to readonly1 in terminal and then trying to access cd /mnt/ssd2/share1 and cd /mnt/ssd2 I get “Permission denied”

so readonly1 doesn’t have access to ssd2 and is a virtual drive, I guess it needs a different Mount option to be shared?

I’m planning on switching a Windows 10 PC to mint so I’m testing the configuration in a VM before I deploy it.

I presumed readonly1 had access to ssd2, I’ll look into that tomorrow and thank you again.

No worries. :slight_smile: I’ve been struggling with samba permissions myself so I know what it’s like…

All parent directories need to be readable+“enterable” (r+x) for the user in question as well. Maybe that’s the issue?

1 Like

Ok I’ve got it working
on ssd2 properties then permission and changed the third folder access to access files from none and when I run ll in /mnt ssd2 goes from drwx------ to drwx—r-x and appears to work fine.

Not too sure if this is the correct / secure way of doing it, but I’d say it’s a good start.

1 Like

In my spare time I’ve been continuing to research permissions and other stuff sure can get complicated.
I’m currently working on a simple way of doing what I want to do, once I’m happy with the setup I’ll try to remember to post it.