Fixed a bug where tar would not set the user and group on device

special files.
 -Erik
This commit is contained in:
Erik Andersen 1999-12-28 00:17:46 +00:00
parent 69ba6b2956
commit 00266d3df6
3 changed files with 17 additions and 21 deletions

View File

@ -10,9 +10,9 @@
* Added 'grep -q' thanks to a patch from "Konstantin Boldyshev" * Added 'grep -q' thanks to a patch from "Konstantin Boldyshev"
<konst@voshod.com>. <konst@voshod.com>.
* Implemented sort. -beppu * Implemented sort. -beppu
* Fixed tar SGID and SUID bug. Seems that chown(2) clears S_ISUID and * Fixed a bug where tar would set, and then clear SGID and SUID bits.
S_ISGID, even when chown is called as root. I changed the ordering * Fixed a bug where tar would not set the user and group on device
of chown and chmod so SGID and SUID file permissions don't get munged. special files.
-Erik Andersen -Erik Andersen

View File

@ -577,18 +577,16 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
} else { } else {
outFd = open (name, O_WRONLY | O_CREAT | O_TRUNC, mode); outFd = open (name, O_WRONLY | O_CREAT | O_TRUNC, mode);
} }
}
if (outFd < 0) { if (outFd < 0) {
perror (name); perror (name);
skipFileFlag = TRUE; skipFileFlag = TRUE;
return; return;
} }
if (tostdoutFlag == FALSE) { chown(name, uid, gid);
fchown(outFd, uid, gid); chmod(name, mode);
fchmod(outFd, mode);
} }
/* /*
* If the file is empty, then that's all we need to do. * If the file is empty, then that's all we need to do.
*/ */

8
tar.c
View File

@ -577,18 +577,16 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
} else { } else {
outFd = open (name, O_WRONLY | O_CREAT | O_TRUNC, mode); outFd = open (name, O_WRONLY | O_CREAT | O_TRUNC, mode);
} }
}
if (outFd < 0) { if (outFd < 0) {
perror (name); perror (name);
skipFileFlag = TRUE; skipFileFlag = TRUE;
return; return;
} }
if (tostdoutFlag == FALSE) { chown(name, uid, gid);
fchown(outFd, uid, gid); chmod(name, mode);
fchmod(outFd, mode);
} }
/* /*
* If the file is empty, then that's all we need to do. * If the file is empty, then that's all we need to do.
*/ */