Bug 141989 - If the downloading user haven't the needed rights to write in the target directory, kftpgrabber will download into nirvana (the files arn't there) and don't inform the user about this!
Summary: If the downloading user haven't the needed rights to write in the target dire...
Status: RESOLVED FIXED
Alias: None
Product: kftpgrabber
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Jernej Kos
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-20 17:18 UTC by Karl Glatz
Modified: 2007-04-01 21:45 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Karl Glatz 2007-02-20 17:18:53 UTC
Version:           0.8.0 (using KDE 3.5.5, Debian Package 4:3.5.5a.dfsg.1-6 (4.0))
Compiler:          Target: i486-linux-gnu
OS:                Linux (i686) release 2.6.18-3-k7

If the downloading user haven't the needed rights to write in the target directory, kftpgrabber will download into nirvana (the files arn't there) and don't inform the user about this (before start downloading of course)!
Comment 1 Jernej Kos 2007-04-01 21:45:23 UTC
SVN commit 648973 by kostko:

Abort file transfer when local open operation fails.

BUG: 141989

 M  +25 -3     ftpsocket.cpp  


--- trunk/extragear/network/kftpgrabber/src/engine/ftpsocket.cpp #648972:648973
@@ -682,13 +682,21 @@
         case SentRest: {
           if (!socket()->isResponse("2") && !socket()->isResponse("3")) {
             socket()->setConfig("feat.rest", 0);
-            
             socket()->getTransferFile()->close();
             
+            bool ok;
+            
             if (socket()->getPreviousCommand() == Commands::CmdGet)
-              socket()->getTransferFile()->open(IO_WriteOnly | IO_Truncate);
+              ok = socket()->getTransferFile()->open(IO_WriteOnly | IO_Truncate);
             else
-              socket()->getTransferFile()->open(IO_ReadOnly);
+              ok = socket()->getTransferFile()->open(IO_ReadOnly);
+            
+            // Check if there was a problem opening the file
+            if (!ok) {
+              socket()->emitError(FileOpenFailed);
+              socket()->resetCommandClass(Failed);
+              return;
+            }
           }
           
           // We have sent REST, now send the data command
@@ -1503,6 +1511,13 @@
             socket()->getTransferFile()->open(IO_WriteOnly | IO_Truncate);
           }
           
+          // Check if there was a problem opening the file
+          if (!socket()->getTransferFile()->isOpen()) {
+            socket()->emitError(FileOpenFailed);
+            socket()->resetCommandClass(Failed);
+            return;
+          }
+          
           // First we have to initialize the data connection, another class will
           // do this for us, so we just add it to the command chain
           socket()->setConfig("params.data_type", KFTPCore::Config::self()->ftpMode(sourceFile.path()));
@@ -1755,6 +1770,13 @@
             socket()->getTransferFile()->open(IO_ReadOnly);
           }
           
+          // Check if there was a problem opening the file
+          if (!socket()->getTransferFile()->isOpen()) {
+            socket()->emitError(FileOpenFailed);
+            socket()->resetCommandClass(Failed);
+            return;
+          }
+          
           // First we have to initialize the data connection, another class will
           // do this for us, so we just add it to the command chain
           socket()->setConfig("params.data_type", KFTPCore::Config::self()->ftpMode(destinationFile.path()));