Samba changes file ownership! How do I get rid of that problem?

6,349

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:
6,349

Related videos on Youtube

tonix
Author by

tonix

Updated on September 18, 2022

Comments

  • tonix
    tonix almost 2 years

    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.

  • tonix
    tonix over 12 years
    I know that fact but why Samba change owner of a file to "root"? That was my problem!
  • oddfellow
    oddfellow over 12 years
    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.