From: Erik Andersen Date: Mon, 27 Dec 1999 23:48:33 +0000 (-0000) Subject: chown(2) clears S_ISUID and S_ISGID, even when chown is X-Git-Tag: 0_40~26 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=98f67e35d82e19f7a5e58551b5dd8feb121229b9;p=oweals%2Fbusybox.git 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 --- diff --git a/archival/tar.c b/archival/tar.c index 438770c03..bff248212 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -520,8 +520,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable) if (hardLink) { if (link (hp->linkName, name) < 0) perror (name); - chmod(name, mode); chown(name, uid, gid); + chmod(name, mode); return; } @@ -529,8 +529,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable) #ifdef S_ISLNK if (symlink (hp->linkName, name) < 0) perror (name); - chmod(name, mode); chown(name, uid, gid); + chmod(name, mode); #else fprintf (stderr, "Cannot create symbolic links\n"); #endif @@ -546,8 +546,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable) */ if (S_ISDIR (mode)) { createPath (name, mode); - chmod(name, mode); chown(name, uid, gid); + chmod(name, mode); return; } @@ -585,8 +585,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable) return; } if (tostdoutFlag == FALSE) { - fchmod(outFd, mode); fchown(outFd, uid, gid); + fchmod(outFd, mode); } /* diff --git a/tar.c b/tar.c index 438770c03..bff248212 100644 --- a/tar.c +++ b/tar.c @@ -520,8 +520,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable) if (hardLink) { if (link (hp->linkName, name) < 0) perror (name); - chmod(name, mode); chown(name, uid, gid); + chmod(name, mode); return; } @@ -529,8 +529,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable) #ifdef S_ISLNK if (symlink (hp->linkName, name) < 0) perror (name); - chmod(name, mode); chown(name, uid, gid); + chmod(name, mode); #else fprintf (stderr, "Cannot create symbolic links\n"); #endif @@ -546,8 +546,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable) */ if (S_ISDIR (mode)) { createPath (name, mode); - chmod(name, mode); chown(name, uid, gid); + chmod(name, mode); return; } @@ -585,8 +585,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable) return; } if (tostdoutFlag == FALSE) { - fchmod(outFd, mode); fchown(outFd, uid, gid); + fchmod(outFd, mode); } /*