Bug 182628 - app-arch/torrentzip changes permissions and fails to run
Bug#: 182628 Product:  Gentoo Linux Version: unspecified Platform: x86
OS/Version: Linux Status: RESOLVED Severity: normal Priority: P2
Resolution: FIXED Assigned To: net-p2p@gentoo.org Reported By: gentoo@altkai.ml1.net
Component: Applications
URL: 
Summary: app-arch/torrentzip changes permissions and fails to run
Keywords:  
Status Whiteboard: 
Opened: 2007-06-20 01:27 0000
Description:   Opened: 2007-06-20 01:27 0000
Hello, this is a known problem upstream, where torrentzip will change
permissions of the file it compresses, even locking itself out of being able to
write a file.

Currently I must use wine + torrentzip, which is less than ideal. I'm not a C
programmer, so would someone please look over this patch, taken from FreeBSD,
and see if it fixes the problem? tyvm!

Also see:
https://sourceforge.net/tracker/index.php?func=detail&aid=1415549&group_id=135285&atid=732451

and:

File permissions on Linux have different names: rename all
instances of 'S_ISTXT' in the patch to 'S_ISVTX' and
trrntzip will then compile.

--- src/trrntzip.c-orig Mon May  2 08:38:40 2005
+++ src/trrntzip.c      Sat May  7 02:51:55 2005
@@ -716,7 +716,7 @@

     if (dirp)
     {
-      // First set all the files to read-only. This is so we can skip
+      // First set the sticky bit on all files. This is so we can skip
       // our new zipfiles if they are returned by readdir() a second time.
       while (direntp = readdir (dirp))
       {
@@ -732,7 +732,7 @@

           if (strstr (szTmpBuf, ".zip\0"))
           {
-            chmod (direntp->d_name, S_IRUSR);
+            chmod (direntp->d_name, istat.st_mode | S_ISTXT);
           }
         }
         // Zip file is actually a dir
@@ -780,9 +780,9 @@
           sprintf (szTmpBuf, "%s", direntp->d_name);
           strlwr (szTmpBuf);

-          if (strstr (szTmpBuf, ".zip\0") && !(istat.st_mode & S_IWUSR))
+          if (strstr (szTmpBuf, ".zip\0") && (istat.st_mode & S_ISTXT))
           {            
-            chmod (direntp->d_name, S_IWUSR);
+            chmod (direntp->d_name, istat.st_mode & ~S_ISTXT);
             mig.cEncounteredZips++;

             if (!mig.fProcessLog)


Reproducible: Always

------- Comment #1 From Jonathan Adamczewski 2007-06-27 10:43:12 0000 -------
The provided patch does not compile.

Try this - it seems to work for me :

--- src/trrntzip.c-orig Mon May  2 08:38:40 2005
+++ src/trrntzip.c      Sat May  7 02:51:55 2005
@@ -780,9 +780,9 @@
           sprintf (szTmpBuf, "%s", direntp->d_name);
           strlwr (szTmpBuf);

           if (strstr (szTmpBuf, ".zip\0") && !(istat.st_mode & S_IWUSR))
           {            
-            chmod (direntp->d_name, S_IWUSR);
+            chmod (direntp->d_name, S_IWUSR | S_IRUSR);
             mig.cEncounteredZips++;

             if (!mig.fProcessLog)

------- Comment #2 From Kai 2007-06-27 20:17:01 0000 -------
Thank you, that seems to do the trick! I'll continue testing.

The patch that applies neatly is:

--- src/trrntzip.c
+++ src/trrntzip.c
@@ -782,7 +782,7 @@

           if (strstr (szTmpBuf, ".zip\0") && !(istat.st_mode & S_IWUSR))
           {            
-            chmod (direntp->d_name, S_IWUSR);
+            chmod (direntp->d_name, S_IWUSR | S_IRUSR);
             mig.cEncounteredZips++;

             if (!mig.fProcessLog)

------- Comment #3 From Raúl Porcel 2007-07-23 13:48:42 0000 -------
Fixed, thanks