Allow symlinks to directories instead of pure directories in several

places (/usr/pkg, /var/db/pkg, ...). Closes PR 6009 by Jim Bernard
<jimjbernard@ox.mines.edu>.
This commit is contained in:
hubertf 1998-08-27 23:37:35 +00:00
parent df83142334
commit 90c872591e
5 changed files with 30 additions and 14 deletions

View File

@ -1,11 +1,11 @@
/* $NetBSD: futil.c,v 1.5 1997/10/18 11:05:34 lukem Exp $ */
/* $NetBSD: futil.c,v 1.6 1998/08/27 23:37:35 hubertf Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: futil.c,v 1.7 1997/10/08 07:45:39 charnier Exp";
#else
__RCSID("$NetBSD: futil.c,v 1.5 1997/10/18 11:05:34 lukem Exp $");
__RCSID("$NetBSD: futil.c,v 1.6 1998/08/27 23:37:35 hubertf Exp $");
#endif
#endif
@ -51,7 +51,7 @@ make_hierarchy(char *dir)
if ((cp2 = strchr(cp1, '/')) !=NULL )
*cp2 = '\0';
if (fexists(dir)) {
if (!isdir(dir))
if (!(isdir(dir) || islinktodir(dir)))
return FAIL;
}
else {

View File

@ -1,11 +1,11 @@
/* $NetBSD: perform.c,v 1.17 1998/08/25 01:16:03 hubertf Exp $ */
/* $NetBSD: perform.c,v 1.18 1998/08/27 23:37:35 hubertf Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.44 1997/10/13 15:03:46 jkh Exp";
#else
__RCSID("$NetBSD: perform.c,v 1.17 1998/08/25 01:16:03 hubertf Exp $");
__RCSID("$NetBSD: perform.c,v 1.18 1998/08/27 23:37:35 hubertf Exp $");
#endif
#endif
@ -155,7 +155,7 @@ pkg_do(char *pkg)
printf("Doing in-place extraction for %s\n", pkg_fullname);
p = find_plist(&Plist, PLIST_CWD);
if (p) {
if (!isdir(p->name) && !Fake) {
if (!(isdir(p->name) || islinktodir(p->name)) && !Fake) {
if (Verbose)
printf("Desired prefix of %s does not exist, creating.\n", p->name);
vsystem("mkdir -p %s", p->name);
@ -228,7 +228,7 @@ pkg_do(char *pkg)
/* See if we're already registered */
sprintf(LogDir, "%s/%s", (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR, PkgName);
if (isdir(LogDir) && !Force) {
if ((isdir(LogDir) || islinktodir(LogDir)) && !Force) {
warnx("package `%s' already recorded as installed", PkgName);
code = 1;
goto success; /* close enough for government work */

View File

@ -1,11 +1,11 @@
/* $NetBSD: perform.c,v 1.10 1998/08/27 20:11:31 ross Exp $ */
/* $NetBSD: perform.c,v 1.11 1998/08/27 23:37:36 hubertf Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.23 1997/10/13 15:03:53 jkh Exp";
#else
__RCSID("$NetBSD: perform.c,v 1.10 1998/08/27 20:11:31 ross Exp $");
__RCSID("$NetBSD: perform.c,v 1.11 1998/08/27 23:37:36 hubertf Exp $");
#endif
#endif
@ -367,7 +367,7 @@ pkg_perform(char **pkgs)
struct dirent *dp;
DIR *dirp;
if (!isdir(tmp))
if (!(isdir(tmp) || islinktodir(tmp)))
return 1;
if ((dirp = opendir(tmp)) != (DIR *) NULL) {
while ((dp = readdir(dirp)) != (struct dirent *) NULL) {

View File

@ -1,11 +1,11 @@
/* $NetBSD: file.c,v 1.13 1998/07/09 16:47:26 hubertf Exp $ */
/* $NetBSD: file.c,v 1.14 1998/08/27 23:37:36 hubertf Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: file.c,v 1.29 1997/10/08 07:47:54 charnier Exp";
#else
__RCSID("$NetBSD: file.c,v 1.13 1998/07/09 16:47:26 hubertf Exp $");
__RCSID("$NetBSD: file.c,v 1.14 1998/08/27 23:37:36 hubertf Exp $");
#endif
#endif
@ -63,11 +63,26 @@ isdir(char *fname)
return FALSE;
}
/* Check if something is a link to a directory */
Boolean
islinktodir(char *fname)
{
struct stat sb;
if (lstat(fname, &sb) != FAIL && S_ISLNK(sb.st_mode))
if (stat(fname, &sb) != FAIL && S_ISDIR(sb.st_mode))
return TRUE; /* link to dir! */
else
return FALSE; /* link to non-dir */
else
return FALSE; /* non-link */
}
/* Check to see if file is a dir, and is empty */
Boolean
isemptydir(char *fname)
{
if (isdir(fname)) {
if (isdir(fname) || islinktodir(fname)) {
DIR *dirp;
struct dirent *dp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lib.h,v 1.6 1998/07/06 07:03:56 mrg Exp $ */
/* $NetBSD: lib.h,v 1.7 1998/08/27 23:37:36 hubertf Exp $ */
/* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */
@ -126,6 +126,7 @@ char *strconcat(char *, char *);
/* File */
Boolean fexists(char *);
Boolean isdir(char *);
Boolean islinktodir(char *);
Boolean isemptydir(char *fname);
Boolean isemptyfile(char *fname);
Boolean isfile(char *);