diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-10-13 17:58:50 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-10-13 17:58:50 +0000 |
commit | d9e84b4dc976d3dab53925ac26c024b218daabe3 (patch) | |
tree | 617482cd39a888e33f21200dfa97756e3109b04a /kcontrol/ebrowsing/plugins/shorturi | |
parent | 42c5401145434f3c2d73e224e35ef3f0826229f0 (diff) | |
download | tdebase-d9e84b4dc976d3dab53925ac26c024b218daabe3.tar.gz tdebase-d9e84b4dc976d3dab53925ac26c024b218daabe3.zip |
Fix detection of executable files by URI
This fixes data files being flagged as executable in the run dialog
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1258846 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kcontrol/ebrowsing/plugins/shorturi')
-rw-r--r-- | kcontrol/ebrowsing/plugins/shorturi/kshorturifilter.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/kcontrol/ebrowsing/plugins/shorturi/kshorturifilter.cpp b/kcontrol/ebrowsing/plugins/shorturi/kshorturifilter.cpp index bee6e99c4..fccaf6b55 100644 --- a/kcontrol/ebrowsing/plugins/shorturi/kshorturifilter.cpp +++ b/kcontrol/ebrowsing/plugins/shorturi/kshorturifilter.cpp @@ -392,10 +392,32 @@ bool KShortURIFilter::filterURI( KURIFilterData& data ) const bool isDir = S_ISDIR( buff.st_mode ); if( !isDir && access ( TQFile::encodeName(path).data(), X_OK) == 0 ) { - //kdDebug() << "Abs path to EXECUTABLE" << endl; - setFilteredURI( data, u ); - setURIType( data, KURIFilterData::EXECUTABLE ); - return true; + // ::access() is not always correct, especially on network file systems + // Verify that we actually have at least one execute permission bit set before flagging the file as executable... + struct stat buffer; + int status; + status = stat(TQFile::encodeName(path).data(), &buffer); + if (status == 0) { + bool is_executable = false; + int file_mode = ((buffer.st_mode & S_IRWXU) >> 6); // User + if (file_mode & 0x1) is_executable = true; + file_mode = file_mode + ((buffer.st_mode & S_IRWXG) >> 3); // Group + if (file_mode & 0x1) is_executable = true; + file_mode = file_mode + ((buffer.st_mode & S_IRWXO) >> 0); // Other + if (file_mode & 0x1) is_executable = true; + if (is_executable == true) { + //kdDebug() << "Abs path to EXECUTABLE" << endl; + setFilteredURI( data, u ); + setURIType( data, KURIFilterData::EXECUTABLE ); + return true; + } + } + else { + //kdDebug() << "Abs path to EXECUTABLE" << endl; + setFilteredURI( data, u ); + setURIType( data, KURIFilterData::EXECUTABLE ); + return true; + } } // Open "uri" as file:/xxx if it is a non-executable local resource. |