Hi all,


I've implemented the auto-exec-bit-ifying of .desktop files in KRun and made the changes suggested in the last couple of threads, including using owned-by-root as an exception as originally discussed instead of merely "not writable by user".


Currently the work is in 3 patches (all attached):


The first patch changes KDesktopFile::isAuthorizedDesktopFile() to include the extra restrictions that we're placing on .desktop files. This should be applied first as the remaining patches both require this change.


The second path implements security by not allowing klauncher to launch a .desktop file that doesn't meet the criteria given by KDesktopFile::isAuthorizedDesktopFile() (a fairly large change from my first submission but all that's happened is the logic is defined in KDesktopFile instead of being duplicated)


The third patch is against KRun, and implements the auto +x. This _needs review_, it was basically all written today after I got home from work (which included running 5K in shorts while it was 1 C outside so it was a rough day ;)


The idea is pop up a nice dialog [1] giving the user a readable description of what the problem is. A Details button is supposed to be included which contains the Exec= line but isn't working for some reason. Also the amount of text buys us into the dreaded Qt layout vs. X11 bug which I've tried to minimize the effects of. On that note, I'm game to better ways to phrase this dialog, it doesn't seem efficient somehow.


Assuming the user clicks on continue the file is made executable by doing 2 things:


1. Add a #!/usr/bin/env xdg-open (if #! is not already present)
- This is done by using KSaveFile, by writing the header and then dumping the .desktop file contents below it. I'm not really happy about manually moving bytes around (especially as v1 in my testing today had an infinite loop) but I don't trust readAll()/write() for library code. Please look at this to make sure I've done it right.


2. chmod u+x /path/to/foo.desktop (this was simpler ;)


Assuming everything proceeded swimmingly the .desktop file is then immediately launched.


Is there anything I'm missing here now? Please let me know, otherwise I'd like to know if there are objections to committing on Sunday.


Regards,
- Michael Pyne


[1] http://purinchu.net/dumping-ground/krun2.png