Guest and Readonly Samba Shares
In this post, I will do a quick talk about guest shares on a Samba file server. Keep up to, it will not take more than 5 minutes.
Putting simple, a guest share is a share which one do not need to provide user credentials to access, as the name implies, guests are welcome.
Although simple in theory, these guest shares might become a little more complex, according to your specific scenario.
Talking about configuration, there are two main options that affects how guest shares works.
guest account: defines which Linux system user account will be used for guest access. Here, you can use the nobody user, create a guest user or whatever. This option goes on the global section
guest ok: defines whether the share will be a guest share. Use a boolean here, like true, 1 or yes. This options goes on the share section
First, sets the guest user account:
[global]
guest account = nobody
Now a simple guest share:
[public]
path = /var/www/public
comment = This is a public share
guest ok = yes # You also can use public = yes
With this configuration, everyone in your network will be able to read/write on the www share - please do not do this in a production environment. Obviously, the nobody user account should have the proper permissions on the system directory, in this case, the /var/www was changed to user and group nobody.
Another cool configuration is the readonly share. In this share, the files and directories should be readable for everyone but writable for only a few, usually a group. Let's take a look at the configuration for a readonly share.
[readonly]
path = /var/www
comment = This is a readonly share
guest ok = yes
write list = @webdev
A little more of spice...
[readonly]
path = /var/www
comment = This is a spicy readonly share
guest ok = yes
write list = @webdev
force group = +webdev
create mask = 0775
directory mask = 0775
The force group = +webdev line is very interesting. It will force the files and directory groups to webdev, if the accessing user belongs to this group. This is nice for group shares.
The create mask and directory mask simple defines a Unix mask that will be ANDed with the file effective mask, calculated from the DOS mapping to Unix mask. Putting simple, using these options you can assure that the files and directories will have, AT LEAST, these Unix modes.