Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong handling of desktop entries with space in name #9834

Open
parulin opened this issue Mar 10, 2025 · 0 comments
Open

Wrong handling of desktop entries with space in name #9834

parulin opened this issue Mar 10, 2025 · 0 comments
Labels
affects-4.2 This issue affects Qubes OS 4.2. C: app menu The primary user-facing GUI application menu in Qubes OS C: manager/widget needs diagnosis Requires technical diagnosis from developer. Replace with "diagnosed" or remove if otherwise closed. P: default Priority: default. Default priority for new issues, to be replaced given sufficient information.

Comments

@parulin
Copy link

parulin commented Mar 10, 2025

Qubes OS release

Qubes OS 4.2

Brief summary

In a qube, a user creates a desktop entry with a space inside the name, like xfce terminal.desktop. The desktop entry is available in the settings of the qube but the resulting desktop entry in dom0 is truncated and thus, failing.

Moreover, trying to run /etc/qubes-rpc/StartApp with the name result in unclear error messages.

Steps to reproduce

  1. In a qube (let's call it test-desktop-space), create a basic desktop entry, called $HOME/.local/share/applications/xfce terminal.desktop with this content:

    [Desktop Entry]
    Name=A TEST WITH SPACE
    Exec=xfce4-terminal
    Type=Application
    
  2. In dom0, try to get available entries:

    # in dom0
    qvm-sync-appmenus test-desktop-space
    qvm-appmenus --get-available --i-understand-format-is-unstable test-desktop-space | grep SPACE
    terminal.desktop - A TEST WITH SPACE
    

    Notice the wrong name. Now set the whitelist, to check the desktop entry created in dom0

    # in dom0
    qvm-appmenus --get-available --i-understand-format-is-unstable test-desktop-space | grep SPACE | qvm-appmenus --set-whitelist - test-desktop-space
    cat ~/.local/share/applications/org.qubes-os.vm._test_ddesktop_dspace.terminal.desktop
    
  3. In the qube, try to manually use /etc/qubes-rpc/qubes.StartApp:

    # in test-desktop-space qube
    /etc/qubes-rpc/qubes.StartApp xfce terminal
    This service requires an argument
    

    Now, while using quotes, the python script ends with a traceback error:

    # in test-desktop-space qube
    /etc/qubes-rpc/qubes.StartApp "xfce terminal"
    Traceback (most recent call last):
      File "/etc/qubes-rpc/qubes.StartApp", line 39, in <module>
        main(sys.argv)
      File "/etc/qubes-rpc/qubes.StartApp", line 15, in main
        if qubes_db.read('/qubes-service/app-dispvm.' + arg) is not None:
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    qubesdb.Error: (71, 'Protocol error')
    

Expected behavior

The desktop entry spec doesn't allow spaces in desktop entry names, so it seems reasonable to fail. Nothing should be visible while trying to update the appmenu.

qubes.StartApp should output only error messages with clear reasons.

Actual behavior

Nothing in dom0, obscure errors in the qube.

Additional information

Changing line 13 of qubes.StartApp by this seems enough as for a non-quoted argument

        print('This service requires one unique argument', file=sys.stderr)

It's possible to add a basic check on line 17, like this:

    if " " in arg:
        print('This service requires an argument without spaces', file=sys.stderr)
        sys.exit(1)

But maybe it's better to handle this inside qubesdb?

In /etc/qubes-rpc/qubes.GetAppmenus, replacing the find command by this could help:

find . -regex '.*/[-_.A-Za-z0-9]+\.desktop'

But still, the correct handling should happen in dom0. I tried to change the line 169 in /usr/lib/python3.11/site-packages/qubesappmenus/receive.py, in order to use re.match instead of re.search but this may be very inefficient or naive?

        untrusted_m = line_rx.match(untrusted_line.split('/')[-1])
@parulin parulin added the P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. label Mar 10, 2025
@andrewdavidwong andrewdavidwong added C: manager/widget needs diagnosis Requires technical diagnosis from developer. Replace with "diagnosed" or remove if otherwise closed. C: app menu The primary user-facing GUI application menu in Qubes OS affects-4.2 This issue affects Qubes OS 4.2. labels Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.2 This issue affects Qubes OS 4.2. C: app menu The primary user-facing GUI application menu in Qubes OS C: manager/widget needs diagnosis Requires technical diagnosis from developer. Replace with "diagnosed" or remove if otherwise closed. P: default Priority: default. Default priority for new issues, to be replaced given sufficient information.
Projects
None yet
Development

No branches or pull requests

2 participants