Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am running a Samba Server (Version 3.5.6). The file sharing is OK until I realize that Samba changes file ownership when another user (not the original owner) edit the file and saves it. This is particularly true, if I have set admin users parameter to administrate the share.

The strange thing is only the file ownership get changed but 'directory ownership' remain unchanged (which is desirable) :)

Options like force user and force group are not going to work here because, sharing directory have a different sub-directories that belong to many users.

Configuration for the share looks like this

[staff]

    comment = "Staff members only"
    path = /path/to/staff
    browseable = yes
    valid users = @staff, @managers, @moderators
    write list = @staff, @managers
    create mask = 0640
    directory mask = 0750
    admin users = @moderators`

As you can see, members in above-mentioned groups are allowed to read others data but only members of @moderators can do changes to file & directories.

Problem arises when a member of @moderators modifies a file (not a directory) that belong to another user (belong to @staff or @managers), the ownership of that edited file changes to root!!! which is totally undesirable.

I want to preserve the ownership of the file to its original creator even after a member of @moderators modifies it. How Do I Achieve This???

Thank you in advanced.

share|improve this question
add comment

1 Answer 1

Do not use "admin users" for the file modifications, because members of this setting operate as root on the filesystem. Quoting from smb.conf man page:

admin users (S) This is a list of users who will be granted administrative privileges on the share. This means that they will do all file operations as the super-user (root). You should use this option very carefully, as any user in this list will be able to do anything they like on the share, irrespective of file permissions.

share|improve this answer
    
I know that fact but why Samba change owner of a file to "root"? That was my problem! –  nobody Jan 17 '12 at 15:31
    
I observed the file ownership changing when a certain user has write permissions in a directory but the file itself is not writeable by the group. Looking at your create and directory mask I would guess this is the case. Try to give the group write permissions on the files and make the directory sticky and set-gid (+t +s). Still I don't recommend using the "admin users" group for working with the files. –  oddfellow Jan 21 '12 at 10:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.