Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
When extracting packages if they were packed with relative path name, then prepend a '/' to the path
Baptiste Daroussin committed 10 years ago
commit 01e323a0ff19dc7dce779a6071a7d7fa0d1ae71e
parent 71e721d
5 files changed +12 -10
modified libpkg/pkg.c
@@ -713,7 +713,7 @@ pkg_addfile_attr(struct pkg *pkg, const char *path, const char *sum,
	assert(pkg != NULL);
	assert(path != NULL && path[0] != '\0');

-
	path = pkg_absolutepath(path, abspath, sizeof(abspath));
+
	path = pkg_absolutepath(path, abspath, sizeof(abspath), false);
	pkg_debug(3, "Pkg: add new file '%s'", path);

	if (check_duplicates && kh_contains(pkg_files, pkg->filehash, path)) {
@@ -756,7 +756,7 @@ pkg_addconfig_file(struct pkg *pkg, const char *path, const char *content)
	struct pkg_config_file *f = NULL;
	char abspath[MAXPATHLEN];

-
	path = pkg_absolutepath(path, abspath, sizeof(abspath));
+
	path = pkg_absolutepath(path, abspath, sizeof(abspath), false);
	pkg_debug(3, "Pkg: add new config file '%s'", path);

	if (kh_contains(pkg_config_files, pkg->config_files, path)) {
@@ -820,7 +820,7 @@ pkg_adddir_attr(struct pkg *pkg, const char *path, const char *uname,
	assert(pkg != NULL);
	assert(path != NULL && path[0] != '\0');

-
	path = pkg_absolutepath(path, abspath, sizeof(abspath));
+
	path = pkg_absolutepath(path, abspath, sizeof(abspath), false);
	pkg_debug(3, "Pkg: add new directory '%s'", path);
	if (check_duplicates && kh_contains(pkg_dirs, pkg->dirhash, path)) {
		if (developer_mode) {
modified libpkg/pkg.h.in
@@ -1691,7 +1691,7 @@ char *pkg_utils_tokenize(char **);
int pkg_utils_count_spaces(const char *);
int pkg_add_port(struct pkgdb *db, struct pkg *pkg, const char *root, \
    const char *locationn, bool testing);
-
char *pkg_absolutepath(const char *src, char *dest, size_t dest_len);
+
char *pkg_absolutepath(const char *src, char *dest, size_t dest_len, bool fromroot);

void pkg_cache_full_clean(void);

modified libpkg/pkg_add.c
@@ -211,7 +211,7 @@ do_extract(struct archive *a, struct archive_entry *ae, const char *location,
		sbuf_clear(newconf);
		rf = NULL;
		rcf = NULL;
-
		pkg_absolutepath(archive_entry_pathname(ae), path, sizeof(path));
+
		pkg_absolutepath(archive_entry_pathname(ae), path, sizeof(path), true);
		snprintf(pathname, sizeof(pathname), "%s%s%s",
		    location ? location : "", *path == '/' ? "" : "/",
		    path
@@ -250,7 +250,7 @@ do_extract(struct archive *a, struct archive_entry *ae, const char *location,
		 */
		lp = archive_entry_hardlink(ae);
		if (lp != NULL) {
-
			pkg_absolutepath(lp, linkpath, sizeof(linkpath));
+
			pkg_absolutepath(lp, linkpath, sizeof(linkpath), true);
			snprintf(tmppath, sizeof(tmppath), "%s%s%s",
			    location ? location : "", *linkpath == '/' ? "" : "/",
			    linkpath);
modified libpkg/utils.c
@@ -751,15 +751,17 @@ pkg_utils_count_spaces(const char *args)

/* unlike realpath(3), this routine does not expand symbolic links */
char *
-
pkg_absolutepath(const char *src, char *dest, size_t dest_size) {
+
pkg_absolutepath(const char *src, char *dest, size_t dest_size, bool fromroot) {
	size_t dest_len, src_len, cur_len;
	const char *cur, *next;

	src_len = strlen(src);
	bzero(dest, dest_size);
	if (src_len != 0 && src[0] != '/') {
+
		if (fromroot)
+
			*dest = '/';
		/* relative path, we use cwd */
-
		if (getcwd(dest, dest_size) == NULL)
+
		else if (getcwd(dest, dest_size) == NULL)
			return (NULL);
	}
	dest_len = strlen(dest);
modified src/which.c
@@ -175,7 +175,7 @@ exec_which(int argc, char **argv)
						free(savedpath);
						goto cleanup;
					} else {
-
						pkg_absolutepath(match, pathabs, sizeof(pathabs));
+
						pkg_absolutepath(match, pathabs, sizeof(pathabs), false);
						/* ensure not not append twice an entry if PATH is messy */
						if (already_in_list(&patterns, pathabs))
							continue;
@@ -188,7 +188,7 @@ exec_which(int argc, char **argv)
		}

		if (!glob && !search) {
-
			pkg_absolutepath(argv[0], pathabs, sizeof(pathabs));
+
			pkg_absolutepath(argv[0], pathabs, sizeof(pathabs), false);
			kv_push(char *, patterns, strdup(pathabs));
		} else if (!search) {
			if (strlcpy(pathabs, argv[0], sizeof(pathabs)) >= sizeof(pathabs)) {