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 change from FreeBSD:
details: https://anonhg.NetBSD.org/src/rev/1703a7315e9b
branches: trunk
changeset: 372584:1703a7315e9b
user: chs <chs%NetBSD.org@localhost>
date: Sat Dec 10 18:49:44 2022 +0000
description:
apply this change from FreeBSD:
commit c028393d7072f1f88efd8d6e6c77bb9b15b3f3b6
Author: Kirk McKusick <mckusick%FreeBSD.org@localhost>
Date: Fri Apr 11 21:48:14 2008 +0000
Correctly set file group when restore is run by a user other than root.
diffstat:
sbin/restore/dirs.c | 13 +++++++++----
sbin/restore/tape.c | 8 +++++---
2 files changed, 14 insertions(+), 7 deletions(-)
diffs (79 lines):
diff -r 332410277895 -r 1703a7315e9b sbin/restore/dirs.c
--- a/sbin/restore/dirs.c Sat Dec 10 17:42:36 2022 +0000
+++ b/sbin/restore/dirs.c Sat Dec 10 18:49:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dirs.c,v 1.53 2021/06/23 14:22:08 riastradh Exp $ */
+/* $NetBSD: dirs.c,v 1.54 2022/12/10 18:49:44 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.53 2021/06/23 14:22:08 riastradh Exp $");
+__RCSID("$NetBSD: dirs.c,v 1.54 2022/12/10 18:49:44 chs Exp $");
#endif
#endif /* not lint */
@@ -598,6 +598,7 @@
struct entry *ep;
char *cp, *buf;
int bufsize;
+ uid_t myuid;
vprintf(stdout, "Set directory mode, owner, and times.\n");
if (command == 'r' || command == 'R')
@@ -618,6 +619,7 @@
clearerr(mf);
bufsize = 0;
buf = NULL;
+ myuid = getuid();
for (;;) {
(void) fread((char *)&node, 1, sizeof(struct modeinfo), mf);
if (ferror(mf)) {
@@ -683,10 +685,13 @@
"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);
- (void) chown(cp, node.uid, node.gid);
- (void) chmod(cp, node.mode);
if (Mtreefile) {
writemtree(cp, "dir",
node.uid, node.gid, node.mode,
diff -r 332410277895 -r 1703a7315e9b sbin/restore/tape.c
--- a/sbin/restore/tape.c Sat Dec 10 17:42:36 2022 +0000
+++ b/sbin/restore/tape.c Sat Dec 10 18:49:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tape.c,v 1.72 2022/05/05 07:45:43 mrg Exp $ */
+/* $NetBSD: tape.c,v 1.73 2022/12/10 18:49:44 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.72 2022/05/05 07:45:43 mrg Exp $");
+__RCSID("$NetBSD: tape.c,v 1.73 2022/12/10 18:49:44 chs Exp $");
#endif
#endif /* not lint */
@@ -656,7 +656,9 @@
ctimep[1].tv_nsec = curfile.birthtime_nsec;
}
extsize = curfile.extsize;
- uid = curfile.uid;
+ uid = getuid();
+ if (uid == 0)
+ uid = curfile.uid;
gid = curfile.gid;
mode = curfile.mode;
flags = curfile.file_flags;
Home |
Main Index |
Thread Index |
Old Index