LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-05-2007, 04:47 AM   #1
deepugopi
LQ Newbie
 
Registered: Apr 2007
Location: India
Distribution: RHEL4,Fedora6
Posts: 28

Rep: Reputation: 15
Samaba server- permission setup


Hi,
I'm using a RHEL 4.2 ES OS.I'm facing a problem regarding a folder which is shared through "samba".
eg: /sambashare

Inside that folder there are many folders.
eg : /sambashare/user1 , /sambashare/user2 , /sambashare/user3...

Thing is that the main folder (/sambashare) should only have "read" permission (to prevent users from creating extra directories or files)
while subfolders (/sambashare/user1..) should have write permission to the respective users.

Thanks & regards,
Deepu G.
 
Old 07-05-2007, 05:56 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Samba won't be able to write to a directory if you make it only writable by root.

Instead of having a /sambashare with subdirectories, you could have a service definition with

path = /sambashare/%U
 
Old 07-05-2007, 06:09 AM   #3
deepugopi
LQ Newbie
 
Registered: Apr 2007
Location: India
Distribution: RHEL4,Fedora6
Posts: 28

Original Poster
Rep: Reputation: 15
Can you please exlpain in detail..

Hi,

Thanks for the reply.But can you explain in detail to me in clearing the above said scenario.

We currently have around 30 systems of which 80% are RHEL & the rest Windows Xp.

The Main folder is /sambashare.
I Want both the linux & Windows users to access this folder.But they should write the contents to the folder which is created especially for them ( /sambashare/user1 )
or
I want to give permission in such a way that only a particular user can edit his folder contents
eg : only user1 should edit the /sambashare/user1 contents rest can read the data in it..

Regards,
Deepu G.
 
Old 07-05-2007, 06:58 PM   #4
splunk
Member
 
Registered: Jan 2007
Location: PA, USA
Distribution: Ubuntu Jaunty (9.04)
Posts: 31

Rep: Reputation: 16
This should help

This page explains the how to use the line 'path = /sambashare/%U' when setting up the share.

http://us1.samba.org/samba/docs/using_samba/ch06.html
 
Old 07-05-2007, 07:32 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
I think that there are two ways you could do this. One is to share the /sambashare directory, and use the permissions of the users subdirectories to control whether a user can write files in that directory.

I created a /home/samba directory on my old dell laptop. I created a second user, gues as well. Then I created a subdirectory for each user. I just noticed that the permissions weren't exactly what I wanted to experiment with, but I still works the way I wanted it to. ( I wanted to use group control using the "users" group, but I forgot to clear the permissions for others.)
Code:
total 24
drwx------  4 gues          503 4096 Jul  5 11:01 gues
drwx------ 35 jschiwal jschiwal 4096 Jul  5 17:54 jschiwal
drwxrwxr-t  4 root     staff    4096 Jul  5 10:50 samba
[jschiwal@delllap ~]$ ls /home/samba/ -l
total 16
drwxr-xr-x 2 gues     users 4096 Jul  5 17:39 gues
drwxr-xr-x 2 jschiwal users 4096 Jul  5 17:45 jschiwal
The samba directory is created with the sticky bit set. This was a preset share that samba swat can setup, so I used it. The reason for the sticky bit, is that file deletion and renaming are operations on the directory itself, so making a file read only, doesn't protect it from renaming or deletion. The sticky bit on the containing directory adds that protection.
You want to use it for any world or group writable directory.

I created the users' subdirectories and gave the owner full access but the group member read only access. I used the "users" group which is a standard Linux group used for the purpose of granting some permissions to all users.

---

The other way of doing this is to create [Profile] or [Home] like shares. I already had the former setup, and use security=user. If I open the workgroup and then the computer in the browser, I will see a share by my user name.
This was setup automatically using samba swat.
The thing is that the other users don't show up. The directory offered is /home/%U. The "%U" is a variable for the username. See the smb.conf manpage. It doesn't exactly say the Unix or Windows User. But assigned user. If you used a "Force User" config entry or allowed a guest, it might change to that instead.
Here are the non-default values in /etc/smb.conf (copy & pasted from the testparm output).
Code:
[Samba]
        comment = Container share
        path = /home/samba
        write list = %U
I hope they aren't too far off.

User jschiwal is able to read user gues's documents and vice versa. One user is not able to create, write, or delete a file in another users directory. Each user is able to create files in their own directory.

Essentually, this is the same as the special [Homes] share. If you used /home/ instead of /sambashare/ you could do the same thing that way.

--

Another thing you might toy around with is a share similar to a [Profile]. You could offer each user their directory. The path would be defined, in your case as /sambashare/%U.

This would have the advantage, that each user could quickly enter there own directly without having to navigate through a long list of user directries in the sambashare directory. It would still be there, so the user could if he wanted to. The latter would be a subdirectory of the [Sambashare] service. The former is its own service.

Here is what "testparm" shows for these shares:
Code:
[Samba]
        comment = Container share
        path = /home/samba
        write list = %U

[Public_%U]
        comment = users public share
        path = /home/samba/%U
        write list = %U
Given more time, I'd tweek things. The write list entry for [Samba] might be wrong. It only caught my eye after running testparm which removed all comments and defaults. A group might be a better choice, but that is untested.
However, it works as you described wanting [Sambashare] to work on your server.


---
You could also create a share for each user instead of using the %U variable, or the /sambashare/ share. Then browsing into the workgroup/domain -> computer would bring up all of the users. Even though this could be scripted to allow samba to do it on the fly when you create a new user, I think this will lead to a big mess.

Last edited by jschiwal; 07-05-2007 at 08:09 PM.
 
  


Reply

Tags
rhel4, server



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
How to setup write permission for a user veeramani Linux - Security 3 03-21-2007 08:21 AM
Samaba problem Mr.Bone Linux - Networking 5 08-29-2004 05:32 PM
Samaba Robush Linux - Newbie 3 01-29-2004 08:45 PM
Samaba setup help ogden2k Linux - Networking 9 02-05-2003 12:28 PM
samaba server is not running properly puru_09 Linux - Networking 1 08-06-2002 07:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:21 PM.

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