apply this change from FreeBSD:

commit c028393d7072f1f88efd8d6e6c77bb9b15b3f3b6
  Author: Kirk McKusick <mckusick@FreeBSD.org>
  Date:   Fri Apr 11 21:48:14 2008 +0000

      Correctly set file group when restore is run by a user other than root.
This commit is contained in:
chs 2022-12-10 18:49:44 +00:00
parent def88d0cda
commit a932562d1e
2 changed files with 14 additions and 7 deletions

View File

@ -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 @@ setdirmodes(int flags)
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 @@ setdirmodes(int flags)
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 @@ 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);
(void) chown(cp, node.uid, node.gid);
(void) chmod(cp, node.mode);
if (Mtreefile) {
writemtree(cp, "dir",
node.uid, node.gid, node.mode,

View File

@ -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 @@ extractfile(char *name)
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;