Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
Dont register SHA256 sum for symlink on pkgdb
Philippe Pepiot committed 15 years ago
commit 2708e572153713554952b7c951c7407a3dd7bbe3
parent d927abbe19308634687af90b2b75ed0fae9fe197
3 files changed +15 -13
modified libpkg/pkg.c
@@ -507,13 +507,15 @@ int
pkg_addfile(struct pkg *pkg, const char *path, const char *sha256)
{
	struct pkg_file *file;
-
	if (path == NULL || path[0] == '\0' || sha256 == NULL || sha256[0] == '\0')
+
	if (path == NULL || path[0] == '\0')
		return (-1);

	pkg_file_new(&file);

	strlcpy(file->path, path, sizeof(file->path));
-
	strlcpy(file->sha256, sha256, sizeof(file->sha256));
+

+
	if (sha256 != NULL)
+
		strlcpy(file->sha256, sha256, sizeof(file->sha256));

	array_init(&pkg->files, 10);
	array_append(&pkg->files, file);
modified libpkg/pkg_delete.c
@@ -2,7 +2,6 @@
#include <err.h>
#include <unistd.h>
#include <sha256.h>
-
#include <sys/stat.h>

#include "pkg.h"

@@ -11,8 +10,7 @@ pkg_delete(struct pkg *pkg, struct pkgdb *db, int force)
{
	struct pkg **rdeps;
	struct pkg_file **files;
-
	char sha256[65], *sha256_ptr;
-
	struct stat st;
+
	char sha256[65];

	if (pkg == NULL || db == NULL)
		return (-1);
@@ -30,9 +28,9 @@ pkg_delete(struct pkg *pkg, struct pkgdb *db, int force)

	for (int i = 0; files[i] != NULL; i++) {
		/* check sha256 */
-
		if (lstat(pkg_file_path(files[i]), &st) != -1 && !S_ISLNK(st.st_mode) &&
-
			((sha256_ptr = SHA256_File(pkg_file_path(files[i]), sha256)) == NULL ||
-
			strcmp(sha256_ptr, pkg_file_sha256(files[i])) != 0))
+
		if (pkg_file_sha256(files[i])[0] != '\0' &&
+
			(SHA256_File(pkg_file_path(files[i]), sha256) == NULL ||
+
			strcmp(sha256, pkg_file_sha256(files[i])) != 0))
			warnx("%s fails original SHA256 checksum, not removed",
					pkg_file_path(files[i]));

modified libpkg/pkg_ports.c
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
+
#include <sys/stat.h>

int
ports_parse_plist(struct pkg *pkg, char *plist, const char *prefix)
@@ -19,6 +20,7 @@ ports_parse_plist(struct pkg *pkg, char *plist, const char *prefix)
	int ret = 0;
	char *last_plist_file = NULL;
	char *cmd = NULL;
+
	struct stat st;

	buf = NULL;
	p = NULL;
@@ -77,14 +79,14 @@ ports_parse_plist(struct pkg *pkg, char *plist, const char *prefix)
			else
				snprintf(path, MAXPATHLEN, "%s/%s", prefix, buf);

-
			p = SHA256_File(path, sha256);
-

-
			if (p)
-
				pkg_addfile(pkg, path, p);
+
			if (lstat(path, &st) >= 0)
+
				p = S_ISLNK(st.st_mode) ? NULL : SHA256_File(path, sha256);
			else {
-
				ret--;
+
				warn("lstat(%s)", path);
+
				p = NULL;
			}

+
			ret += pkg_addfile(pkg, path, p);
		}

		plist_p += next + 1;