LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2498|回复: 8

请教,autofs自动挂载后的权限问题

[复制链接]
发表于 2006-7-22 22:39:41 | 显示全部楼层 |阅读模式
[root@localhost ~]# cat /etc/exports
#
/shared         172.16.95.0/255.255.255.0(ro,sync)
[root@localhost ~]#
挂载后即使是root也不可以写入

[root@localhost ~]# cat /etc/auto.misc
#
# $Id: auto.misc,v 1.2 2003/09/29 08:22:35 raven Exp $
#
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# Details may be found in the autofs(5) manpage

cd              -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom

# the following entries are samples to pique your imagination
#linux          -ro,soft,intr           ftp.example.org:/pub/linux
#boot           -fstype=ext2            :/dev/hda1
#floppy         -fstype=auto            :/dev/fd0
#floppy         -fstype=ext2            :/dev/fd0
#e2floppy       -fstype=ext2            :/dev/fd0
#jaz            -fstype=ext2            :/dev/sdc1
#removable      -fstype=ext2            :/dev/hdd

linux           -ro,soft,intr           172.16.95.101:/shared
[root@localhost ~]#

为什么进入/misc/linux后root可以写入?
发表于 2006-7-22 23:00:23 | 显示全部楼层
你可以证明root可以写入吗?如果可以证明,祝贺你,你发现bug了!
不过,在你高兴之前,先看看你的autofs是否真的挂上了!
回复 支持 反对

使用道具 举报

发表于 2006-7-23 08:19:20 | 显示全部楼层
NFS的权限是按照nfs server上的user id和client的user id对应起来。。。
如果你client上使用的用户的id 和server上某用户的id一样。。。那么你的权限就是按照server上这个用户的权限来计算的。。。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-7-23 10:46:27 | 显示全部楼层
现在我把相关的配置文件和实验结果都贴出来
在同一台计算机172.16.95.101做实验:

服务器172.16.95.101
[root@localhost ~]# cat /etc/exports
#
/shared         172.16.95.0/255.255.255.0(ro,sync)
/var/ftp/RHEL4  *(ro,sync)
[root@localhost ~]#

[root@localhost ~]# mount -t nfs 172.16.95.101:/var/ftp/RHEL4 /mnt/nfstest
[root@localhost ~]# cd /mnt/nfstest/
[root@localhost nfstest]# touch a
touch: cannot touch `a': Permission denied
[root@localhost nfstest]#

[root@localhost nfstest]# cd
[root@localhost ~]# cat /etc/auto.master
#
# $Id: auto.master,v 1.3 2003/09/29 08:22:35 raven Exp $
#
# Sample auto.master file
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# For details of the format look at autofs(5).
/misc  /etc/auto.misc --timeout=60
#/misc  /etc/auto.misc
#/net   /etc/auto.net

[root@localhost ~]#

[root@localhost ~]# cat /etc/auto.misc
#
# $Id: auto.misc,v 1.2 2003/09/29 08:22:35 raven Exp $
#
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# Details may be found in the autofs(5) manpage

cd              -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom

# the following entries are samples to pique your imagination
#linux          -ro,soft,intr           ftp.example.org:/pub/linux
#boot           -fstype=ext2            :/dev/hda1
#floppy         -fstype=auto            :/dev/fd0
#floppy         -fstype=ext2            :/dev/fd0
#e2floppy       -fstype=ext2            :/dev/fd0
#jaz            -fstype=ext2            :/dev/sdc1
#removable      -fstype=ext2            :/dev/hdd

RHEL4           -ro,soft,intr           172.16.95.101:/vat/ftp/RHEL4
[root@localhost ~]#

[root@localhost ~]# cd /misc/RHEL4
[root@localhost RHEL4]# touch a
[root@localhost RHEL4]# ls a
a
[root@localhost RHEL4]#

也是通过nfs自动挂的root可以写入

下面在两台计算机做实验:

客户机172.16.95.221
[root@localhost ~]# showmount -e 172.16.95.101
Export list for 172.16.95.101:
/var/ftp/RHEL4 *
/shared        172.16.95.0/255.255.255.0
[root@localhost ~]# mount -t nfs 172.16.95.101:/var/ftp/RHEL4 /mnt/nfs
[root@localhost ~]# cd /mnt/nfs/
[root@localhost nfs]# touch a
touch: cannot touch `a': Permission denied
[root@localhost nfs]#

[root@localhost ~]# cat /etc/auto.master
#
# $Id: auto.master,v 1.3 2003/09/29 08:22:35 raven Exp $
#
# Sample auto.master file
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# For details of the format look at autofs(5).
/misc  /etc/auto.misc --timeout=60
#/misc  /etc/auto.misc
#/net   /etc/auto.net

[root@localhost ~]#

[root@localhost nfs]# cd /misc/RHEL4
[root@localhost RHEL4]# ls
RedHat
[root@localhost RHEL4]# touch a
touch: cannot touch `a': Permission denied
[root@localhost RHEL4]#

------------------
两台计算机就没有问题

两台计算机都是RHEL4
回复 支持 反对

使用道具 举报

发表于 2006-7-23 21:58:43 | 显示全部楼层
问题出在你使用同一台机器测试!
autofs在本机上挂接本机的nfs共享目录的时候,使将本地目录直接挂接到本地虚拟目录上!
你mount可以看到
var/ftp/RHEL4 直接挂在/misc/RHEL4 而非走的nfs挂接协议!
你在本机是root ,当然可以做任何事情!
在前面我给过你提示!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-7-24 09:28:10 | 显示全部楼层
我手动指定挂接协议:
[root@localhost ~]# cat /etc/auto.misc
#
# $Id: auto.misc,v 1.2 2003/09/29 08:22:35 raven Exp $
#
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# Details may be found in the autofs(5) manpage

cd              -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom

# the following entries are samples to pique your imagination
#linux          -ro,soft,intr           ftp.example.org:/pub/linux
#boot           -fstype=ext2            :/dev/hda1
#floppy         -fstype=auto            :/dev/fd0
#floppy         -fstype=ext2            :/dev/fd0
#e2floppy       -fstype=ext2            :/dev/fd0
#jaz            -fstype=ext2            :/dev/sdc1
#removable      -fstype=ext2            :/dev/hdd

RHEL4           -fstyp=nfs,ro,soft,intr         172.16.95.101:/var/ftp/RHEL4
[root@localhost ~]#
本机也还可以创建文件
输入mount之后
/var/ftp/RHEL4 on /misc/RHEL4 type none (rw,bind)
发现type none,这是怎么回事?看来是只要是本机就按本地目录来挂。
回复 支持 反对

使用道具 举报

发表于 2006-8-15 19:43:18 | 显示全部楼层

nfs

network file system !!!network   network !!!
回复 支持 反对

使用道具 举报

发表于 2007-4-18 11:26:17 | 显示全部楼层
在导出文件系统上可写有三个条件:
  1)导出文件系统本身有写权限;
  2)exports中导出对像有写权限;  
      /xxxx               10.10.0.0/16(rw,sync)

   3)本身自动挂载时指定rw选项
回复 支持 反对

使用道具 举报

发表于 2007-4-18 11:27:53 | 显示全部楼层
在导出文件系统上可写有三个条件:
  1)导出文件系统本身有写权限;
  2)exports中导出对像有写权限;  
      /xxxx               10.10.0.0/16(rw,sync)

   3)本地自动挂载时指定rw选项
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表