Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Fix symlinks checksum verification in pkg_delete.
Vsevolod Stakhov committed 11 years ago
commit 84ce9f4ea63e0458cc76d11c7e69a84d79e6c74f
parent 20c3c38
1 file changed +12 -1
modified libpkg/pkg_delete.c
@@ -118,6 +118,7 @@ pkg_delete_files(struct pkg *pkg, unsigned force)
	const char	*path;
	char		fpath[MAXPATHLEN];
	int		nfiles, cur_file = 0;
+
	struct stat st;

	nfiles = HASH_COUNT(pkg->files);

@@ -143,8 +144,18 @@ pkg_delete_files(struct pkg *pkg, unsigned force)
		/* Regular files and links */
		/* check sha256 */
		if (!force && sum[0] != '\0') {
-
			if (sha256_file(fpath, sha256) != EPKG_OK)
+
			if (lstat(fpath, &st) == -1) {
+
				pkg_emit_error("cannot stat %s: %s", fpath, strerror(errno));
				continue;
+
			}
+
			if (S_ISLNK(st.st_mode)) {
+
				if (pkg_symlink_cksum(fpath, NULL, sha256) != EPKG_OK)
+
					continue;
+
			}
+
			else {
+
				if (sha256_file(fpath, sha256) != EPKG_OK)
+
					continue;
+
			}
			if (strcmp(sha256, sum)) {
				pkg_emit_error("%s fails original SHA256 "
				    "checksum, not removing", path);