
我有一台 FreeNAS (11.1-U1) 和一台 FreeBSD (11.1-RELEASE-p6) 機器。在 FreeNAS 上,我想以zfs receive
具有委派權限的非 root 使用者身分遞歸快照。這似乎對於大多數子資料集都很有效。但是 iocage 的data
資料集可以安裝到監獄中並從那裡進行管理,但它們失敗了:
root@freebsd:~> zfs send -RI "dozer@2018-02-21" "dozer@2018-03-08" | ssh -T -i /root/backup_key backupuser@freenas zfs receive -dvuF neo/backups/freebsd
receiving incremental stream of dozer@2018-03-03 into neo/backups/freebsd@2018-03-03
received 312B stream in 1 seconds (312B/sec)
receiving incremental stream of dozer@2018-03-07 into neo/backups/freebsd@2018-03-07
received 312B stream in 1 seconds (312B/sec)
receiving incremental stream of dozer@2018-03-08 into neo/backups/freebsd@2018-03-08
received 312B stream in 1 seconds (312B/sec)
receiving incremental stream of dozer/ROOT@2018-03-03 into neo/backups/freebsd/ROOT@2018-03-03
.
.
.
receiving incremental stream of dozer/iocage/jails/owncloud/root@2018-03-08 into neo/backups/freebsd/iocage/jails/owncloud/root@2018-03-08
received 578MB stream in 110 seconds (5.25MB/sec)
receiving incremental stream of dozer/iocage/jails/owncloud/root/data@2018-03-03 into neo/backups/freebsd/iocage/jails/owncloud/root/data@2018-03-03
cannot receive incremental stream: permission denied
warning: cannot send 'dozer/iocage/jails/owncloud/root/data@2018-03-03': signal received
warning: cannot send 'dozer/iocage/jails/owncloud/root/data@2018-03-07': Broken pipe
warning: cannot send 'dozer/iocage/jails/owncloud/root/data@2018-03-08': Broken pipe
該特定子資料集的權限與父資料集的權限完全相同:
root@freenas:~ # zfs allow neo/backups/freebsd/iocage/jails/owncloud/root/data
---- Permissions on neo/backups/freebsd -----------------------------
Local+Descendent permissions:
user backupuser atime,compression,create,dedup,exec,jailed,mount,mountpoint,quota,receive,rename,reservation,setuid,userprop
zfs receive
以 root 身分在 FreeNAS 上運行可以按預期工作。
我的使用者需要什麼委派權限才能接收 iocage 的被監禁資料集,更一般地說,是否有一種方法可以發出zfs receive
更詳細的錯誤訊息,告訴您缺少哪些權限?
答案1
zfs
在排查指令所引起的權限問題時,請zfs
依照操作的組成步驟進行分析。
解包範例命令zfs receive -duvF
分為幾個步驟。其中兩個標誌與任何特殊權限無關:
-d 影響新資料集的命名(如果有)
-v 啟用詳細輸出
另外兩個也這樣做。
-F 表示接收開始前檔案系統將回滾到增量傳輸的初始快照
-u 表示接收完成後不會掛載檔案系統
我的預感是您缺少回滾權限。命令中的 -F 標誌意味著zfs rollback
將執行 a ,並且您的zfs allow
不列出rollback
.
在一般情況下,人們可以對給定命令所需的權限進行演繹猜測zfs
。
手冊頁指出zfs
:
權限名稱與 ZFS 子命令和屬性名稱相同。
和 ...
權限通常是使用 ZFS 子命令或更改 ZFS 屬性的能力。可以使用以下權限:
NAME TYPE NOTES allow subcommand Must also have the permission that is being allowed clone subcommand Must also have the 'create' ability and 'mount' ability in the origin file system create subcommand Must also have the 'mount' ability destroy subcommand Must also have the 'mount' ability diff subcommand Allows lookup of paths within a dataset given an object number, and the ability to create snapshots necessary to 'zfs diff' hold subcommand Allows adding a user hold to a snapshot mount subcommand Allows mount/umount of ZFS datasets promote subcommand Must also have the 'mount' and 'promote' ability in the origin file system receive subcommand Must also have the 'mount' and 'create' ability release subcommand Allows releasing a user hold which might destroy the snapshot rename subcommand Must also have the 'mount' and 'create' ability in the new parent rollback subcommand Must also have the 'mount' ability send subcommand share subcommand Allows sharing file systems over the NFS protocol snapshot subcommand Must also have the 'mount' ability groupquota other Allows accessing any groupquota@... property groupused other Allows reading any groupused@... property userprop other Allows changing any user property userquota other Allows accessing any userquota@... property userused other Allows reading any userused@... property aclinherit property aclmode property atime property canmount property casesensitivity property checksum property compression property copies property dedup property devices property exec property filesystem_limit property logbias property jailed property mlslabel property mountpoint property nbmand property normalization property primarycache property quota property readonly property recordsize property refquota property refreservation property reservation property secondarycache property setuid property sharenfs property sharesmb property snapdir property snapshot_limit property sync property utf8only property version property volblocksize property volsize property vscan property xattr property
手邊的範例包含該-u
標誌,因此在接收作業結束時不會安裝檔案系統。但是,如果-u
不存在,檔案系統將在接收過程結束時安裝。顯然,receive
許可需要mount
許可。
由於zfs mount
操作將自動建立任何必要的掛載點,因此使用者可能具有zfs
掛載資料集的權限,但沒有建立掛載點的檔案系統權限。在 的情況下zfs mount
,掛載將會失敗。在zfs create
orrename
操作中,將建立或重新命名檔案系統,但如果使用者沒有足夠的檔案系統權限來建立掛載點,則檔案系統將保持卸載狀態。
同樣,zfs rename
命令可能會因重命名操作中的多個點缺乏權限而失敗。寬鬆地表達,組成步驟可能是:
1) 卸載檔案系統(mount
權限)
2) 建立新檔案系統(create
權限)
3) 將檔案系統元資料對應到新名稱(rename
權限)
第四步是在新的、可能已變更的安裝點處重新安裝新命名的檔案系統,這將再次使用權限mount
以及可能的檔案系統權限來建立新的安裝點。
我沒有測試過這樣的技巧,但是可以看出,zfs
區分create
和rename
權限,也區分mount
和mountpoint
權限。人們想像可能允許用戶創建新的檔案系統,但一旦創建,用戶就無法重新命名它們。對於具有繼承掛載點的檔案系統,重新命名檔案系統通常也會重新命名檔案系統的掛載點,就像重新命名tank/usr/local
為將tank/usr/local.OLD
掛載點從 更改/usr/local
為時一樣/usr/local.OLD
。
mount
權限rename
的分離mountpoint
意味著可以允許使用者重新命名檔案系統,但不允許更改其安裝點。反之亦然,能夠變更檔案系統的安裝位置,但無法變更檔案系統的名稱。
其檔案系統操作和這些操作的委派的豐富性,再加上權限的粒度,可能會帶來zfs
一些挑戰,但也非常強大。
答案2
這看起來像是您有一個缺少權限的快照。
嘗試設定receive
權限neo/backups/freebsd/iocage/jails/owncloud/root/data@2018-03-03
。
看起來它在卷上設置正確,但在快照上丟失。