我在 Ubuntu 20.04 上安装了 Samba,并具有以下内容/etc/samba/smb.conf
:
Load smb config files from /etc/samba/smb.conf
Loaded services file OK.
Server role: ROLE_STANDALONE
# Global parameters
[global]
log file = /var/log/samba/log.%m
logging = file
map to guest = Bad User
max log size = 1000
obey pam restrictions = Yes
pam password change = Yes
panic action = /usr/share/samba/panic-action %d
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
passwd program = /usr/bin/passwd %u
server role = standalone server
server string = %h server (Samba, Ubuntu)
unix password sync = Yes
usershare allow guests = Yes
workgroup = MYDOMAIN
idmap config * : backend = tdb
[printers]
browseable = No
comment = All Printers
create mask = 0700
path = /var/spool/samba
printable = Yes
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
[myuser]
comment = My drive
create mask = 0664
directory mask = 0777
path = /data/myuser
read only = No
每当我从 Windows 10 创建目录时,权限都是:
drwxr-xr-x 2 myuser mydomain 4096 Aug 11 11:07 test2
我尝试编辑smb.conf
以删除create mask
和directory mask
行。然后我重新启动了 Samba,但权限仍然相同:
drwxr-xr-x 2 myuser mydomain 4096 Aug 11 11:16 test3
我需要至少以下权限drwxrwxr-x
我浏览了多个网站,它们给出了不同的建议:
create mask = 0666
、、create mask = 0664
各种目录掩码。似乎我可以使用“create mask”创建更严格的权限,但我想要的是更宽松的权限。
答案1
从纯粹的权限角度来看:
我采用了现有的公共共享并添加了两行来修改已保存文件的最终权限:
[Public]
create mask = 0664
force directory mode = 0775
force user = tester
guest ok = Yes
path = /srv/Public
read only = No
然后我从 Win10 创建了一个文件和一个目录。结果如下:
tester@vubsrv2004:~$ ls -al /srv/Public | grep fromWin10
drwxrwxr-x 2 tester tester 4096 Aug 12 13:15 fromWin10
-rw-rw-r-- 1 tester tester 0 Aug 12 13:18 fromWin10.txt
笔记:
根据 Nmath 的上述评论,这只有当目标文件夹可屏蔽和可模式时才会起作用,这意味着它必须驻留在 Linux 文件系统上。
如果它位于 fat32 或 ntfs 等 Windows 文件系统上,则需要修改包含此共享文件夹的分区的 fstab 挂载中的 umask (或 dmask / fmask)操作符。