There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

Samba share writable to everyone, even if someone else created the files?

I have a public SMB share mainly as a media dump. Everyone can read and write, without any auth - as intended. However, if I copy files via SSH (as a regular user, not the samba user), these files are of course owned by that user and thus not writable for the samba user - so I can’t touch these files via SMB.

My config looks like this


<span style="color:#323232;">[public]
</span><span style="color:#323232;">  path = /path/to/samba/public
</span><span style="color:#323232;">  guest ok = yes
</span><span style="color:#323232;">  writeable = yes
</span><span style="color:#323232;">  browseable = yes
</span><span style="color:#323232;">  create mask = 0664
</span><span style="color:#323232;">  directory mask = 0775
</span><span style="color:#323232;">  force user = sambapub
</span><span style="color:#323232;">  force group = users
</span>

I can fix the permissions by simply chown/chmod all files, but that’s not really a solution.

smoof ,

My hacky way was to make sure group ID on each computer matches and have the directory writable by the group. I also make sure user ID is different so I can identify who created it. It was easy for me because I only have to worry about 2 computers plus my NAS.

nyan ,

Untested Evil Method, Not Really Recommended: format the backing file system in vfat, which has no notion of file ownership.

lazynooblet ,
@lazynooblet@lazysoci.al avatar

Add the sticky group bit to the directory so that new files are created with the group of the directory.


<span style="color:#323232;">chmod 2775 /path/to/samba/public```
</span><span style="color:#323232;">
</span><span style="color:#323232;">Now any new file will have group "users".
</span>
Nibodhika ,

I’m not 100% sure on this, but there’s a config in the general which tells samba which user to use, if none is defined it uses nobody. I assume that if you change that to the same user you use via SSH it should work.

That being said, what you’re seeing is expected, it’s complaining that you copied files as user A to a public directory and now user B can’t delete them unless user A sets the files as read/write for everyone (chmod) or transfers ownership (chown). There’s a thing called ACL’s that should allow you to set the permissions to the same as the parent folder so you can have everything be 777, but I’ve never used it so can’t really help, however with the name you should be able to find some examples on the internet.

agressivelyPassive OP ,

<span style="color:#323232;">  force user = sambapub
</span><span style="color:#323232;">  force group = users
</span>

This should set the user, and it’s exactly what I’m seeing if I copy files over via smb. I’m aware, that it’s kind if expected, but not what is intended (by me).

Nibodhika ,

Are you using the sambapub user to SSH the files into the folder? I thought that the force user refered to a samba user, not a Linux user.

jdnewmil ,

Samba is a pipe of sorts… those settings only apply to files created using that pipe.

SSH is a different pipe, with different configuration. I think you need to modify the umask of the user connecting via ssh and/or add them to a samba group.

agressivelyPassive OP ,

umask seems to only set the permissions, not the ownership. But ownership seems to be necessary to delete files.

jdnewmil ,

… which is why you also need to join the samba group.

agressivelyPassive OP ,

The user is in that group, but files are (by default) owned by the user (that is, the group of the same name as the user, I’m not sure, what the wording is).

However, at least it seems to currently work somewhat. I had to chown and umask the entire share, and then restart the machine. Maybe some dangling session interfered?

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines