最近 MIS 升級 server 後遇到一個神祕現象,我在 Ubuntu 上用 mount.cifs 掛載了一個 NAS 用 samba 分享出來的資料夾。在操作的時候 mkdir 一個目錄 OK,touch 出一個檔案也 ok,但是 mkdir -p a/b/c 會失敗 !?
mkdir -p a/b/c 會成功建出 a,但是當要建出 b 的時後就噴 permission deny。而且這個時候在 a 下面要 mkdir 或是 touch 都會遇到一樣的錯誤,甚至 sudo 了也沒用。
其實看不太出原因,因為
- a 目錄的 uid, gid 跟其他目錄沒有差別,而且權限也是對的。
- a 目錄的 unix permission 也是對的。(但是 other 是沒有 w 的)
- chown, chmod 都不會成功。
檔案的 owner, group 是當初 mount 時所指定的,但在 other permission 沒有 w 我就無法存取和 chown, chmod 都不成功的狀況下,可以推測系統在檢查檔案權限時判斷是該檔案 owner 不是當前使用者而把當前使用者當作 other,造成一個神祕的誤判(?)。
翻了一下 mount.cifs 的 man apge。發現了一個參數好像可以使用。
noperm
Client does not do permission checks. This can expose files on this mount to access by other users on the local client system. It is typically only needed when the server supports the CIFS Unix Extensions but the UIDs/GIDs on the client and server system do not match closely enough to allow access by the user doing the mount. Note that this does not affect the normal ACL check on the target machine done by the server software (of the server ACL against the user name provided at mount time).
上了這個 option 重 mount 就好了!!!!!!!!!
好吧,應該是 server 之前沒有開 CIFS Unix Extensions 吧 ..
Reference