Subject: Re: kern/31850: directory stickyness is not obeyed with tmpfs
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Geoff Wing <gcw@pobox.com>
List: netbsd-bugs
Date: 02/21/2006 03:00:07
The following reply was made to PR kern/31850; it has been noted by GNATS.
From: Geoff Wing <gcw@pobox.com>
To: NetBSD GNATS <gnats-bugs@netbsd.org>
Cc:
Subject: Re: kern/31850: directory stickyness is not obeyed with tmpfs
Date: Tue, 21 Feb 2006 13:54:33 +1100
On Tuesday 2005-10-18 11:10 +1000, Geoff Wing output:
: Stickyness is not honoured on tmpfs mounts. Anyone can delete
: anything on basic common /tmp if mounted as tmpfs.
I don't really know anything about file-systems.
Maybe it should set error = EPERM, avoid the VOP_ACCESS check and fall
through to "goto out" and do the checks in that section.
Regards,
Geoff
--- sys/fs/tmpfs/tmpfs_vnops.c.org 2006-02-17 10:11:03.000000000 +1100
+++ sys/fs/tmpfs/tmpfs_vnops.c 2006-02-21 13:32:20.000000000 +1100
@@ -224,11 +224,15 @@
if ((cnp->cn_flags & ISLASTCN) &&
(cnp->cn_nameiop == DELETE ||
cnp->cn_nameiop == RENAME)) {
+ if (dnode->tn_mode & S_ISTXT &&
+ cnp->cn_cred != 0 &&
+ cnp->cn_cred->cr_uid != dnode->tn_uid &&
+ cnp->cn_cred->cr_uid != tnode->tn_uid)
+ return EPERM;
error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred,
cnp->cn_lwp);
if (error != 0)
goto out;
- /* TODO: Check sticky bit. */
tnode->tn_lookup_dirent = de;
}