tarfs: Support tar files which include file modes with permissions.

Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D39020
This commit is contained in:
Dag-Erling Smørgrav 2023-03-16 11:31:10 +00:00
parent fd8c98a52f
commit e81d55b439
2 changed files with 3 additions and 2 deletions

View File

@ -515,12 +515,12 @@ again:
/* get standard attributes */ /* get standard attributes */
num = tarfs_str2int64(hdrp->mode, sizeof(hdrp->mode)); num = tarfs_str2int64(hdrp->mode, sizeof(hdrp->mode));
if (num < 0 || num > ALLPERMS) { if (num < 0 || num > (S_IFMT|ALLPERMS)) {
TARFS_DPF(ALLOC, "%s: invalid file mode at %zu\n", TARFS_DPF(ALLOC, "%s: invalid file mode at %zu\n",
__func__, TARFS_BLOCKSIZE * (blknum - 1)); __func__, TARFS_BLOCKSIZE * (blknum - 1));
mode = S_IRUSR; mode = S_IRUSR;
} else { } else {
mode = num; mode = num & ALLPERMS;
} }
num = tarfs_str2int64(hdrp->uid, sizeof(hdrp->uid)); num = tarfs_str2int64(hdrp->uid, sizeof(hdrp->uid));
if (num < 0 || num > UID_MAX) { if (num < 0 || num > UID_MAX) {

View File

@ -59,6 +59,7 @@ tarfs_basic_body() {
atf_check_equal "$(stat -f%d,%i "${mnt}"/sparse_file)" "$(stat -L -f%d,%i "${mnt}"/short_link)" atf_check_equal "$(stat -f%d,%i "${mnt}"/sparse_file)" "$(stat -L -f%d,%i "${mnt}"/short_link)"
atf_check_equal "$(stat -f%d,%i "${mnt}"/sparse_file)" "$(stat -L -f%d,%i "${mnt}"/long_link)" atf_check_equal "$(stat -f%d,%i "${mnt}"/sparse_file)" "$(stat -L -f%d,%i "${mnt}"/long_link)"
atf_check_equal "$(sha256 -q "${mnt}"/sparse_file)" ${sum} atf_check_equal "$(sha256 -q "${mnt}"/sparse_file)" ${sum}
atf_check_equal "$(stat -f%p "${mnt}"/sparse_file)" 100644
atf_check_equal "$(stat -f%l "${mnt}"/sparse_file)" 2 atf_check_equal "$(stat -f%l "${mnt}"/sparse_file)" 2
atf_check_equal "$(stat -f%l "${mnt}"/hard_link)" 2 atf_check_equal "$(stat -f%l "${mnt}"/hard_link)" 2
} }