Samba "chmod 777" config without security=share

I regularly find myself in need of a samba config that shares a directory and "just friggin works". In those situations, I don't need authentication, user permissions or anything - I really just need the thing to work and copy files.

I even had a config that did this, but it seemed to depend on "security = share", which has been removed in a recent version of Samba 4. Luckily, I had a couple other options in that config that caused it to work even though recent versions of samba use "security = user".

The key in getting this scenario to work is the "map to guest = bad user" line. Whenever authentication fails (and before the user even had the chance to enter credentials, it does), this line will cause samba to just use the Guest account in this case. This way, authentication is practically disabled.

So, here's the config:

   netbios name  = AWESOMEHOST
   workgroup     = WORKGROUP

   security      = user
   guest only    = yes
   map to guest  = bad user
   force user    = smb-data
   force group   = smb-data
   guest account = smb-data

   path          = /shares/daten
   available     = yes
   browseable    = yes
   guest ok      = yes
   writeable     = yes

The "force user" and "guest account" settings define which system user samba should use, regardless of whether or not the user managed to authenticate. In my case, I created a separate "smb-data" user for this purpose, but it can be any other account as well.

Note that the directory needs to be writeable for the group your smb-data user is in. So you'll at least require the directory to be chmod 775. If that still doesn't work, you can of course always resort to 777 - the config has this name for a reason anyway.