File ownership on Samba Share

Asked by Gunnar Tryggvason on 2009-11-24

I mount this share in the fstab-file.: //192.168.1.100/gagnadiskur /media/samba_share cifs credentials=/etc/samba/user,iocharset=utf8,noexec 0 0., like this.
The files on the samba-file-server pc are owned by the user=gunnar and in the smb.conf. file I use "force user=gunnar".
But on a client where there are 4 different users, the files on the samba server are owned by a different user which blocks others to create files on the samba share.

What I want to accomplish is that each user will be owner of files and folders who he/she creates and belonging group.

Can I mount different samba-shares for each user on the client pc (4 different users), so that each mount only appears at one user, not them all? Is there a way to mount different shares at each login?

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu samba Edit question
Assignee:
No assignee Edit question
Last query:
2009-11-24
Last reply:
2009-11-25
Ryan Dwyer (ryandwyer) said : #1

Sounds like you need to:
- Remove the force user line from smb.conf
- Create an account for each user on the Samba server (and sync them to Samba's passdb backend)
- Create a group (eg. shareusers) and set that as the primary group for each user
- chgrp the existing files to shareusers
- chmod the existing files to 775, so the shareusers group can write to it
- Set create mask = 775 and directory mask = 775 in smb.conf

Then the files they write will have their own account as the owner, and shareusers as the group. The 775 permissions allow them to change each others files.

Tanks very much.

It seems like my problems has to be related to the client, I changed
what you suggested. If I am logged in as f.eks. the user tryggvi he gets
ownerships of his newly created file. But if I am logged in as I,
gunnar, then my files which I create gets the ownership of user=harpa.
But when I check on the samba-server the owner is gunnar?????? The
shared folder is owned by gunnar on the server, but not at the client.
I am afraid I made some mistakes when I created the disk on the server
or there are some mismatch regarding samba accounts and the client
pc-accaunts. I want to get a good course at spidertools or a good book
on samba, any recomantations?

Tanks.

Here follows part of my smb.conf.

[global]
    netbios name = Gagnadiskur
# server string =
    workgroup = strand
    announce version = 5.0
    socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE
SO_RCVBUF=8192 SO_SNDBUF=8192
    passdb backend = tdbsam
    security = user
    null passwords = true
    username map = /etc/samba/smbusers
    name resolve order = hosts wins bcast
    wins support = yes
    syslog = 1
    syslog only = yes
    usershare owner only = false

[gagnadiskur]
    path = /gagnadiskur/
    browseable = yes
    read only = no
   ; writable = yes
   ; valid users = gunnar,harpa,maria,tryggvi,fartolva,gt
    guest ok = no
    create mask = 0775
    directory mask = 0777
  ; force user = gunnar
  ; force group = gunnar

On Tue, 2009-11-24 at 12:18 +0000, Ryan Dwyer wrote:
> Your question #91515 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/91515
>
> Status: Open => Answered
>
> Ryan Dwyer proposed the following answer:
> Sounds like you need to:
> - Remove the force user line from smb.conf
> - Create an account for each user on the Samba server (and sync them to Samba's passdb backend)
> - Create a group (eg. shareusers) and set that as the primary group for each user
> - chgrp the existing files to shareusers
> - chmod the existing files to 775, so the shareusers group can write to it
> - Set create mask = 775 and directory mask = 775 in smb.conf
>
> Then the files they write will have their own account as the owner, and
> shareusers as the group. The 775 permissions allow them to change each
> others files.
>

--
Gunnar Tryggvason
Sími 461 3140
Fax 461 3142
Vasasími 893 7294

Ryan Dwyer (ryandwyer) said : #3

That would be caused by something in your username map. You shouldn't need it, so remove the username map line.

Can you help with this problem?

Provide an answer of your own, or ask Gunnar Tryggvason for more information if necessary.

To post a message you must log in.