Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
create: track permissions for files and directories automatically
strssndktn committed 6 months ago
commit 148e9d8a41033cd7af0bf0acb574e3e2d5cc1d6f
parent 48e6c12
2 files changed +26 -3
modified libpkg/pkg_create.c
@@ -114,6 +114,10 @@ pkg_create_from_dir(struct pkg *pkg, const char *root,
			flatsize += file->size;
		}

+
		if (file->perm == 0) {
+
			file->perm = st.st_mode & ~S_IFMT;
+
		}
+

		if (trust_filesystem) {
			free(file->sum);
			file->sum = pkg_checksum_generate_file(fpath,
@@ -141,6 +145,25 @@ pkg_create_from_dir(struct pkg *pkg, const char *root,
	}
	vec_free_and_free(&hardlinks, free);

+
	while (pkg_dirs(pkg, &dir) == EPKG_OK) {
+
		snprintf(fpath, sizeof(fpath), "%s%s%s", root ? root : "",
+
			 relocation, dir->path);
+

+
		if (lstat(fpath, &st) == -1) {
+
			pkg_emit_error("dir '%s' is missing", fpath);
+
			return (EPKG_FATAL);
+
		}
+

+
		if (!S_ISDIR(st.st_mode)) {
+
			pkg_emit_error("dir '%s' is not a directory", fpath);
+
			return (EPKG_FATAL);
+
		}
+

+
		if (dir->perm == 0) {
+
			dir->perm = st.st_mode & ~S_IFMT;
+
		}
+
	}
+

	counter_end();

	pkg->flatsize = flatsize;
modified tests/frontend/create.sh
@@ -456,7 +456,7 @@ files {
        sum = "1\$e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
        uname = "root";
        gname = "wheel";
-
        perm = "0000";
+
        perm = "0644";
        fflags = 0;
        mtime = ${A_mtime};
    }
@@ -465,7 +465,7 @@ directories {
    /B {
        uname = "root";
        gname = "wheel";
-
        perm = "0000";
+
        perm = "0755";
        fflags = 0;
    }
}
@@ -512,7 +512,7 @@ files {
        sum = "1\$e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
        uname = "root";
        gname = "wheel";
-
        perm = "0000";
+
        perm = "0644";
        fflags = 0;
        mtime = ${testfile_mtime};
    }