Relative paths in .desktop, .service files' Exec= lines
Michal Suchanek
hramrach at gmail.com
Thu Jun 23 18:10:33 UTC 2016
On 23 June 2016 at 19:54, Simon McVittie <simon.mcvittie at collabora.co.uk> wrote:
> On 23/06/16 17:53, Allison Lortie wrote:
>> On Mon, Jun 20, 2016, at 13:24, Simon McVittie wrote:
>> On the other hand, what we are doing here very much might break the
>> previously working behaviour of making symlinks from
>> /usr/share/applications into the user's home directory.
>
> Right, that's a valid concern.
>
>> On the other other hand, if we follow this all the way down the rabbit
>> hole, we may get into weird situations whereby we're canonicalising
>> symlinks in situations where /usr is a symlink to /mnt/usr or something
>> equally awful, in which case we might end up at the wrong result.
>
> Indeed. I specifically don't want to do that.
>
>> For
>> that reason, I think we should limit any resolution step here to direct
>> inspection of the desktop file in question for being a symlink, itself,
>> and not attempt a full canonicalisation.
>
> OK. So are you thinking of something like this pseudocode?
>
> path = $HOME/Desktop/dconf-editor.desktop # or something
>
> data = load(path)
> working_directory = data["Path"]
> argv = split(data["Exec"])
>
> if argv[0] is absolute:
> chdir(working_directory)
> execv(argv[0], argv)
> else if argv[0] contains a path separator:
> if lstat(path) says it's a symlink:
> link_target = readlink(path)
> # assume join() is syntax-only manipulation like
> # Python os.path.join, and does not look at the disk
> reference = join(dirname(path), link_target)
This is a bit fishy. Link target may be absolute or relative path.
You can (ab)use this to your advantage, too.
Typically the desktop symlink will be absolute to / and desktop file
linking as part of installation will be typically relative.
Thanks
Michal
More information about the xdg
mailing list