挂载CIFS共享时,“file_mode,dir_mode”和“gid”有什么区别?

挂载CIFS共享时,“file_mode,dir_mode”和“gid”有什么区别?

我正在尝试使用 /etc/fstab 在 xubuntu 16.04 上安装 Windows 10 共享,我注意到如果我没有将file_mode=0777,dir_mode=0777参数设置为/etc/fstab,则 root 之外的用户将无法写入共享。这对我来说似乎是一种安全风险,因为我看到这777意味着每个人都应该拥有读取和写入共享的权限,而我不想要。所以我删除了这些参数,查看了手册,并改为设置gid=1000为只有该组中的用户才能写入共享。这最终根本不起作用,所以我将file_mode=0777dir_mode=0777参数放回了/etc/fstab,它就像我希望的那样工作了。根据 thunar 的说法,组 1000 中的用户可以读写,而“其他人”则没有任何访问权限。

总结:为什么需要file_mode=0777dir_mode=0777参数才能获得共享的正确权限?如果八进制权限中的 0777 表示每个人都可以访问它,那么为什么参数gid=1000似乎会覆盖它?

答案1

根据 mount.cifs man

       file_mode=arg
       If the server does not support the CIFS Unix extensions this
       overrides the default file mode.

       dir_mode=arg
       If the server does not support the CIFS Unix extensions this
       overrides the default mode for directories.
       
       gid sets the gid that will own all files or directories on the
       mounted filesystem when the server does not provide ownership
       information. It may be specified as either a groupname or a
       numeric gid. When not specified, the default is gid 0.

file_modedir_mode的是文件和目录权限。我不知道您安装 Windows 10 Share 的目录具有什么权限。我的意思是,如果您仅在根目录权限下安装,其他用户将无权访问此目录,这就是为什么它只0777对其他用户有效。

我建议您更改挂载目录的所有者和组所有者,这样您就可以向其他非 root 用户授予权限。

相关内容