slackbuilds_ponce/system/trrntzip/trrntzip_permission_fix.diff
2010-05-13 00:42:04 +02:00

47 lines
1.6 KiB
Diff

diff -Nru trrntzip/src/trrntzip.c trrntzip_v2patched/src/trrntzip.c
--- trrntzip/src/trrntzip.c 2005-05-02 10:38:40.000000000 -0300
+++ trrntzip_v2patched/src/trrntzip.c 2009-07-09 23:50:57.833279724 -0300
@@ -732,7 +732,15 @@
if (strstr (szTmpBuf, ".zip\0"))
{
- chmod (direntp->d_name, S_IRUSR);
+ //chmod (direntp->d_name, S_IRUSR);
+#ifndef S_ISVTX
+ // On windows we just set the file to read-only
+ chmod (direntp->d_name, S_IRUSR);
+#else
+ // On Unix systems we use the sticky bit
+ // We also retain all other flags
+ chmod (direntp->d_name, S_ISVTX | istat.st_mode);
+#endif
}
}
// Zip file is actually a dir
@@ -780,9 +788,22 @@
sprintf (szTmpBuf, "%s", direntp->d_name);
strlwr (szTmpBuf);
- if (strstr (szTmpBuf, ".zip\0") && !(istat.st_mode & S_IWUSR))
- {
- chmod (direntp->d_name, S_IWUSR);
+ //if (strstr (szTmpBuf, ".zip\0") && !(istat.st_mode & S_IWUSR))
+ //{
+ // chmod (direntp->d_name, S_IWUSR);
+ if (strstr (szTmpBuf, ".zip\0") &&
+
+#ifndef S_ISVTX
+ !(istat.st_mode & S_IWUSR))
+ {
+ // Remove the read only bit we set earlier on Windows systems
+ chmod (direntp->d_name, S_IWUSR);
+#else
+ istat.st_mode & S_ISVTX)
+ {
+ // Remove the sticky bit we set earlier on Unix systems
+ chmod (direntp->d_name, istat.st_mode - S_ISVTX);
+#endif
mig.cEncounteredZips++;
if (!mig.fProcessLog)