Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 Sep 2000 11:26:48 -0500
From:      Will Andrews <will@physics.purdue.edu>
To:        Maxim Sobolev <sobomax@FreeBSD.ORG>
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>
In-Reply-To: <39B351FA.A6CFD24F@FreeBSD.org>; from sobomax@FreeBSD.ORG on Mon, Sep 04, 2000 at 10:40:42AM %2B0300
References:  <39B351FA.A6CFD24F@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <will@physics.purdue.edu> <will@FreeBSD.org>
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




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