LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-06-2013, 09:12 PM   #1
timl
Member
 
Registered: Jan 2009
Location: Sydney, Australia
Distribution: Fedora,CentOS
Posts: 750

Rep: Reputation: 156Reputation: 156
samba privileges


Hi, I set up a few shares a while ago. I use these under both windows and linux. The problem I have relates to usage on a linux box. The smb.conf for the share in question reads:

Quote:
[shared]
path = /home/doco
writeable = yes
browseable = yes
read only = no
guest ok = yes
valid users = doco
public = yes
create mask = 0666
directory mask = 0777
I mount this on my Fedora box as:

Quote:
//10.1.1.61/doco /mnt/doco cifs credentials=/home/tim/.docs_cred 0 0
I have had problems writing to files in the past and worked around this by making mods on the server. Which is not very healthy going forward!

The problem is quite simple:
  1. I mkdir a directory under the /mnt/doco folder. Let's call this /mnt/doco/coding
  2. I open an existing file in a directory under my /home (I use geany for editing)
  3. I save this file into /mnt/doco/coding
  4. I make changes and save. All good
  5. I compile. All good
  6. I try to run and things go wrong
  7. Then I start to panic.

Quote:
[tim@petunia coding]$ gcc abc.c -o abc.o
[tim@petunia coding]$ ls -lh abc*
-rwxrw-rw-. 1 503 503 278 May 7 10:48 abc.c
-rwxrw-rw-. 1 503 503 7.2K May 7 10:48 abc.o
[tim@petunia coding]$ ./abc.o
bash: ./abc.o: Permission denied
[tim@petunia coding]$ chmod 777 abc.o
chmod: changing permissions of ‘abc.o’: Operation not permitted
[tim@petunia coding]$ sudo chmod 777 abc.o
[sudo] password for tim:
[tim@petunia coding]$
I saw a post on here recently about samba privileges but I can't find it. Basically, do I need to add some hooks either in the smb.conf file or at mount time to give me access to new files created?

Cheers
 
Old 05-08-2013, 07:27 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
guest ok (S)
If this parameter is yes for a service, then no password is required to connect to the service. Privileges will be those of the guest account.
valid users (S)
This is a list of users that should be allowed to login to this service
create mask (S)
When a file is created, the necessary permissions are calculated according to the mapping from DOS modes to UNIX permissions, and the resulting UNIX mode is then bit-wise 'AND'ed with this parameter. This parameter may be thought of as a bit-wise MASK for the UNIX modes of a file. Any bit not set here will be removed from the modes set on a file when it is created....New in Samba 4.0.0. This mask is applied whenever permissions are changed on a file. To allow clients full control over permission changes it should be set to 0777.

According to this settings you will be mapped to guest and execute permission is removed, and not allowed to restore.
 
1 members found this post helpful.
Old 05-08-2013, 06:37 PM   #3
timl
Member
 
Registered: Jan 2009
Location: Sydney, Australia
Distribution: Fedora,CentOS
Posts: 750

Original Poster
Rep: Reputation: 156Reputation: 156
thanks pan64. Your explanation on the mapping of permissions (execute permission is removed, and not allowed to restore) explains my predicament and also why I can read/write office docs with no fuss. The solution in this instance is to create a new share for coding where I can build executables.

Cheers
 
Old 05-13-2013, 09:06 PM   #4
timl
Member
 
Registered: Jan 2009
Location: Sydney, Australia
Distribution: Fedora,CentOS
Posts: 750

Original Poster
Rep: Reputation: 156Reputation: 156
Unfortunately I am reopening this as I am not getting very far. I set up a new share:

Quote:
# Shared area for coding

[shared]
path = /home/coding
writeable = yes
browseable = yes
read only = no
guest ok = yes
valid users = coding
public = yes
create mask = 0777
directory mask = 0777
Restart smb/nmb and I mount this on my fedora box (fstab entry)

Quote:
//10.1.1.61/coding /mnt/coding cifs credentials=/home/tim/.coding_cred 0 0
Then:

Quote:
[tim@petunia ~]$ cd /mnt/coding/
[tim@petunia coding]$ touch aaa
touch: cannot touch ‘aaa’: Permission denied
but the file is created

Quote:
[tim@petunia ~]$ ls -lh /mnt/coding/aaa
-rw-r--r--. 1 506 506 0 May 14 11:33 /mnt/coding/aaa
I copy a file from my home area into the share and the privileges change:

Quote:
[tim@petunia ~]$ ls -lh Documents/coding/sizes.c
-rwxrw-r--. 1 tim tim 1.1K May 9 11:24 Documents/coding/sizes.c
[tim@petunia ~]$ cp Documents/coding/sizes.c /mnt/coding/
[tim@petunia ~]$ ls -lh /mnt/coding/
total 1.0M
-rwxr--r--. 1 506 506 1.1K May 14 2013 sizes.c
I think I am confused about privileges between the samba server and my PC...I specified a mask of 777 so everyone should be able to read, write, execute. Is that right? However, I am losing group privileges when I copy to the share. Basically, when I create a file in the share, on my Fedora box I want it to be writeable and executable from the Fedora box. Are there any other setting I need to add to smb.conf?

thanks
 
Old 05-14-2013, 12:23 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
I think the problem is related to user ids, somehow they are not properly configured. You can see used ids instead of user names.
touch aaa created the file but it was immediately owned by someone else and you will have no write access any more. So can you please tell us some details about the users (tim, coding, doco, 503, 506) on both hosts.
 
Old 05-14-2013, 07:22 PM   #6
timl
Member
 
Registered: Jan 2009
Location: Sydney, Australia
Distribution: Fedora,CentOS
Posts: 750

Original Poster
Rep: Reputation: 156Reputation: 156
Hi,

tim is the account I use to login at the client end (petunia).

coding (506) is the owner of the share in question on the server. Set up with:

Quote:
sudo useradd -c "Coding section" -d /home/coding/ -s /sbin/nologin coding
doco (503) is the owner of the doco share (/home/doco). I don't have any records on how this was set up.

So when the client mounts the coding share it uses the coding login to verify with the server. However, tim is logged in to the client and there is no coding login on the client.

Cheers
 
Old 05-15-2013, 01:23 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
try to chmod 777 on /mnt/coding/aaa
what is your umask settings
 
Old 05-15-2013, 07:07 PM   #8
timl
Member
 
Registered: Jan 2009
Location: Sydney, Australia
Distribution: Fedora,CentOS
Posts: 750

Original Poster
Rep: Reputation: 156Reputation: 156
my umask is 002. I recreated the aaa file and tried chmod. From my user this did not work, from root it worked.

Quote:
[tim@petunia coding]$ touch /mnt/coding/aaa
touch: cannot touch ‘/mnt/coding/aaa’: Permission denied
[tim@petunia coding]$ ls -lh /mnt/coding/aaa
-rw-r--r--. 1 506 506 0 May 16 2013 /mnt/coding/aaa
[tim@petunia coding]$ chmod 777 /mnt/coding/aaa
chmod: changing permissions of ‘/mnt/coding/aaa’: Operation not permitted
[tim@petunia coding]$ ls -lh /mnt/coding/aaa
-rw-r--r--. 1 506 506 0 May 16 2013 /mnt/coding/aaa
[tim@petunia coding]$ sudo chmod 777 /mnt/coding/aaa
[sudo] password for tim:
[tim@petunia coding]$ ls -lh /mnt/coding/aaa
-rwxrwxrwx. 1 506 506 0 May 16 09:50 /mnt/coding/aaa
So the file is created under the user coding (506) while I am logged on as tim. Do I need to include something in smb.conf to open up access to the tim user/group?

Cheers
 
Old 05-16-2013, 01:59 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
probably force create mode can help you
 
Old 05-19-2013, 07:41 PM   #10
timl
Member
 
Registered: Jan 2009
Location: Sydney, Australia
Distribution: Fedora,CentOS
Posts: 750

Original Poster
Rep: Reputation: 156Reputation: 156
Hi pan64, I tried that as well but no joy. I have set up a VirtualBox PC to play around with this problem. The first share I created had exactly the same problem.

From the posts you have made so far I can see that this is a problem relating to ownership conflicts between the share and the host computer. I guess I need to dig deeper to find a solution to this. If/when I come up with a solution I will post it here.

Thanks
 
Old 05-21-2013, 05:44 AM   #11
timl
Member
 
Registered: Jan 2009
Location: Sydney, Australia
Distribution: Fedora,CentOS
Posts: 750

Original Poster
Rep: Reputation: 156Reputation: 156
okay, looks like I am in business now. First of all I will have to go back on my last post as I added "force create mode = 777" & "force directory mode = 777" and I can read, write & x. The other thing I came across which will not have been evident from any of my posts is that I was using the share name [shared] for all my shares! Changing this to [coding] could also have helped to solve this:

Quote:
[coding]
path = /home/coding
valid users = coding
read only = No
create mask = 0777
force create mode = 0777
directory mask = 0777
force directory mode = 0777
anyway, thanks for all the help. I will mark this one as solved in a day or 2 unless something else goes wrong

Cheers
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What privileges must a user have to access a Samba share FiftyOneFifty Linux - Server 3 12-02-2011 02:12 AM
Samba-Windows-NFS - Privileges Problems blu_alchemist Linux - Server 4 06-07-2007 03:45 PM
Another attempt to get user rw privileges for samba shares Jeebizz Slackware 10 01-11-2006 11:37 PM
Samba Users & Groups Privileges Bilal84 Linux - Networking 3 10-11-2005 08:31 AM
How to grant domain Administrator privileges on Samba mfeoli Linux - Networking 2 01-12-2004 11:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:05 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