Module Name: src Committed By: chs Date: Mon Dec 12 16:53:30 UTC 2022
Modified Files: src/sbin/restore: dirs.c tape.c Log Message: apply this commit from FreeBSD: commit 9dda00df7e8f9279a43d92758df6a7e10a9aed95 Author: Chuck Silvers <c...@freebsd.org> Date: Mon Dec 12 08:14:17 2022 -0800 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 To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/sbin/restore/dirs.c cvs rdiff -u -r1.73 -r1.74 src/sbin/restore/tape.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/restore/dirs.c diff -u src/sbin/restore/dirs.c:1.54 src/sbin/restore/dirs.c:1.55 --- src/sbin/restore/dirs.c:1.54 Sat Dec 10 18:49:44 2022 +++ src/sbin/restore/dirs.c Mon Dec 12 16:53:30 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: dirs.c,v 1.54 2022/12/10 18:49:44 chs Exp $ */ +/* $NetBSD: dirs.c,v 1.55 2022/12/12 16:53:30 chs Exp $ */ /* * Copyright (c) 1983, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)dirs.c 8.7 (Berkeley) 5/1/95"; #else -__RCSID("$NetBSD: dirs.c,v 1.54 2022/12/10 18:49:44 chs Exp $"); +__RCSID("$NetBSD: dirs.c,v 1.55 2022/12/12 16:53:30 chs Exp $"); #endif #endif /* not lint */ @@ -675,8 +675,13 @@ setdirmodes(int flags) (uintmax_t)node.ino); continue; } + cp = myname(ep); if (!Nflag) { - cp = myname(ep); + 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); @@ -685,11 +690,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); (void) utimens(cp, node.ctimep); (void) utimens(cp, node.mtimep); if (Mtreefile) { Index: src/sbin/restore/tape.c diff -u src/sbin/restore/tape.c:1.73 src/sbin/restore/tape.c:1.74 --- src/sbin/restore/tape.c:1.73 Sat Dec 10 18:49:44 2022 +++ src/sbin/restore/tape.c Mon Dec 12 16:53:30 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tape.c,v 1.73 2022/12/10 18:49:44 chs Exp $ */ +/* $NetBSD: tape.c,v 1.74 2022/12/12 16:53:30 chs Exp $ */ /* * Copyright (c) 1983, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)tape.c 8.9 (Berkeley) 5/1/95"; #else -__RCSID("$NetBSD: tape.c,v 1.73 2022/12/10 18:49:44 chs Exp $"); +__RCSID("$NetBSD: tape.c,v 1.74 2022/12/12 16:53:30 chs Exp $"); #endif #endif /* not lint */ @@ -698,13 +698,13 @@ extractfile(char *name) if (uflag) (void) unlink(name); if (linkit(lnkbuf, name, SYMLINK) == GOOD) { - if (extsize > 0) - set_extattr(-1, name, buf, extsize, SXA_LINK); if (setbirth) (void) lutimens(name, ctimep); (void) lutimens(name, mtimep); (void) lchown(name, uid, gid); (void) lchmod(name, mode); + if (extsize > 0) + set_extattr(-1, name, buf, extsize, SXA_LINK); if (Mtreefile) { writemtree(name, "link", uid, gid, mode, flags); @@ -730,6 +730,8 @@ extractfile(char *name) skipfile(); return (FAIL); } + (void) chown(name, uid, gid); + (void) chmod(name, mode); if (extsize == 0) { skipfile(); } else { @@ -740,8 +742,6 @@ extractfile(char *name) if (setbirth) (void) utimens(name, ctimep); (void) utimens(name, mtimep); - (void) chown(name, uid, gid); - (void) chmod(name, mode); if (Mtreefile) { writemtree(name, ((mode & (S_IFBLK | IFCHR)) == IFBLK) ? @@ -765,6 +765,8 @@ extractfile(char *name) skipfile(); return (FAIL); } + (void) chown(name, uid, gid); + (void) chmod(name, mode); if (extsize == 0) { skipfile(); } else { @@ -775,8 +777,6 @@ extractfile(char *name) if (setbirth) (void) utimens(name, ctimep); (void) utimens(name, mtimep); - (void) chown(name, uid, gid); - (void) chmod(name, mode); if (Mtreefile) { writemtree(name, "fifo", uid, gid, mode, flags); @@ -797,6 +797,8 @@ extractfile(char *name) } if (Dflag) (*ddesc->dd_init)(&dcontext); + (void) fchown(ofile, uid, gid); + (void) fchmod(ofile, mode); buf = setupextattr(extsize); getfile(xtrfile, xtrattr, xtrskip); if (extsize > 0) @@ -814,8 +816,6 @@ extractfile(char *name) if (setbirth) (void) futimens(ofile, ctimep); (void) futimens(ofile, mtimep); - (void) fchown(ofile, uid, gid); - (void) fchmod(ofile, mode); if (Mtreefile) { writemtree(name, "file", uid, gid, mode, flags);