summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install
diff options
context:
space:
mode:
authorsobomax <sobomax@FreeBSD.org>2002-05-02 12:52:42 +0000
committersobomax <sobomax@FreeBSD.org>2002-05-02 12:52:42 +0000
commit95a09c0851d805818c39950f9f3937901a15e3e6 (patch)
tree50d56ed42b8d488530432aaf57ab9bc46c0f1e44 /usr.sbin/pkg_install
parent0bc51e3b0f5750f8334f68f7f672786157a24d7c (diff)
downloadFreeBSD-src-95a09c0851d805818c39950f9f3937901a15e3e6.zip
FreeBSD-src-95a09c0851d805818c39950f9f3937901a15e3e6.tar.gz
Make `-g' working for symlinks.
PR: 33857 Submitted by: darren <igla@batterybackups.net> MFC after: 1 week
Diffstat (limited to 'usr.sbin/pkg_install')
-rw-r--r--usr.sbin/pkg_install/info/show.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/usr.sbin/pkg_install/info/show.c b/usr.sbin/pkg_install/info/show.c
index fb896ed..95550d1a 100644
--- a/usr.sbin/pkg_install/info/show.c
+++ b/usr.sbin/pkg_install/info/show.c
@@ -279,9 +279,26 @@ show_cksum(const char *title, Package *plist)
snprintf(tmp, FILENAME_MAX, "%s/%s", dir, p->name);
if (!fexists(tmp))
warnx("%s doesn't exist\n", tmp);
- else if (p->next && p->next->type == PLIST_COMMENT && !strncmp(p->next->name, "MD5:", 4)) {
- char *cp, buf[33];
- if ((cp = MD5File(tmp, buf)) != NULL) {
+ else if (p->next && p->next->type == PLIST_COMMENT &&
+ (strncmp(p->next->name, "MD5:", 4) == 0)) {
+ char *cp = NULL, buf[33];
+
+ /*
+ * For packing lists whose version is 1.1 or greater, the md5
+ * hash for a symlink is calculated on the string returned
+ * by readlink().
+ */
+ if (issymlink(tmp) && verscmp(plist, 1, 0) > 0) {
+ int len;
+ char linkbuf[FILENAME_MAX];
+
+ if ((len = readlink(tmp, linkbuf, FILENAME_MAX)) > 0)
+ cp = MD5Data((unsigned char *)linkbuf, len, buf);
+ } else if (isfile(tmp) || verscmp(plist, 1, 1) < 0)
+ cp = MD5File(tmp, buf);
+
+ if (cp != NULL) {
+ /* Mismatch? */
if (strcmp(cp, p->next->name + 4))
printf("%s fails the original MD5 checksum\n", tmp);
else if (Verbose)
OpenPOWER on IntegriCloud