From 2972ec435c0fc06120f7462f3d3faf828b9f386f Mon Sep 17 00:00:00 2001 From: minskim Date: Tue, 1 Jun 2004 16:15:31 +0000 Subject: [PATCH] If symlink integrity check fails, try the target of the symlink. This is needed when linkfarm creates a symlink to a symlink in the depot. OK'ed by silence on tech-pkg@. --- usr.sbin/pkg_install/lib/plist.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/usr.sbin/pkg_install/lib/plist.c b/usr.sbin/pkg_install/lib/plist.c index ee201ce291cb..1c2c2df27acb 100644 --- a/usr.sbin/pkg_install/lib/plist.c +++ b/usr.sbin/pkg_install/lib/plist.c @@ -1,11 +1,11 @@ -/* $NetBSD: plist.c,v 1.43 2004/05/10 19:59:59 kleink Exp $ */ +/* $NetBSD: plist.c,v 1.44 2004/06/01 16:15:31 minskim Exp $ */ #include #ifndef lint #if 0 static const char *rcsid = "from FreeBSD Id: plist.c,v 1.24 1997/10/08 07:48:15 charnier Exp"; #else -__RCSID("$NetBSD: plist.c,v 1.43 2004/05/10 19:59:59 kleink Exp $"); +__RCSID("$NetBSD: plist.c,v 1.44 2004/06/01 16:15:31 minskim Exp $"); #endif #endif @@ -397,11 +397,23 @@ delete_package(Boolean ign_err, Boolean nukedirs, package_t *pkg) } buf[SymlinkHeaderLen + cc] = 0x0; if (strcmp(buf, p->next->name) != 0) { - printf("symlink %s is not same as recorded value, %s: %s\n", - buf, Force ? "deleting anyway" : "not deleting", tmp); - if (!Force) { - fail = FAIL; - continue; + if ((cc = readlink(&buf[SymlinkHeaderLen], &buf[SymlinkHeaderLen], + sizeof(buf) - SymlinkHeaderLen)) < 0) { + printf("symlink %s is not same as recorded value, %s: %s\n", + buf, Force ? "deleting anyway" : "not deleting", tmp); + if (!Force) { + fail = FAIL; + continue; + } + } + buf[SymlinkHeaderLen + cc] = 0x0; + if (strcmp(buf, p->next->name) != 0) { + printf("symlink %s is not same as recorded value, %s: %s\n", + buf, Force ? "deleting anyway" : "not deleting", tmp); + if (!Force) { + fail = FAIL; + continue; + } } } }