Correctly set file group when restore is run by a user other than root.
This commit is contained in:
parent
31c50f53da
commit
c028393d70
@ -558,6 +558,7 @@ setdirmodes(int flags)
|
||||
char *cp, *buf;
|
||||
const char *tmpdir;
|
||||
int bufsize;
|
||||
uid_t myuid;
|
||||
|
||||
vprintf(stdout, "Set directory mode, owner, and times.\n");
|
||||
if ((tmpdir = getenv("TMPDIR")) == NULL || tmpdir[0] == '\0')
|
||||
@ -578,6 +579,7 @@ setdirmodes(int flags)
|
||||
}
|
||||
clearerr(mf);
|
||||
bufsize = 0;
|
||||
myuid = getuid();
|
||||
for (;;) {
|
||||
(void) fread((char *)&node, 1, sizeof(struct modeinfo), mf);
|
||||
if (feof(mf))
|
||||
@ -624,7 +626,10 @@ setdirmodes(int flags)
|
||||
"extended attributes for ", cp);
|
||||
}
|
||||
}
|
||||
(void) chown(cp, node.uid, node.gid);
|
||||
if (myuid != 0)
|
||||
(void) chown(cp, myuid, node.gid);
|
||||
else
|
||||
(void) chown(cp, node.uid, node.gid);
|
||||
(void) chmod(cp, node.mode);
|
||||
utimes(cp, node.ctimep);
|
||||
utimes(cp, node.mtimep);
|
||||
|
@ -582,7 +582,9 @@ extractfile(char *name)
|
||||
ctimep[1].tv_sec = curfile.birthtime_sec;
|
||||
ctimep[1].tv_usec = curfile.birthtime_nsec / 1000;
|
||||
extsize = curfile.extsize;
|
||||
uid = curfile.uid;
|
||||
uid = getuid();
|
||||
if (uid == 0)
|
||||
uid = curfile.uid;
|
||||
gid = curfile.gid;
|
||||
mode = curfile.mode;
|
||||
flags = curfile.file_flags;
|
||||
|
Loading…
x
Reference in New Issue
Block a user