From owner-freebsd-bugs Fri Apr 26 11: 0:17 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 760E037B421 for ; Fri, 26 Apr 2002 11:00:03 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g3QI03173162; Fri, 26 Apr 2002 11:00:03 -0700 (PDT) (envelope-from gnats) Date: Fri, 26 Apr 2002 11:00:03 -0700 (PDT) Message-Id: <200204261800.g3QI03173162@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Peter Sanchez Subject: Re: bin/37250: [PATCH] ftpd(8) cannot delete stale symlinks Reply-To: Peter Sanchez Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR bin/37250; it has been noted by GNATS. From: Peter Sanchez To: Nino Dehne , freebsd-gnats-submit@FreeBSD.org Cc: Subject: Re: bin/37250: [PATCH] ftpd(8) cannot delete stale symlinks Date: Fri, 26 Apr 2002 11:57:59 -0700 This patch appears to work... -- START --- libexec/ftpd/ftpd.c Fri Apr 26 11:39:59 2002 +++ libexec/ftpd/ftpd.c.new Fri Apr 26 11:40:34 2002 @@ -2170,8 +2170,10 @@ LOGCMD("delete", name); if (stat(name, &st) < 0) { - perror_reply(550, name); - return; + if (lstat(name, &st) < 0) { + perror_reply(550, name); + return; + } } if ((st.st_mode&S_IFMT) == S_IFDIR) { if (rmdir(name) < 0) { -- END cd /usr/src && patch < ftpd.patch cd libexec/ftpd && make all install clean Peter On Fri, Apr 19, 2002 at 06:15:25AM -0700, Nino Dehne wrote: > > >Number: 37250 > >Category: bin > >Synopsis: [PATCH] ftpd(8) cannot delete stale symlinks > >Confidential: no > >Severity: non-critical > >Priority: low > >Responsible: freebsd-bugs > >State: open > >Quarter: > >Keywords: > >Date-Required: > >Class: sw-bug > >Submitter-Id: current-users > >Arrival-Date: Fri Apr 19 06:20:01 PDT 2002 > >Closed-Date: > >Last-Modified: > >Originator: Nino Dehne > >Release: FreeBSD 4.5-RELEASE-p2 i386 > >Organization: > Clan-Planet GmbH > >Environment: > FreeBSD [...] 4.5-RELEASE-p2 FreeBSD 4.5-RELEASE-p2 #1: Tue Mar 19 18:17:09 CET 2002 root@[...] i386 > >Description: > When trying to delete a file via ftp(1) (or any other client, it doesn't matter), ftpd(8) does a stat(2) on the file to verify it's there. However, if the file to delete is a symlink the target of the link gets checked, not the link itself thus making stale links impossible to delete via ftp. > > This occured when local users had symlinks in their home which point to /usr/local/something but are rendered stale when users log in via ftp (due to using chroot() feature of ftpd(8)). > >How-To-Repeat: > Create a symlink inside a user's home which points outside of the user's home. Log in as that user via ftp while chroot()'ing him using /etc/ftpchroot. Try to delete said link. > > This should also work with "ordinary" stale symlinks, i.e. not involving any chroot'ing behaviour of ftpd(8). > >Fix: > > >Release-Note: > >Audit-Trail: > >Unformatted: > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-bugs" in the body of the message -- Peter Sanchez, aka fut0n | "The ability to read is what - fut0n@linuxforlesbians.org | distinguishes Unix users from - www.linuxforlesbians.org | those of more popular platforms." - FreeBSD or DIE | - John Lasser To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message