Bug 105635 - xdg-desktop-menu uninstall /nonexistent/*.directory /nonexistent/*.desktop removes unrelated files
Summary: xdg-desktop-menu uninstall /nonexistent/*.directory /nonexistent/*.desktop re...
Alias: None
Product: Portland
Classification: Unclassified
Component: xdg-utils (show other bugs)
Version: unspecified
Hardware: All Linux (All)
: medium major
Assignee: Portland Bugs
QA Contact:
Depends on:
Reported: 2018-03-20 23:42 UTC by marmarek
Modified: 2019-02-16 13:39 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Description marmarek 2018-03-20 23:42:27 UTC
Providing arguments to xdg-desktop-menu with wildcards (not expanded by shell - either because of quoting, or missing files) expand them internally, but ignoring directory part of the argument. This results in operation on unrelated files.

The most extreme case is: xdg-desktop-menu uninstall /nonexistent/*.directory /nonexistent/*.desktop
This results in removing all files from /usr/share/desktop-directories and /usr/share/applications.
While this behavior could be expected (if documented!) for just "*.desktop" argument, certainly it isn't when there was a full path provided.

Looks like missing quoting here:

            for x in $xdg_dir $kde_dir $gnome_dir ; do
                rm -f $x/$basefile  # <- here

(this fragment appears twice in the script - once for directory files and once for desktop files)

Version: xdg-utils 1.1.1 (Fedora 26).

BTW I recommend running shellcheck on this (and other) script, it detects problems like this:
In /usr/bin/xdg-desktop-menu line 1411:
                rm -f $x/$basefile
                      ^-- SC2086: Double quote to prevent globbing and word splitting.
                         ^-- SC2086: Double quote to prevent globbing and word splitting.
Comment 1 GitLab Migration User 2019-02-16 13:39:54 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xdg/xdg-utils/issues/123.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.