diff options
Diffstat (limited to 'kcontrol/ebrowsing/plugins')
-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. |