mirror of
https://github.com/sheumann/hush.git
synced 2024-12-22 14:30:31 +00:00
copyFile could call chmod on a symlink, changing the perms
of the pointed to file. Minor fix to tar for directory handling. -Erik
This commit is contained in:
parent
ccc7488615
commit
ce5b466bcc
@ -25,7 +25,8 @@
|
|||||||
contributed Friedrich Vedder <fwv@myrtle.lahn.de>
|
contributed Friedrich Vedder <fwv@myrtle.lahn.de>
|
||||||
* Cosmetic fix to busybox.c (Don't print a comma at the
|
* Cosmetic fix to busybox.c (Don't print a comma at the
|
||||||
end of line if there are no more application names).
|
end of line if there are no more application names).
|
||||||
* Fixed a stupid bug in "head" option handling ("head -n" would segfault).
|
* Fixed a stupid bug in "head" option handling ("head -n"
|
||||||
|
would segfault).
|
||||||
* Moved commonly used functions "xmalloc()" and "exit()"
|
* Moved commonly used functions "xmalloc()" and "exit()"
|
||||||
to utility.c (with proper #ifdef's).
|
to utility.c (with proper #ifdef's).
|
||||||
* Created a tiny tail implementation, removing -c, -q, -v, and making
|
* Created a tiny tail implementation, removing -c, -q, -v, and making
|
||||||
@ -37,7 +38,10 @@
|
|||||||
* Fixed mount and umount. Previously they could leak loop device
|
* Fixed mount and umount. Previously they could leak loop device
|
||||||
allocations, causing the system to quickly run out. Fix for umount
|
allocations, causing the system to quickly run out. Fix for umount
|
||||||
by Ben Collins <bcollins@debian.org>, and mount was fixed by me.
|
by Ben Collins <bcollins@debian.org>, and mount was fixed by me.
|
||||||
* ls formatting on 8 char user names fixed by Randolph Chung <tausq@debian.org>.
|
* ls formatting on eight charactor user names fixed by
|
||||||
|
Randolph Chung <tausq@debian.org>.
|
||||||
|
* cp could, when copying symlinks, change permissions of the
|
||||||
|
files pointed to by the symlinks.
|
||||||
|
|
||||||
|
|
||||||
-Erik Andersen
|
-Erik Andersen
|
||||||
|
@ -596,6 +596,7 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
chmod(outName, mode);
|
chmod(outName, mode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
1
tar.c
1
tar.c
@ -596,6 +596,7 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
chmod(outName, mode);
|
chmod(outName, mode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
30
utility.c
30
utility.c
@ -131,6 +131,7 @@ copyFile( const char *srcName, const char *destName,
|
|||||||
struct stat dstStatBuf;
|
struct stat dstStatBuf;
|
||||||
struct utimbuf times;
|
struct utimbuf times;
|
||||||
|
|
||||||
|
/* Grab the source file's stats */
|
||||||
if (followLinks == FALSE)
|
if (followLinks == FALSE)
|
||||||
result = stat(srcName, &srcStatBuf);
|
result = stat(srcName, &srcStatBuf);
|
||||||
else
|
else
|
||||||
@ -140,6 +141,7 @@ copyFile( const char *srcName, const char *destName,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Grab the dest file's stats */
|
||||||
if (followLinks == FALSE)
|
if (followLinks == FALSE)
|
||||||
result = stat(destName, &dstStatBuf);
|
result = stat(destName, &dstStatBuf);
|
||||||
else
|
else
|
||||||
@ -223,18 +225,18 @@ copyFile( const char *srcName, const char *destName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (setModes == TRUE) {
|
if (setModes == TRUE) {
|
||||||
//fprintf(stderr, "Setting permissions for %s\n", destName);
|
if (! S_ISLNK(srcStatBuf.st_mode)) {
|
||||||
chmod(destName, srcStatBuf.st_mode);
|
|
||||||
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
|
|
||||||
if (followLinks == FALSE)
|
|
||||||
lchown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid);
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
chown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid);
|
chown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid);
|
||||||
|
/* Never chmod a symlink; it follows the link */
|
||||||
|
chmod(destName, srcStatBuf.st_mode);
|
||||||
|
}
|
||||||
|
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
|
||||||
|
else {
|
||||||
|
lchown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
times.actime = srcStatBuf.st_atime;
|
times.actime = srcStatBuf.st_atime;
|
||||||
times.modtime = srcStatBuf.st_mtime;
|
times.modtime = srcStatBuf.st_mtime;
|
||||||
|
|
||||||
utime(destName, ×);
|
utime(destName, ×);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,6 +416,7 @@ recursiveAction(const char *fileName, int recurse, int followLinks, int depthFir
|
|||||||
status = lstat(fileName, &statbuf);
|
status = lstat(fileName, &statbuf);
|
||||||
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
|
fprintf(stderr, "status=%d followLinks=%d TRUE=%d\n", status, followLinks, TRUE);
|
||||||
perror(fileName);
|
perror(fileName);
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
@ -515,14 +518,11 @@ extern int createPath (const char *name, int mode)
|
|||||||
cp = strchr (cp + 1, '/');
|
cp = strchr (cp + 1, '/');
|
||||||
*cpOld = '\0';
|
*cpOld = '\0';
|
||||||
retVal = mkdir (buf, cp ? 0777 : mode);
|
retVal = mkdir (buf, cp ? 0777 : mode);
|
||||||
*cpOld = '/';
|
if (retVal != 0 && errno != EEXIST) {
|
||||||
}
|
perror( buf);
|
||||||
/* Return the result from the final directory, as that
|
|
||||||
* is the one that counts */
|
|
||||||
if( retVal!=0) {
|
|
||||||
if ( errno!=EEXIST) {
|
|
||||||
return( FALSE);
|
return( FALSE);
|
||||||
}
|
}
|
||||||
|
*cpOld = '/';
|
||||||
}
|
}
|
||||||
return( TRUE);
|
return( TRUE);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user