Skip to content

Commit 0d9c37f

Browse files
committed
Add receive:append permission for limited receive
Force receive (zfs receive -F) can rollback or destroy snapshots and file systems that do not exist on the sending side (see zfs-receive man page). This means an user having the receive permission can effectively delete data on receiving side, even if such user does not have explicit rollback or destroy permissions. This patch adds the receive:append permission, which only permits limited, non-forced receive. Behavior for users with full receive permission is not changed in any way. Fixes #16943 Signed-off-by: Gionatan Danti <[email protected]>
1 parent 68473c4 commit 0d9c37f

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

cmd/zfs/zfs_main.c

+1
Original file line numberDiff line numberDiff line change
@@ -5292,6 +5292,7 @@ zfs_do_receive(int argc, char **argv)
52925292
#define ZFS_DELEG_PERM_SHARE "share"
52935293
#define ZFS_DELEG_PERM_SEND "send"
52945294
#define ZFS_DELEG_PERM_RECEIVE "receive"
5295+
#define ZFS_DELEG_PERM_RECEIVE_APPEND "receive:append"
52955296
#define ZFS_DELEG_PERM_ALLOW "allow"
52965297
#define ZFS_DELEG_PERM_USERPROP "userprop"
52975298
#define ZFS_DELEG_PERM_VSCAN "vscan" /* ??? */

include/sys/dsl_deleg.h

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ extern "C" {
4646
#define ZFS_DELEG_PERM_SHARE "share"
4747
#define ZFS_DELEG_PERM_SEND "send"
4848
#define ZFS_DELEG_PERM_RECEIVE "receive"
49+
#define ZFS_DELEG_PERM_RECEIVE_APPEND "receive:append"
4950
#define ZFS_DELEG_PERM_ALLOW "allow"
5051
#define ZFS_DELEG_PERM_USERPROP "userprop"
5152
#define ZFS_DELEG_PERM_VSCAN "vscan"

man/man8/zfs-allow.8

+2-1
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,15 @@ load-key subcommand Allows loading and unloading of encryption key (see \fBzfs l
207207
change-key subcommand Allows changing an encryption key via \fBzfs change-key\fR.
208208
mount subcommand Allows mounting/umounting ZFS datasets
209209
promote subcommand Must also have the \fBmount\fR and \fBpromote\fR ability in the origin file system
210-
receive subcommand Must also have the \fBmount\fR and \fBcreate\fR ability
210+
receive subcommand Must also have the \fBmount\fR and \fBcreate\fR ability, required for \fBzfs receive -F\fR (see also \fBreceive:append\fR for limited, non forced receive)
211211
release subcommand Allows releasing a user hold which might destroy the snapshot
212212
rename subcommand Must also have the \fBmount\fR and \fBcreate\fR ability in the new parent
213213
rollback subcommand Must also have the \fBmount\fR ability
214214
send subcommand
215215
share subcommand Allows sharing file systems over NFS or SMB protocols
216216
snapshot subcommand Must also have the \fBmount\fR ability
217217

218+
receive:append other Must also have the \fBmount\fR and \fBcreate\fR ability, limited receive ability (can not do receive -F)
218219
groupquota other Allows accessing any \fBgroupquota@\fI\fR property
219220
groupobjquota other Allows accessing any \fBgroupobjquota@\fI\fR property
220221
groupused other Allows reading any \fBgroupused@\fI\fR property

module/zcommon/zfs_deleg.c

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const zfs_deleg_perm_tab_t zfs_deleg_perm_tab[] = {
5252
{ZFS_DELEG_PERM_MOUNT},
5353
{ZFS_DELEG_PERM_PROMOTE},
5454
{ZFS_DELEG_PERM_RECEIVE},
55+
{ZFS_DELEG_PERM_RECEIVE_APPEND},
5556
{ZFS_DELEG_PERM_RENAME},
5657
{ZFS_DELEG_PERM_ROLLBACK},
5758
{ZFS_DELEG_PERM_SNAPSHOT},

module/zfs/zfs_ioctl.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -900,9 +900,18 @@ zfs_secpolicy_recv(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
900900
(void) innvl;
901901
int error;
902902

903+
/*
904+
* zfs receive -F requires full receive permission,
905+
* otherwise receive:append permission is enough
906+
*/
903907
if ((error = zfs_secpolicy_write_perms(zc->zc_name,
904-
ZFS_DELEG_PERM_RECEIVE, cr)) != 0)
905-
return (error);
908+
ZFS_DELEG_PERM_RECEIVE, cr)) != 0) {
909+
if (zc->zc_guid)
910+
return (error);
911+
if ((error = zfs_secpolicy_write_perms(zc->zc_name,
912+
ZFS_DELEG_PERM_RECEIVE_APPEND, cr)) != 0)
913+
return (error);
914+
}
906915

907916
if ((error = zfs_secpolicy_write_perms(zc->zc_name,
908917
ZFS_DELEG_PERM_MOUNT, cr)) != 0)

0 commit comments

Comments
 (0)