LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 10-06-2011, 10:52 AM   #1
baronobeefdip
Senior Member
 
Registered: Jul 2009
Distribution: Debian Squeeze
Posts: 1,267

Rep: Reputation: 32
How do i grant permissions to samba users


we want to setup a samba share where a certain user has permission to write, browse and read the share while we have other users that have permission to read and browse but not write. is this possible and how do i go about doing it.

Last edited by baronobeefdip; 10-06-2011 at 11:21 AM.
 
Old 10-06-2011, 01:21 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

You can use acls to achieve this. Here is what you have to do:

1. Create one group say sharerw and add the users who will require read and write access.
2. Create another group say sharero and add the user who will require read only access.
3. Use setfacl command to set up these groups on the folder with require permission. Do "man setfacl" to get more information on this command. It is quite easy.
4. In your Samba configuration file make the share browseable and make these groups allowed to access this share.
5. Restart samba.
6. When user from any of the group will access Samba share already set permission will be applicable on them.
 
Old 10-07-2011, 10:40 AM   #3
baronobeefdip
Senior Member
 
Registered: Jul 2009
Distribution: Debian Squeeze
Posts: 1,267

Original Poster
Rep: Reputation: 32
well i am at a stand still here this doesn't do me much good since you never told me how to add groups and i can't find a strait and simple answer on how to make a group let alone adding users to it and changing the groups permissions and adding the group to a samba share. i looked everywhere on the net and i now don't know what to do.
 
Old 10-07-2011, 02:28 PM   #4
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

If you would have searched on the internet with the things that I have listed I am quite sure you would have got the information. Anyways, here is how you can do:

1. Create groups one for read only access and one for read and write access:

Code:
groupadd sharerw
/* The above group will be later configured with ACL to provide users read and write access. */

Code:
groupadd sharero
/* The above group will be later configured with ACL to provide users read only access. */

2. Add users who require read and write access to sharerw group. Following is the command:

Code:
usermod -G sharerw username
3. Add users who require read only access to sharero group. Following is the command:

Code:
usermod -G sharero username
4. Set ACL on your share directory. Suppose your share directory is under /. To setup sharerw group to have read and write access to /share run the following command:

Code:
setfacl -R -m g:sharerw:rwx /share
To setup sharero group to have read only access to /share run the following command:

Code:
setfacl -R -m g:sharero:r-x /share
5. In the samba configuration file you can under your share configuration put the following lines:

Code:
writable = yes
valid users = @sharerw, @sharero
In the above configuration the users file system permission will be taken from ACL. However, if you want to skip step 4 and 5 then you can go with the following option:

4. Directly edit samba configuration file and put the following lines under your share configuration:

Code:
writable=yes
read list = @sharero
write list = @sharerw
I hope this helps.

Note: Make sure that you take backup of Samba configuration file before making any changes

Last edited by T3RM1NVT0R; 10-07-2011 at 04:10 PM.
 
Old 10-07-2011, 08:40 PM   #5
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750
This can also be done within a Samba share simply by using 'read only = yes' and 'write list = <user to have write access>'. e.g. http://oreilly.com/openbook/samba/book/ch06_02.html
 
Old 10-08-2011, 11:51 AM   #6
baronobeefdip
Senior Member
 
Registered: Jul 2009
Distribution: Debian Squeeze
Posts: 1,267

Original Poster
Rep: Reputation: 32
thanks allend, the creation of groupe wasn't necessary for you technique and was a lot easier
 
Old 10-09-2011, 04:41 AM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Quote:
setfacl -R -m g:sharerw:rwx /share
You need to use both

setfacl -R -m g:sharerw:rwx /share

and

setfacl -R -m d:g:sharerw:rwx /share

The acl setting needs to be set for the directory itself, and then for the default settings, so the sharerw group will have these permissions for files created later.
 
Old 10-09-2011, 08:09 AM   #8
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

@ jschiwal

Yes, you are right both will be required.

@ baronobeefdip

The only reason I have suggested for creating the groups as they are easy to manage. In your first post you mentioned that there are certain users which require read only access and certain users required read and write access. In my opinion when you are dealing with multiple users then group comes handy.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot change permissions for Samba users ndaka123488 Linux - Software 2 09-19-2011 11:34 PM
Samba users permissions problem Jordi Linux - Server 3 04-26-2007 02:48 AM
Samba and different permissions for different users ... pjones1974 Linux - Newbie 1 02-23-2006 12:59 PM
Samba Permissions - RWX for all Users joshnya Linux - Newbie 2 05-17-2005 11:28 AM
how to grant permissions to a user yeehi Linux - General 3 10-20-2004 07:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration