Bug 74593 - kio/sftp: file permissions are not preserved but set to 0644 per default
Summary: kio/sftp: file permissions are not preserved but set to 0644 per default
Status: RESOLVED FIXED
Alias: None
Product: kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Lucas Fisher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-08 17:16 UTC by Daniel Franke
Modified: 2004-02-15 00:42 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 Daniel Franke 2004-02-08 17:16:59 UTC
Version:           3.2.0 (using KDE 3.2.0, SuSE)
Compiler:          gcc version 3.3 20030226 (prerelease) (SuSE Linux)
OS:          Linux (i686) release 2.4.20-4GB

konqueror window 1: sftp://user@anyhost:/any/directory
konqueror window 2: file://$HOME

drag'n'drop an executeable file from window 1 to window 2: file permissions are set from 755 to 644 ...
Comment 1 Dawit Alemayehu 2004-02-13 13:01:31 UTC
This is not a bug, but a security feature. It is also not specific to the sftp io-slave. If you copy executables from any remote protocol, the executable flag is always dropped on purpose to protect against malicious remote executions. You have to manually reset the executable flag. I am not sure if there is an option that you can set to circumvent this. Moving to general since the issue is not sftp specific...
Comment 2 Daniel Franke 2004-02-13 13:17:23 UTC
It's a rather odd behaviour since sftp (command-line) preserves the flags.
Think of copying an autoconf/automake project tree. Many executables, mixed with regular files. Restoring the flags by hand? Not if I can avoid it.
Comment 3 Dawit Alemayehu 2004-02-14 22:00:11 UTC
Ahhh... My pervious comment was wrong. The issue has nothing to do with security at all! It seems to be caused by what I think is an outdated assumption in KIO's code. Sent patch to kde-core for peer review...

Comment 4 Dawit Alemayehu 2004-02-15 00:42:27 UTC
CVS commit by adawit: 

- Preserve file premissions when copying from remote protocols that
  support listing. Fixes BR# 74593.

CCMAIL: 74593-done@bugs.kde.org


  M +1 -3      job.cpp   1.372


--- kdelibs/kio/kio/job.cpp  #1.371:1.372
@@ -2903,7 +2903,5 @@ void CopyJob::copyNextFile()
             // If source isn't local and target is local, we ignore the original permissions
             // Otherwise, files downloaded from HTTP end up with -r--r--r--
-            // But for files coming from TAR, we want to preserve permissions -> we use default perms only if from remote
-            // The real fix would be KProtocolInfo::inputType(protocol) == T_FILESYSTEM, but we can't access ksycoca from here !
-            bool remoteSource = !(*it).uSource.isLocalFile() && ((*it).uSource.protocol() != "tar"); // HACK
+            bool remoteSource = !KProtocolInfo::supportsListing((*it).uSource);
             int permissions = ( remoteSource && (*it).uDest.isLocalFile() ) ? -1 : (*it).permissions;
             KIO::FileCopyJob * copyJob = KIO::file_copy( (*it).uSource, (*it).uDest, permissions, bOverwrite, false, false/*no GUI*/ );