aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChuck Silvers <chs@FreeBSD.org>2022-12-12 16:14:17 +0000
committerChuck Silvers <chs@FreeBSD.org>2022-12-12 16:19:51 +0000
commit9dda00df7e8f9279a43d92758df6a7e10a9aed95 (patch)
treef08ce4dc085d3b8178da41a6512ad805f5e5333a
parent86edb11e7491e657e6c75ef6814867021665c377 (diff)
downloadsrc-9dda00df7e8f9279a43d92758df6a7e10a9aed95.tar.gz
src-9dda00df7e8f9279a43d92758df6a7e10a9aed95.zip
restore: fix restore of NFS4 ACLs
Changing the mode bits on a file with an NFS4 ACL results in the NFS4 ACL being replaced by one matching the new mode bits being set, so when restoring a file with an NFS4 ACL, set the owner/group/mode first and then set the NFS4 ACL, so that setting the mode does not throw away the ACL that we just set. Reviewed by: mckusick Differential Revision: https://reviews.freebsd.org/D37618
-rw-r--r--sbin/restore/dirs.c10
-rw-r--r--sbin/restore/tape.c16
2 files changed, 13 insertions, 13 deletions
diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c
index a8120fda8b6e..4a25b728e8a0 100644
--- a/sbin/restore/dirs.c
+++ b/sbin/restore/dirs.c
@@ -646,6 +646,11 @@ setdirmodes(int flags)
}
cp = myname(ep);
if (!Nflag) {
+ if (myuid != 0)
+ (void) chown(cp, myuid, node.gid);
+ else
+ (void) chown(cp, node.uid, node.gid);
+ (void) chmod(cp, node.mode);
if (node.extsize > 0) {
if (bufsize >= node.extsize) {
set_extattr(-1, cp, buf, node.extsize, SXA_FILE);
@@ -654,11 +659,6 @@ setdirmodes(int flags)
"extended attributes for ", cp);
}
}
- if (myuid != 0)
- (void) chown(cp, myuid, node.gid);
- else
- (void) chown(cp, node.uid, node.gid);
- (void) chmod(cp, node.mode);
utimensat(AT_FDCWD, cp, node.ctimep, 0);
utimensat(AT_FDCWD, cp, node.mtimep, 0);
(void) chflags(cp, node.flags);
diff --git a/sbin/restore/tape.c b/sbin/restore/tape.c
index 1c8c2402b9fc..e5508bc08639 100644
--- a/sbin/restore/tape.c
+++ b/sbin/restore/tape.c
@@ -628,10 +628,10 @@ extractfile(char *name)
return (GOOD);
}
if (linkit(lnkbuf, name, SYMLINK) == GOOD) {
- if (extsize > 0)
- set_extattr(-1, name, buf, extsize, SXA_LINK);
(void) lchown(name, uid, gid);
(void) lchmod(name, mode);
+ if (extsize > 0)
+ set_extattr(-1, name, buf, extsize, SXA_LINK);
(void) utimensat(AT_FDCWD, name, ctimep,
AT_SYMLINK_NOFOLLOW);
(void) utimensat(AT_FDCWD, name, mtimep,
@@ -655,6 +655,8 @@ extractfile(char *name)
skipfile();
return (FAIL);
}
+ (void) chown(name, uid, gid);
+ (void) chmod(name, mode);
if (extsize == 0) {
skipfile();
} else {
@@ -662,8 +664,6 @@ extractfile(char *name)
getfile(xtrnull, xtrattr, xtrnull);
set_extattr(-1, name, buf, extsize, SXA_FILE);
}
- (void) chown(name, uid, gid);
- (void) chmod(name, mode);
(void) utimensat(AT_FDCWD, name, ctimep, 0);
(void) utimensat(AT_FDCWD, name, mtimep, 0);
(void) chflags(name, flags);
@@ -685,6 +685,8 @@ extractfile(char *name)
skipfile();
return (FAIL);
}
+ (void) chown(name, uid, gid);
+ (void) chmod(name, mode);
if (extsize == 0) {
skipfile();
} else {
@@ -692,8 +694,6 @@ extractfile(char *name)
getfile(xtrnull, xtrattr, xtrnull);
set_extattr(-1, name, buf, extsize, SXA_FILE);
}
- (void) chown(name, uid, gid);
- (void) chmod(name, mode);
(void) utimensat(AT_FDCWD, name, ctimep, 0);
(void) utimensat(AT_FDCWD, name, mtimep, 0);
(void) chflags(name, flags);
@@ -714,12 +714,12 @@ extractfile(char *name)
skipfile();
return (FAIL);
}
+ (void) fchown(ofile, uid, gid);
+ (void) fchmod(ofile, mode);
buf = setupextattr(extsize);
getfile(xtrfile, xtrattr, xtrskip);
if (extsize > 0)
set_extattr(ofile, name, buf, extsize, SXA_FD);
- (void) fchown(ofile, uid, gid);
- (void) fchmod(ofile, mode);
(void) futimens(ofile, ctimep);
(void) futimens(ofile, mtimep);
(void) fchflags(ofile, flags);