Subject: Re: Pkgviews and symlinks
To: None <cube@cubidou.net>
From: Min Sik Kim <minskim@NetBSD.org>
List: tech-pkg
Date: 05/04/2004 12:08:27
--Signature=_Tue__4_May_2004_12_08_27_-0500_uHxtvTEtLZGonOhm
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

* cube@cubidou.net, Tue, 4 May 2004 09:39:42 +0200:
> [snip]
>
> 3.  Hack pkg_admin so that it tries the symlink itself, the
>     target of the symlink, and so on until either the correct
>     value is found, or an error, or a recursion limit.  Works,
>     but it's hacky.
> 
> 4.  Avoid using pkg_admin is the outlned situation, and use
>     something else that knows a bit more about symlinks.  A
>     bit like 2.
> 
> Comments?  I'm tempted to implement 3 ``for now'' and then
> forget^Wdo something better later.

I have been using the following hack (3 with recursion limit=1) since
I reported the problem in PR pkg/24190.  I think it is OK at least
``for now.''

-- 
Min Sik Kim


Index: plist.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/pkg_install/lib/plist.c,v
retrieving revision 1.42
diff -u -r1.42 plist.c
--- plist.c	15 Jan 2004 09:33:39 -0000	1.42
+++ plist.c	4 May 2004 16:49:25 -0000
@@ -397,11 +397,23 @@
 						}
 						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;
+								}
 							}
 						}
 					}

--Signature=_Tue__4_May_2004_12_08_27_-0500_uHxtvTEtLZGonOhm
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (NetBSD)

iQEVAwUBQJfOC/QsKR/Zi7L+AQLItgf/TMAYCOUBhVXTX4V5QUnv4sybFJtL+xwX
A5PTcnRvebMAMjBfM+vo5BCbzNrSveOO2c0QIJzRrHiUZXpA7dKRd1/vodrwrnd/
vAEn2X1QrxFJ6Zq0zzGZx8S0ZxuxLMgymkx575JER1WRFG7sOgT+D5/5AcxYtp/m
XcxpaSuHa0vrV0V9uXsAXAVVncBfFj3QgaZH3NPE+ccRIrUKQsDQihpG+yWpss1J
bPQ3HT85u5kpprkaDFb2Bi6i9FN3eQX9rP4dmrnM378jGdJYcFdOqRI2PNoymmLQ
YAGfkfjY/EFNhis800C3wObiAn8Tkv57JDB7ConOFWmkkbjDFWmqPg==
=2hAJ
-----END PGP SIGNATURE-----

--Signature=_Tue__4_May_2004_12_08_27_-0500_uHxtvTEtLZGonOhm--