Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Shared directory behavior

  1. #1
    Join Date
    Feb 2010
    Beans
    166
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Shared directory behavior

    Hi,

    I have a folder that is set to one of my supplement group(say, dev). and I have made it group read/write/executable.

    But when I create files in that folder they belong to my main group and they are not group-rwx. How will I make all files created have the same permissions and group of it's directory?

    Also I found out that another user belonging to the group dev is able to delete and create files. But he couldn't execute or append. That's strange. Delete but not append !!!

  2. #2
    Join Date
    Feb 2010
    Beans
    166
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Shared directory behavior

    Please let me know if I should elaborate it with an example.

  3. #3
    Join Date
    Aug 2005
    Location
    Los Angeles area
    Beans
    602
    Distro
    Kubuntu 11.04 Natty Narwhal

    Re: Shared directory behavior

    Quote Originally Posted by john77eipe View Post
    Please let me know if I should elaborate it with an example.
    Yes. Please post the output of:
    Code:
    ls -l
    in the parent directory of the directory you're referring to.

    In other words, if the directory you're talking about is called something and it's located under /home/user/yourname, please be in /home/user/yourname when you issue the ls -l command. We need to see the permissions and ownership info for something. Then cd to something and again issue ls -l and post its output (all of it).

  4. #4
    Join Date
    Feb 2010
    Beans
    166
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Shared directory behavior

    $ ls -l | grep share
    drwxrwxr-t 2 eipe dev 4096 2010-12-16 20:34 share

  5. #5
    Join Date
    Dec 2007
    Location
    The last place I look
    Beans
    Hidden!
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Shared directory behavior

    try using setGID on the folder that holds the share, and in your samba Create Mask.
    setGID on a folder will cause all files created in the folder to be owned by the same ownergroup as the folder. on executable files, it will cause the execution to occur under the rights of the group.

    http://en.wikipedia.org/wiki/Setgid

    you can enable SetGID on a folder with
    Code:
    chmod -R g+s <folderpath>
    use sudo if the user does not have write permissions on the folder.

    for samba, if you are using /etc/samba/smb.conf, the create mask should be 2776 for your permission set. the 2 enables setgid.
    Things are rarely just crazy enough to work, but they're frequently just crazy enough to fail hilariously.

  6. #6
    Join Date
    Feb 2010
    Beans
    166
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Shared directory behavior

    Thank you.

    I'm not on an ubuntu system right now. But I'll check tomorrow.

    Also I'm not using Samba. What is it used for?

  7. #7
    Join Date
    Dec 2007
    Location
    The last place I look
    Beans
    Hidden!
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Shared directory behavior

    ahh, after rereading, don;t worry about samba. I was under the impression you wished to share the directory over your network. anyway, just makes the job all the easier.

    also in terms of Deleting/creating, you might also want to look into the sticky bit. it allows users to only delete files on which they are the user-owner, even if the user has the write privilege.
    Code:
    sudo chmod +t <path to dir>
    that way everyone has write based on their group membership in Dev, and can add to eachothers files, but they cannot rename or delete files without first taking ownership (if they are able).
    Things are rarely just crazy enough to work, but they're frequently just crazy enough to fail hilariously.

  8. #8
    Join Date
    Dec 2009
    Beans
    5,779

    Re: Shared directory behavior

    doas777. It could be that we are saying the same thing in a different way but the original requirement was:
    But when I create files in that folder they belong to my main group and they are not group-rwx. How will I make all files created have the same permissions and group of it's directory?
    If you originally created a directory that has "dev" as group then I would set the permissions on that directory such that every new file "inherits" the group:
    Code:
    sudo chmod 2775 /path-to-directory
    But there is a problem. When morbius adds a new file it will save with the correct group but with the wrong permissions:
    owner = morbius
    group = dev
    permissions = 644
    All other members of the dev group can still only read but not write to the file.

    I beleive what needs to be done next is to change the default umask from 022 to 002 in /etc/profile. Then the file will save as 664 allowing other group-dev users the ability to edit the file.

    It's also possible I misunderstood the requirement

  9. #9
    Join Date
    Feb 2010
    Beans
    166
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Shared directory behavior

    Yes you guys are right.
    setgid on a directory helps to make the group id inheritable to all the files under the directory. So 1 problem solved.

    [quote]I beleive what needs to be done next is to change the default umask from 022 to 002 in /etc/profile.[quote]

    But this would affect all files created by the user. I guess there is no way we could make it happen for a specific directory alone.

    I think the default behavior of unix is weird. Consider 2 user's john and tom belonging to group dev. Now a folder is created with dev as the groupid and group permission set to rwx.

    John creates a file inside. Surprisingly Tom can delete that file but not modify/execute it.

  10. #10
    Join Date
    Dec 2009
    Beans
    5,779

    Re: Shared directory behavior

    I beleive what needs to be done next is to change the default umask from 022 to 002 in /etc/profile.

    But this would affect all files created by the user. I guess there is no way we could make it happen for a specific directory alone.
    EDIT: Even with a built in spell checker I still can't spell believe.

    Yes and No.

    If you set umask to 002 then any new file created anywhere will have permissions of 664. But outside of the folder that you did a chmod 2775 it will save as owner = group = morbius. No other group can edit the file.
    John creates a file inside. Surprisingly Tom can delete that file but not modify/execute it.
    Yep, I suppose that is wierd. It's the difference in the meaning of permissions on a directory vs a file:

    Write on a file means the ability to edit it's contents - to add or delete the content of the file.

    Write on a directory , in a way, means the same thing. The ability to add to or delete from the contents of the directory - i.e., add or delete files and subdirectories from the contents of the parent directory.
    Last edited by Morbius1; February 27th, 2011 at 06:14 PM.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •