From owner-freebsd-hackers Mon Sep 18 14:07:59 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id OAA02643 for hackers-outgoing; Mon, 18 Sep 1995 14:07:59 -0700 Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.211]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id OAA02634 for ; Mon, 18 Sep 1995 14:07:50 -0700 Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id OAA08619; Mon, 18 Sep 1995 14:05:08 -0700 From: Terry Lambert Message-Id: <199509182105.OAA08619@phaeton.artisoft.com> Subject: Re: suspect code in 'unlink' syscall. To: julian@ref.tfs.com (Julian Elischer) Date: Mon, 18 Sep 1995 14:05:08 -0700 (MST) Cc: hackers@FreeBSD.ORG In-Reply-To: <199509180750.AAA01170@ref.tfs.com> from "Julian Elischer" at Sep 18, 95 00:50:32 am X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Length: 1118 Sender: owner-hackers@FreeBSD.ORG Precedence: bulk > looking at 'unlink (2)' > I see, > if (vp->v_type != VDIR || > (error = suser(p->p_ucred, &p->p_acflag)) == 0) { > /* > * The root of a mounted filesystem cannot be deleted. > */ > if (vp->v_flag & VROOT) > error = EBUSY; > else > (void) vnode_pager_uncache(vp); > } > > I translate this as: > "if it's not a DIR, or we are root", > check if we are deleteing the > root of an FS, > if not, flush cache...... > > now, if we were NOT root, and it IS a dir...... (normal...) > > can we delete it? > I'm about to try this.. > if you dont hear from me, the building exploded... Invert the test. I made this mod some time ago: if( ( error = suser(p->p_ucred, &p->p_acflag)) == 0 || vp->v_type != VDIR) { This way, the error code will be set to EPERM if you are not root and the followon code will not be executed. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.