Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Red Hat This forum is for the discussion of Red Hat Linux.


  Search this Thread
Old 02-13-2013, 02:30 PM   #1
LQ Newbie
Registered: May 2004
Distribution: Fedora and CentOS
Posts: 9

Rep: Reputation: 0
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:

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

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:
$ 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:

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.

Old 02-16-2013, 02:36 PM   #2
John VV
LQ Muse
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,093

Rep: Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474
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

su -
yum --releaseserver=6.3 upgrade
you can add a mask in the fstab file to override the default permissions
man fstab
---- and ----
man mount
Old 02-25-2013, 04:11 PM   #3
LQ Newbie
Registered: May 2004
Distribution: Fedora and CentOS
Posts: 9

Original Poster
Rep: Reputation: 0
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:
/tsbackupshare	/etc/auto.tsbackupshare --ghost
In our auto.tsbackupshare file:
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:
$ 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:
$ 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.



autofs, permissions

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Modifying FTP user' rights/permissions/upload criteria Brent45 Linux - Newbie 2 07-15-2010 02:12 PM
problem logging in with automounted home directories al.lmco Linux - Networking 1 10-15-2008 09:16 PM
Permissions and directories arubin Slackware 6 09-21-2007 03:56 AM
Mystery directories in automounted directory flgal3 Linux - Enterprise 0 02-24-2006 08:53 AM
modifying permissions in slackware noxious Slackware 3 09-09-2004 09:45 PM

All times are GMT -5. The time now is 04:40 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration