
我配置了一個基本的 samba shire,以便在本地網路上透過 SMB 共享媒體文件,無需憑證(即作為 SMB 來賓)
/etc/samba/smb.conf
[media]
Comment = Media directory
Path = /mnt/media
Browseable = yes
Writeable = Yes
create mask = 0666
directory mask = 0777
Public = yes
當我在 Windows 上使用 SMB 建立名為的目錄時example
,目錄結構如下所示
ls -alh
total 28K
drwxrwxrwt 4 root root 4.0K Oct 21 13:44 ./
drwxr-xr-x 3 root root 4.0K Oct 20 13:33 ../
drwxrwxrwx 2 nobody nogroup 4.0K Oct 21 13:44 example/
drwx------ 2 root root 16K Oct 20 13:36 lost+found/
lsattr
--------------e----- ./example
當我嘗試使用標準使用者帳戶從系統中刪除目錄時,收到錯誤訊息。
rmdir:無法刪除「範例」:不允許操作
不過,我可以在 Windows 上使用 SMB 刪除該資料夾。這裡發生了什麼,如何允許任何本地 UNIX 用戶透過 SMB 刪除或修改來賓建立的檔案?
答案1
父目錄權限中的標誌t
聲明只有目錄的擁有者(或根目錄)才能從中刪除檔案或目錄。
Samba 似乎被配置為提供使用者帳戶存取權限nobody
。您不是nobody
,所以您無權刪除該目錄。
我不建議您在頂層建立文件和目錄。保留lost+found
一個資料目錄,並共用該資料目錄而不是掛載點。
# Remove global write permission from the mountpoint
chmod go-w,-t /mnt/media
# Create your files and directories in here
mkdir -m777 /mnt/media/data
現在修復 Samba 資料路徑
[media]
comment = Media directory
path = /mnt/media/data
browseable = yes
read only = no
guest ok = yes
force directory mode = 0777
force create mode = 0666