
雖然我可以連接到 Samba 共享並讀取所有共享文件,但我無法在 Mac 上修改/刪除該共享中的文件。
我在這裡發現了一個非常相似的問題:Samba 檔案權限:Linux 伺服器、Mac 用戶端。我嘗試從接受的答案中找到解決方案,即將參數添加到smb.conf
,但不幸的是,它對我不起作用。
我的smb.conf
:
[global]
nt acl support = yes
acl map full control = no
security = user
passdb backend = tdbsam
unix charset = utf-8
dos charset = cp932
[private-share]
path = /home/pi/music
valid users = @smbgrp
我已將伺服器資料夾的存取權限授予sambauser
和smbgrp
:
sudo chmod -R 0770 /home/pi/music
sudo chown -R sambauser:smbgrp music/
驗證這一點:
$ ls -l /home/pi/
total 4
drwxrwx--- 6 sambauser smbgrp 4096 Feb 2 10:19 music
當我切換到 時sambauser
,我可以隨意刪除檔案。儘管當我切換到 Mac 並使用cmd+K
Finder 中的功能sambauser
時,我可以連接到 Samba 共享並讀取所有共享文件,但我無法在 Mac 上的該共享中創建/修改/刪除文件。
我也可以從命令列掛載它,但掛載後,資料夾權限似乎改變了:
$ mkdir -p /tmp/samba-share
$ cd /tmp
$ ls -l
drwxr-xr-x 2 hans wheel 64 2 Feb 14:47 samba-share
$ sudo mount_smbfs //sambauser:password@k3smaster/private-share /tmp/samba-share
$ ls -l
ls: samba-share: Permission denied
$ sudo ls -l
drwx------ 1 root wheel 16384 2 Feb 11:19 samba-share
當我嘗試刪除檔案時,權限被拒絕:
$ sudo ls -l samba-share/non-pro/Dan
total 63488
-rwx------ 1 root wheel 5948277 1 Feb 17:05 01-Track-01.mp3
$ sudo rm samba-share/non-pro/Dan/01-Track-01.mp3
override rwx------ root/wheel arch for samba-share/non-pro/Dan/01-Track-01.mp3? y
rm: samba-share/non-pro/Dan/01-Track-01.mp3: Permission denied
建立文件也是如此:
$ sudo touch samba-share/non-pro/Dan/foo.bar
touch: samba-share/non-pro/Dan/foo.bar: Permission denied
Windows用戶端測試:
$ net use z: \\k3smaster\private-share
Windows prompts for username and password
之後,資料夾和文件即可訪問,但只讀。與 Mac 上相同。
答案1
添加參數read only = no
和writable = yes
似乎可以解決問題。
整體smb.conf
[global]
security = user
passdb backend = tdbsam
unix charset = utf-8
dos charset = cp932
map to guest = Bad Password
[private-share]
path = /home/pi/music
valid users = @smbgrp
read only = no
writable = yes
在Mac客戶端上,掛載的共享的權限不再root
屬於群組wheel
。相反,所有者現在是logged in Mac user
and group staff
:
$ ls -l /Volumes/samba-share
drwx------ 1 hans staff 16384 1 Feb 18:05 non-pro
我能夠創建資料夾和文件以及刪除和重命名資料夾和文件。所以最終它按預期工作了。