LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (http://www.linuxquestions.org/questions/red-hat-31/)
-   -   Modifying permissions on automounted directories in CentOS6 (http://www.linuxquestions.org/questions/red-hat-31/modifying-permissions-on-automounted-directories-in-centos6-4175450029/)

greyseal96 02-13-2013 02:30 PM

Modifying permissions on automounted directories in CentOS6
 
Hello all,

I'm on a CentOS 6.2 box and I've been playing around with setting up autofs to automount a shared directory from a NAS. I've got a question about the permissions that are set on directories which are automounted by autofs and if it's possible to change them. After automounting the directory, the mount point directory is always assigned the permissions of 755. Is it possible to get these permissions changed somehow to 775? Here is my config:

I am mounting a shared directory from a NAS using cifs. Here is what's in my /etc/auto.master file:

Code:

/tsbackupshare  /etc/auto.tsbackupshare --ghost
Here's what's in my /etc/auto.tsbackupshare file:

Code:

obackups  -fstype=cifs,gid=502,rw,guest,ip=10.17.x.x            ://BackupDrive/OBackups
When the share is mounted, here are the privileges that it has:
Code:

$ ls -al /tsbackupshare
total 4
drwxr-xr-x.  3 root root    0 Feb 12 16:12 .
dr-xr-xr-x. 26 root root 4096 Feb 12 16:12 ..
drwxr-xr-x.  1 root dba    0 Feb 12 15:15 obackups

What I'm going for is to have something where I could have multiple users assigned to the dba group and this directory would be automounted and they could have read/write permissions to this directory. So I'd like to have permissions like this:

Code:

drwxrwxr-x.  1 root dba    0 Feb 12 15:15 obackups
As it is now, users in the dba group can only read from the directory. One possible path is to use the "uid=" parameter to assign one of the users from the dba group as the owner and then one of the users can write to the directory but none of the other users of the group can write to the directory. But I don't want only one user to be able to write to this directory. I don't see the purpose of assigning a group if the group will only have the same permissions as "others". That doesn't make too much sense so I figure there's got to be a way to assign read/write privileges to the group too; I just don't know how to do that yet (hoping it's possible). :)

I've searched all over the internet to try to find a solution to this. I found one suggestion to "pre-create" the directories, assign the permissions that you want, and then they will be carried over after autofs mounts the directory. No matter what, though, permissions are reset after autofs mounts the directory (which is, I guess, to be expected).

Is there any way to control what the permissions are set as with autofs? It seems like the only solutions is to let only one user have read/write access.

I really like the concept of autofs and I'd prefer to use that over an entry in /etc/fstab because I like how automount will umount the directory after a period of non use. Any help would be greatly appreciated.

Thanks,
John

John VV 02-16-2013 02:36 PM

you are aware that CentOS 6.2 is unsupported and that all the software repos are now dead -- moved to the historical archive " The Vault"
please stay current and upgrade to 6.3 ASAP

Code:

su -
yum --releaseserver=6.3 upgrade

you can add a mask in the fstab file to override the default permissions
see
Code:

man fstab
---- and ----
man mount


greyseal96 02-25-2013 04:11 PM

Thanks for your response, John_VV. We are aware that 6.2 is out of date; thank you for your concern. What we're doing is actually part of our upgrade plan so that we can get up to the latest version of CentOS.

For future reference, I wanted to post here what I did to get this working. I tried adding the mask to override the default permissions that were being set. When I tried this, though, it didn't seem to have any effect. What got it working was using the dir_mode and file_mode options which are detailed in the man page for "cifs.mount." We're using a NAS and I guess the way that the NAS is implementing cifs doesn't support the cifs Unix extensions. Because of that, dir_mode and file_mode override the mode that is being set by default on the files and directories. Here is what our settings are:

In our auto.master file:
Code:

/tsbackupshare        /etc/auto.tsbackupshare --ghost
In our auto.tsbackupshare file:
Code:

obackups        -fstype=cifs,gid=502,rw,guest,ip=10.17.x.x,dir_mode=0775,file_mode=0775                ://BackupDrive/OBackups
Here are the resulting privileges:
The first time that we ls the parent directory, we see this:
Code:

$ ls -al /tsbackupshare/
total 3
drwxr-xr-x.  4 root root    0 Feb 25 12:09 .
dr-xr-xr-x. 26 root root 4096 Feb 25 12:09 ..
dr-xr-xr-x.  1 root root    0 Feb 25 00:00 obackups

However, after enumerating the contents of the directory (thus making automount load everything up)
we see the permissions get set correctly:
Code:

$ ls -al /tsbackupshare/
total 3
drwxr-xr-x.  4 root root    0 Feb 25 12:09 .
dr-xr-xr-x. 26 root root 4096 Feb 25 12:09 ..
drwxrwxr-x.  1 root dba    0 Feb 25 00:00 obackups

Hope this might be helpful to someone in the future. Thanks again to John_VV because it got me looking in the right direction.

Regards,
John


All times are GMT -5. The time now is 03:36 PM.