Thursday, February 3, 2011

How do I force specific permissions for new files/folders on Linux file server?

Hi All,

I'm having an issue with my install of Ubuntu 9.10 (file server) and its samba permissions. Logging in and reading works fine. However, creation of new directories by users restricts access for other users. For instance, if Bob (Windows user who maps the drive) creates a folder in the directory, Jane (Mac user that simply smb mounts) can read from it, but can't write to it -- and vice versa. I then must go CHMOD 777 the directory for everyone to be happy. I've tried editing the "create/directory mask", and "force" options in the smb.conf file but this doesn't seem to help.

I'm about to resort to CRONTABing a recursive chmod routine, although I'm sure this isn't the fix. How do I get all new items to always be 777? Does anyone have any suggestions to fix this ever-occurring situation?

Best

  • Set the permissions on the directory to be 2777, like this:

    chmod 2777 /shared/dir
    

    This causes all files and folders under the '/shared/dir' directory to inherit the permissions of the top directory, in this case 777.

    Afterwards, do this to make sure all files have the proper permissions:

    chmod -R 777 /shared/dir
    
    Warner : About the only situation where publicly writable is acceptable is with `/tmp`.
    Mistiry : Yeah, probably better to use 774 or even 770, depending on the situation. But, he asked how to make them all '777', so I just used that in my example.
    humble_coder : Yes, but how do I ensure that all future files copied to that directory over the network receive the same permissions regardless of their initial permissions? I have no problems when manually doing it, I simply want it automated.
    From Mistiry
  • I typically use SAMBA's native functionality for permissions and groups management on shares. For example..

    force user=user1
    force group=sharedgroup
    create mask=775
    

    You would specify these settings under the share. Be certain to reload SAMBA after the configuration change, which could be done via the init script.

    Mistiry : Yet the post says he did that and it didn't work....
    Warner : Then he did it wrong. It works.
    humble_coder : I'm not sure what's up. I've tried it manually and via Webmin to no avail. Perhaps my group choice of group is wrong? I've tried using "users" as well as various manually created groups, of which all have been made members. Regardless of what I do, users can't manipulate anything they didn't place themselves. The only "solution" is to have all users log in (or mount) as GUEST which produces confusion.
    Warner : SAMBA uses a combination of filesystem permissions and settings within the configuration. If users aren't on a `write list` or otherwise allowed to write in the share configuration, it will not work. If the user that SAMBA runs at is unable to access the directories, it will not work. Users should be members of the appropriate group, the directories and files should be owned by that group, and have the writable bit set for the group. You can check the SAMBA logs as well.
    humble_coder : Yes, and to my knowledge I've done this. After reading repsonses I know *what* needs to be done (and I feel that I've done it), but apparently I'm missing something. Can you point me to a bit of info on something specific? Thanks, btw.
    Warner : Does the user writing have permissions on the local filesystem as well as via the SAMBA configuration? The user would need to be owner or member of the group with permissions to write as well as be on the write list, for example.
    From Warner

0 comments:

Post a Comment