配置 CIFS 挂载点权限

Fae*_*ter 4 fstab cifs file-permissions ubuntu

在我的 Ubuntu 机器上,我CIFS通过在我的/etc/fstab

//netgear0/photos /media/netgear0-photos  cifs  credentials=/home/bob/passwd/netgear0-smb-cred,iocharset=utf8,uid=1000,gid=1000,rw  0  0
Run Code Online (Sandbox Code Playgroud)

这将正确安装共享并显示如下:

drwxr-xr-x  1 bob  bob    0 2011-10-10 07:25 netgear0-photos
Run Code Online (Sandbox Code Playgroud)

但是,我想将挂载点目录的权限更改为700只能bob看到挂载点中的文件。我曾尝试在挂载之前设置目录的权限,但这在挂载期间会被替换。我可以找到更改挂载点内部权限的选项,但不能更改挂载点本身。

小智 6

如果您的 Samba 服务器允许 CIFS Unix 扩展,您可能需要添加nounix到米克的回答中:,dir_mode=0700,file_mode=0700,nounix

这是因为对于 CIFS Unix 扩展,客户端无法覆盖该模式。虽然不是很清楚,但是mount.cifs 手册页上有一个参考说:

   If the uid's and gid's being used do not match on the client and
   server, the forceuid and forcegid options may be helpful. Note however,
   that there is no corresponding option to override the mode. Permissions
   assigned to a file when forceuid or forcegid are in effect may not
   reflect the the real permissions.
Run Code Online (Sandbox Code Playgroud)