mirror of
https://github.com/sheumann/hush.git
synced 2025-01-13 06:30:09 +00:00
chown(2) clears S_ISUID and S_ISGID, even when chown is
called as root. Changed ordering of chown and chmod so SGID and SUID file permissions don't get munged. -Erik
This commit is contained in:
parent
00417a38c1
commit
98f67e35d8
@ -520,8 +520,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
if (hardLink) {
|
if (hardLink) {
|
||||||
if (link (hp->linkName, name) < 0)
|
if (link (hp->linkName, name) < 0)
|
||||||
perror (name);
|
perror (name);
|
||||||
chmod(name, mode);
|
|
||||||
chown(name, uid, gid);
|
chown(name, uid, gid);
|
||||||
|
chmod(name, mode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,8 +529,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
#ifdef S_ISLNK
|
#ifdef S_ISLNK
|
||||||
if (symlink (hp->linkName, name) < 0)
|
if (symlink (hp->linkName, name) < 0)
|
||||||
perror (name);
|
perror (name);
|
||||||
chmod(name, mode);
|
|
||||||
chown(name, uid, gid);
|
chown(name, uid, gid);
|
||||||
|
chmod(name, mode);
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, "Cannot create symbolic links\n");
|
fprintf (stderr, "Cannot create symbolic links\n");
|
||||||
#endif
|
#endif
|
||||||
@ -546,8 +546,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
*/
|
*/
|
||||||
if (S_ISDIR (mode)) {
|
if (S_ISDIR (mode)) {
|
||||||
createPath (name, mode);
|
createPath (name, mode);
|
||||||
chmod(name, mode);
|
|
||||||
chown(name, uid, gid);
|
chown(name, uid, gid);
|
||||||
|
chmod(name, mode);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -585,8 +585,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (tostdoutFlag == FALSE) {
|
if (tostdoutFlag == FALSE) {
|
||||||
fchmod(outFd, mode);
|
|
||||||
fchown(outFd, uid, gid);
|
fchown(outFd, uid, gid);
|
||||||
|
fchmod(outFd, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
8
tar.c
8
tar.c
@ -520,8 +520,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
if (hardLink) {
|
if (hardLink) {
|
||||||
if (link (hp->linkName, name) < 0)
|
if (link (hp->linkName, name) < 0)
|
||||||
perror (name);
|
perror (name);
|
||||||
chmod(name, mode);
|
|
||||||
chown(name, uid, gid);
|
chown(name, uid, gid);
|
||||||
|
chmod(name, mode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,8 +529,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
#ifdef S_ISLNK
|
#ifdef S_ISLNK
|
||||||
if (symlink (hp->linkName, name) < 0)
|
if (symlink (hp->linkName, name) < 0)
|
||||||
perror (name);
|
perror (name);
|
||||||
chmod(name, mode);
|
|
||||||
chown(name, uid, gid);
|
chown(name, uid, gid);
|
||||||
|
chmod(name, mode);
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, "Cannot create symbolic links\n");
|
fprintf (stderr, "Cannot create symbolic links\n");
|
||||||
#endif
|
#endif
|
||||||
@ -546,8 +546,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
*/
|
*/
|
||||||
if (S_ISDIR (mode)) {
|
if (S_ISDIR (mode)) {
|
||||||
createPath (name, mode);
|
createPath (name, mode);
|
||||||
chmod(name, mode);
|
|
||||||
chown(name, uid, gid);
|
chown(name, uid, gid);
|
||||||
|
chmod(name, mode);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -585,8 +585,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (tostdoutFlag == FALSE) {
|
if (tostdoutFlag == FALSE) {
|
||||||
fchmod(outFd, mode);
|
|
||||||
fchown(outFd, uid, gid);
|
fchown(outFd, uid, gid);
|
||||||
|
fchmod(outFd, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user