Re-add .desktop file custom icons [PATCH]

Michael Pyne mpyne at purinchu.net
Fri May 29 03:17:35 BST 2009


Hi all,

I've heard that people would actually really rather have custom icons back 
even for untrusted icons in a few useful situations.

For instance, initially with a new KDE 4.3 desktop the previously working 
desktop icons now will show that one-time annoying dialog.  But in addition 
they also just show a generic icon instead of their custom icon, making it 
difficult to tell what program you wanted to start on a desktop full of generic 
"exec" type icons (until you've run all the programs at least once, that is).

So I've thought about it a bit more and decided it would probably be a better 
idea to leave the custom icon but simply denote that there is something 
possibly fishy about it.  We already have "emblem" infrastructure for just this 
kind of thing, so the following patch converts the untrusted custom icon case 
into a untrusted emblem case.  Note the reason we don't want to show custom 
icons is to avoid maliciously downloaded .desktop files from showing some 
innocuous icon (such as the image/jpeg icon) even though the .desktop file is 
executable.

One comment I'll get out of the way is that the KIconLoader documentation 
quite clearly states that the "emblem-" prefix for a file name is implied, which 
means I should only have to add an overlay of "important".  This doesn't 
actually work however, which is probably a separate issue we need to address 
altogether.

The other comment I have is that emblems don't work at all when file previews 
are present for the specific file type, so if you don't see it, ensure that 
you've turned off previews.

As a reminder, "untrusted" .desktop files are those files which can execute code 
but are not themselves executable (i.e. no +x bit).

Regards,
 - Michael Pyne

Index: kio/kio/kfileitem.cpp                
===================================================================
--- kio/kio/kfileitem.cpp       (revision 973868)                  
+++ kio/kio/kfileitem.cpp       (working copy)                     
@@ -761,9 +761,6 @@                                                
                 }
             }
         }
-    } else if ( group.hasKey( "Exec" ) && 
!KDesktopFile::isAuthorizedDesktopFile( path ) ) {
-        // Disable custom icons for untrusted executables
-        return QString("application-x-desktop");
     }
     return icon;
 }
@@ -813,6 +810,17 @@
         names.append("object-locked");
     }

+    if ( isDesktopFile() ) {
+        KDesktopFile cfg( localPath() );
+        const KConfigGroup group = cfg.desktopGroup();
+
+        // Add a warning emblem if this is an executable desktop file
+        // which is untrusted.
+        if ( group.hasKey( "Exec" ) && 
!KDesktopFile::isAuthorizedDesktopFile( localPath() ) ) {
+            names.append( "emblem-important" );
+        }
+    }
+
     if ( isHidden() ) {
         names.append("hidden");
     }

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20090528/fe41cc89/attachment.sig>


More information about the kde-core-devel mailing list