挂载共享 cifs 时总是权限 777
Always permission 777 on mount shared cifs
我从 Synology NAS 挂载 SMB 共享文件夹时遇到一点问题。
我想挂载具有以下权限的共享文件夹:git:root 700
但是挂载文件夹的权限总是设置为 777(即使在 chmod 700 之后没有错误)
在我的 /etc/fstab
中,我使用了这一行:
#uid=999 ---> git user
//server/folder /mnt/artifacts cifs username=windowsUser,password=xxxxx,gid=0,uid=999,file_mode=0700,dir_mode=0700,iocharset=utf8 0 0
你知道为什么我不能设置权限为700吗?
我做错了吗?有什么蠢事?
在此先感谢您的帮助 ;)
一个好的开始是查看 CIFS
:
的联机帮助页
$ man mount.cifs
[...]
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.
[...]
nounix
Disable the CIFS Unix Extensions for this mount.
[...]
因此,由于 file_mode
(和 dir_mode
)似乎仅在服务器 不 支持 CIFS Unix 扩展的情况下才有效,我将首先禁用它们(通过 nounix
选项)
你的问题很常见。您正在使用不正确的标签来更改已安装文件夹的文件权限。
您需要添加 'umask=',而不是 'file_mode=700' 和 'dir_mode=700' 因为它使用的是系统安装选项而不是 CIFS 的选项。
为此,您可以使用:
//address/location /mount/location cifs credentials=/location,uid=id,gid=id,umask=700 0 0
这将在设置的文件权限下装载文件共享。
为了安全起见,我建议使用凭证文件,其中包含用户名和密码,并且必须设置为只读。
如果远程机器用户 ID 和本地机器用户 ID 不匹配,权限将默认为 777。Mount.cifs 不支持 umask,因此可以使用 "noperm" 选项.这样即使本地和远程机器上的用户权限不匹配,用户仍然可以读取和写入文件夹,相当于 umask=000。
//address/location /mount/location cifs username=username,password=password,noperm,vers=2.0 0 0
我尝试挂载一个只有 root 权限的 CIFS 共享。其他用户应该甚至不能列出任何文件。
因此我使用了以下 fstab 条目:
//192.168.0.100/DRV /mnt/DRV cifs user=user,pass=pass,uid=0,gid=0,nounix,file_mode=0007,dir_mode=0007 0 0
我也尝试了 noperm 参数。
详细来说,我创建了具有以下权限的文件夹:
drwxrwx--- 2 root root 4096 Mai 14 09:09 DRV
挂载网络共享后,文件夹有:
d------rwx 2 root root 4096 Mai 14 04:50 W
添加 nounix
效果很好。有关信息,我在 /etc/fstab
中的行是:
//server/share /mnt/folder cifs credentials=/home/yannick/.smbcredentials,iocharset=utf8,sec=ntlm,vers=1.0,uid=1000,gid=1000,file_mode=0644,dir_mode=0755,nounix 0 0
其中 1000
是我的用户 ID 和组 ID。
在 .smbcredentials
里面,我有这个 :
username=<distant login>
password=<distant password>
我从 Synology NAS 挂载 SMB 共享文件夹时遇到一点问题。
我想挂载具有以下权限的共享文件夹:git:root 700
但是挂载文件夹的权限总是设置为 777(即使在 chmod 700 之后没有错误)
在我的 /etc/fstab
中,我使用了这一行:
#uid=999 ---> git user
//server/folder /mnt/artifacts cifs username=windowsUser,password=xxxxx,gid=0,uid=999,file_mode=0700,dir_mode=0700,iocharset=utf8 0 0
你知道为什么我不能设置权限为700吗? 我做错了吗?有什么蠢事?
在此先感谢您的帮助 ;)
一个好的开始是查看 CIFS
:
$ man mount.cifs
[...]
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.
[...]
nounix
Disable the CIFS Unix Extensions for this mount.
[...]
因此,由于 file_mode
(和 dir_mode
)似乎仅在服务器 不 支持 CIFS Unix 扩展的情况下才有效,我将首先禁用它们(通过 nounix
选项)
你的问题很常见。您正在使用不正确的标签来更改已安装文件夹的文件权限。
您需要添加 'umask=',而不是 'file_mode=700' 和 'dir_mode=700' 因为它使用的是系统安装选项而不是 CIFS 的选项。
为此,您可以使用:
//address/location /mount/location cifs credentials=/location,uid=id,gid=id,umask=700 0 0
这将在设置的文件权限下装载文件共享。
为了安全起见,我建议使用凭证文件,其中包含用户名和密码,并且必须设置为只读。
如果远程机器用户 ID 和本地机器用户 ID 不匹配,权限将默认为 777。Mount.cifs 不支持 umask,因此可以使用 "noperm" 选项.这样即使本地和远程机器上的用户权限不匹配,用户仍然可以读取和写入文件夹,相当于 umask=000。
//address/location /mount/location cifs username=username,password=password,noperm,vers=2.0 0 0
我尝试挂载一个只有 root 权限的 CIFS 共享。其他用户应该甚至不能列出任何文件。
因此我使用了以下 fstab 条目:
//192.168.0.100/DRV /mnt/DRV cifs user=user,pass=pass,uid=0,gid=0,nounix,file_mode=0007,dir_mode=0007 0 0
我也尝试了 noperm 参数。
详细来说,我创建了具有以下权限的文件夹:
drwxrwx--- 2 root root 4096 Mai 14 09:09 DRV
挂载网络共享后,文件夹有:
d------rwx 2 root root 4096 Mai 14 04:50 W
添加 nounix
效果很好。有关信息,我在 /etc/fstab
中的行是:
//server/share /mnt/folder cifs credentials=/home/yannick/.smbcredentials,iocharset=utf8,sec=ntlm,vers=1.0,uid=1000,gid=1000,file_mode=0644,dir_mode=0755,nounix 0 0
其中 1000
是我的用户 ID 和组 ID。
在 .smbcredentials
里面,我有这个 :
username=<distant login>
password=<distant password>