summaryrefslogtreecommitdiffstats
path: root/system/trrntzip/trrntzip_permission_fix.diff
blob: 6e6f93929e6ba04c9ebb0ecb956c56d3d9b30e2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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)