From owner-freebsd-ports Sat Sep 9 9:29:43 2000 Delivered-To: freebsd-ports@freebsd.org Received: from radon.gryphonsoft.com (mcut-b-167.resnet.purdue.edu [128.211.209.167]) by hub.freebsd.org (Postfix) with ESMTP id 37A3837B422; Sat, 9 Sep 2000 09:29:41 -0700 (PDT) Received: by radon.gryphonsoft.com (Postfix, from userid 1000) id 561BF18A2; Sat, 9 Sep 2000 11:26:48 -0500 (EST) Date: Sat, 9 Sep 2000 11:26:48 -0500 From: Will Andrews To: Maxim Sobolev Cc: ports@FreeBSD.ORG, asami@FreeBSD.ORG Subject: Re: Handling of symlinks to directory in pkg_delete [patch for review] Message-ID: <20000909112648.L632@radon.gryphonsoft.com> Reply-To: Will Andrews Mail-Followup-To: Will Andrews , Maxim Sobolev , ports@FreeBSD.ORG, asami@FreeBSD.ORG References: <39B351FA.A6CFD24F@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <39B351FA.A6CFD24F@FreeBSD.org>; from sobomax@FreeBSD.ORG on Mon, Sep 04, 2000 at 10:40:42AM +0300 X-Operating-System: FreeBSD 4.1-STABLE i386 Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Mon, Sep 04, 2000 at 10:40:42AM +0300, Maxim Sobolev wrote: > I wonder if anybody noticed that handling of symlinks in pkg_delete is somewhat > broken. Particularly, the problems exist with symlinks to a directories. The > pkg_delete code considers those symlinks as a directories (if the referred > directory exists), however they are not, and thus tries to delete it using > rmdir(2), which obviously doesn't work. The workaround exists to delete > directory symlink points to first and only then remove corresponding symlinks, > however it looks like an ugly hack (see lesstif's PLIST for example). The > attached patch is expected to solve this problem. Also in this message I'm > attaching small fake package, which exposes the bug (it consist of one symlink > and one directory this symlink points to). It's widely known that pkg_delete's behavior around symlinks is quite broken. IMHO, pkg_delete should treat symlinks as files (because, really, that is all they are). Hence, pkg_delete should be able to delete them if they are specified in the PLIST; there shouldn't be a requirement to delete them with a @dirrm directive. So, regardless of whether a symlink is pointing at a directory or a file, it should just be deleted if specified in PLIST. Then, some time after support is added to pkg_delete, perhaps we'll fix the PLISTs that have worked around it (remember, people don't necessarily make world along with ports collection upgrades). > +} > + > +/* Returns TRUE if file is a symbolic link. */ > +Boolean > +issymlink(char *fname) > +{ > + struct stat sb; > + if (lstat(fname, &sb) != FAIL && S_ISLNK(sb.st_mode)) > + return TRUE; > + return FALSE; > } Your implementation looks fine; if it works, it seems commitworthy. However, I am not a style(9) police officer. -- Will Andrews GCS/E/S @d- s+:+ a--- C++ UB++++$ P+ L- E--- W+ N-- !o ?K w--- O- M+ V- PS+ PE++ Y+ PGP+>+++ t++ 5 X+ R+ tv+ b++ DI+++ D+ G++ e>++++ h! r- y? To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message