Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 20 Feb 2010 02:23:28 +0300
From:      "Alexander Zagrebin" <alexz@visp.ru>
To:        <freebsd-fs@freebsd.org>
Cc:        freebsd-current@freebsd.org
Subject:   ZFS allows deletion of files in a sticky directory
Message-ID:  <3A28259E0677447BBFDECFCCDBD97FD5@vosz.local>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.

------=_NextPart_000_0D69_01CAB1D3.B0549730
Content-Type: text/plain;
	charset="koi8-r"
Content-Transfer-Encoding: 7bit

I have found that directory entry may be deleted from a ZFS directory
with the sticky bit, if "the entry is a plain file and you have write
access"
(this is citation from a comments in zfs_dir.c)
But this behavior isn't described in the sticky(8) and isn't allowed on a
UFS.
The attached patch provides the UFS-like behavior of a sticky directories on
a ZFS.
Is this bug or feature?

-- 
Alexander Zagrebin

------=_NextPart_000_0D69_01CAB1D3.B0549730
Content-Type: application/octet-stream;
	name="patch-zfs_dir.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="patch-zfs_dir.c"

--- =
/usr/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c.orig	=
2009-07-20 23:16:42.000000000 +0400=0A=
+++ /usr/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c	=
2010-02-20 01:23:45.112613715 +0300=0A=
@@ -962,7 +962,6 @@=0A=
  *=0A=
  *	you own the directory,=0A=
  *	you own the entry,=0A=
- *	the entry is a plain file and you have write access,=0A=
  *	or you are privileged (checked in secpolicy...).=0A=
  *=0A=
  * The function returns 0 if remove access is granted.=0A=
@@ -984,9 +983,7 @@=0A=
 	downer =3D zfs_fuid_map_id(zfsvfs, zdp->z_phys->zp_uid, cr, ZFS_OWNER);=0A=
 	fowner =3D zfs_fuid_map_id(zfsvfs, zp->z_phys->zp_uid, cr, ZFS_OWNER);=0A=
 =0A=
-	if ((uid =3D crgetuid(cr)) =3D=3D downer || uid =3D=3D fowner ||=0A=
-	    (ZTOV(zp)->v_type =3D=3D VREG &&=0A=
-	    zfs_zaccess(zp, ACE_WRITE_DATA, 0, B_FALSE, cr) =3D=3D 0))=0A=
+	if ((uid =3D crgetuid(cr)) =3D=3D downer || uid =3D=3D fowner)=0A=
 		return (0);=0A=
 	else=0A=
 		return (secpolicy_vnode_remove(ZTOV(zp), cr));=0A=

------=_NextPart_000_0D69_01CAB1D3.B0549730--




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A28259E0677447BBFDECFCCDBD97FD5>