Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/restore apply this commit from FreeBSD:



details:   https://anonhg.NetBSD.org/src/rev/0be7992483d3
branches:  trunk
changeset: 372617:0be7992483d3
user:      chs <chs%NetBSD.org@localhost>
date:      Mon Dec 12 16:53:30 2022 +0000

description:
apply this commit from FreeBSD:

  commit 9dda00df7e8f9279a43d92758df6a7e10a9aed95
  Author: Chuck Silvers <chs%FreeBSD.org@localhost>
  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

diffstat:

 sbin/restore/dirs.c |  16 ++++++++--------
 sbin/restore/tape.c |  20 ++++++++++----------
 2 files changed, 18 insertions(+), 18 deletions(-)

diffs (133 lines):

diff -r ff757271181d -r 0be7992483d3 sbin/restore/dirs.c
--- a/sbin/restore/dirs.c       Mon Dec 12 13:26:46 2022 +0000
+++ b/sbin/restore/dirs.c       Mon Dec 12 16:53:30 2022 +0000
@@ -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 @@
                            (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 @@
                                            "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) {
diff -r ff757271181d -r 0be7992483d3 sbin/restore/tape.c
--- a/sbin/restore/tape.c       Mon Dec 12 13:26:46 2022 +0000
+++ b/sbin/restore/tape.c       Mon Dec 12 16:53:30 2022 +0000
@@ -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 @@
                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 @@
                        skipfile();
                        return (FAIL);
                }
+               (void) chown(name, uid, gid);
+               (void) chmod(name, mode);
                if (extsize == 0) {
                        skipfile();
                } else {
@@ -740,8 +742,6 @@
                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 @@
                        skipfile();
                        return (FAIL);
                }
+               (void) chown(name, uid, gid);
+               (void) chmod(name, mode);
                if (extsize == 0) {
                        skipfile();
                } else {
@@ -775,8 +777,6 @@
                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 @@
                }
                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 @@
                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);



Home | Main Index | Thread Index | Old Index