Skip to content

Commit a0350f6

Browse files
msladektonyhutter
authored andcommitted
Fix send:raw permission for send -w -I
When performing an incremental raw send with intermediates (-w -I), the standard 'send' permission was incorrectly required instead of allowing 'send:raw'. This was due to a strict boolean comparison on the 'rawok' flag in zfs_secpolicy_send() with non-boolean value. This change normalizes the 'rawok' variable to be strictly 0/1 and updates the test suite to properly verify delegated raw send behavior. Introduced-by: openzfs#17543 Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Marc Sladek <marc@sladek.dev> Closes openzfs#18198 Closes openzfs#18193
1 parent 936a98c commit a0350f6

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

module/zfs/zfs_ioctl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ zfs_secpolicy_send(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
685685
dsl_dataset_t *ds;
686686
const char *cp;
687687
int error;
688-
boolean_t rawok = (zc->zc_flags & 0x8);
688+
boolean_t rawok = !!(zc->zc_flags & 0x8);
689689

690690
/*
691691
* Generate the current snapshot name from the given objsetid, then
@@ -708,7 +708,7 @@ zfs_secpolicy_send(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
708708

709709
error = zfs_secpolicy_write_perms_ds(zc->zc_name, ds,
710710
ZFS_DELEG_PERM_SEND, cr);
711-
if (error != 0 && rawok == B_TRUE) {
711+
if (error != 0 && rawok) {
712712
error = zfs_secpolicy_write_perms_ds(zc->zc_name, ds,
713713
ZFS_DELEG_PERM_SEND_RAW, cr);
714714
}
@@ -727,7 +727,7 @@ zfs_secpolicy_send_new(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
727727
(void) innvl;
728728
error = zfs_secpolicy_write_perms(zc->zc_name,
729729
ZFS_DELEG_PERM_SEND, cr);
730-
if (error != 0 && rawok == B_TRUE) {
730+
if (error != 0 && rawok) {
731731
error = zfs_secpolicy_write_perms(zc->zc_name,
732732
ZFS_DELEG_PERM_SEND_RAW, cr);
733733
}

tests/zfs-tests/tests/functional/cli_user/zfs_send_delegation_user/zfs_send_usertest.ksh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,18 @@ log_must zfs unallow -u $OTHER1 send $TESTPOOL/$TESTFS1
103103

104104
# test new sendraw abilities (send should fail, sendraw should pass)
105105
log_mustnot user_run $OTHER1 sh -c "'zfs send $TESTPOOL/$TESTFS1@snap1 | zfs receive -u $TESTPOOL/$TESTFS2/zfsrecv2_user_datastream.$$'"
106-
verify nothing went through
106+
# verify nothing went through
107107
if [ -s $TESTPOOL/$TESTFS2/zfsrecv2_user_datastream.$$ ]
108108
then
109109
log_fail "A zfs recieve was completed in $TESTPOOL/$TESTFS2/zfsrecv2_user_datastream !"
110110
fi
111111
log_must user_run $OTHER1 sh -c "'zfs send -w $TESTPOOL/$TESTFS1@snap1 | zfs receive -u $TESTPOOL/$TESTFS2/zfsrecv2raw_user_datastream.$$'"
112112

113+
# test incremental send with intermediates (should pass)
114+
log_must zfs allow $OTHER1 hold $TESTPOOL/$TESTFS1
115+
log_must zfs snapshot $TESTPOOL/$TESTFS1@snap2
116+
log_must user_run $OTHER1 sh -c "'zfs send -w -I $TESTPOOL/$TESTFS1@snap1 $TESTPOOL/$TESTFS1@snap2 > /dev/null'"
117+
113118
# disable raw delegation
114119
log_must zfs unallow -u $OTHER1 send:raw $TESTPOOL/$TESTFS1
115120
log_must zfs allow $OTHER1 send $TESTPOOL/$TESTFS1
@@ -123,13 +128,13 @@ log_must zfs unallow -u $OTHER1 send $TESTPOOL/$TESTFS1
123128

124129
# verify original send abilities (should fail)
125130
log_mustnot user_run $OTHER1 sh -c "'zfs send $TESTPOOL/$TESTFS1@snap1 | zfs receive -u $TESTPOOL/$TESTFS2/zfsrecv4_user_datastream.$$'"
126-
verify nothing went through
131+
# verify nothing went through
127132
if [ -s $TESTPOOL/$TESTFS2/zfsrecv4_user_datastream.$$ ]
128133
then
129134
log_fail "A zfs recieve was completed in $TESTPOOL/$TESTFS2/zfsrecv4_user_datastream !"
130135
fi
131136
log_mustnot user_run $OTHER1 sh -c "'zfs send -w $TESTPOOL/$TESTFS1@snap1 | zfs receive -u $TESTPOOL/$TESTFS2/zfsrecv4raw_user_datastream.$$'"
132-
verify nothing went through
137+
# verify nothing went through
133138
if [ -s $TESTPOOL/$TESTFS2/zfsrecv4raw_user_datastream.$$ ]
134139
then
135140
log_fail "A zfs recieve was completed in $TESTPOOL/$TESTFS2/zfsrecv4raw_user_datastream !"

0 commit comments

Comments
 (0)