Do not allow two different apps to have the same autostart-desktop file

Bug #2013242 reported by Marco Trevisan (Treviño)
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
New
Undecided
Unassigned

Bug Description

We had a bug in ubuntu-software where the same desktop file was used as an autostart script, this was causing snapd to always launch the desktop file as the wrong application.

This was the wrong snapcraft.yaml file:
 - https://gitlab.gnome.org/Community/Ubuntu/gnome-software/-/blob/eb26457f1/snap/snapcraft.yaml#L55-78

In fact, as per: https://github.com/snapcore/snapd/blob/6b29eb8f/usersession/autostart/autostart.go#L184-L188 the application binary used for auto-start is automatically computed by snapd, but at the same time the first app matching the desktop-id (or well, in this case its basename) is picked: https://github.com/snapcore/snapd/blob/6b29eb8f/usersession/autostart/autostart.go#L159-L165

So, snapcraft should use a stronger check to ensure that a desktop-id is not shared by multiple auto-start entries for different apps, otherwise snapd will not be able to launch the correct application.

Snapd could also do some stronger checks, based on the exec file, but that would make its logic more complex.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

This is what was happening at snapd level (adding more debug):

tool_linux.go:93: DEBUG: snap (at "/snap/core/current") is older ("2.58.3") than distribution package ("2.58.3+23.04ubuntu1")
autostart.go:261: DEBUG: autostart desktop file ubuntu-software-service.desktop
autostart.go:269: DEBUG: snap name: "snap-store"
autostart.go:161: DEBUG: Autostart desktop file is ubuntu-software-service.desktop, matching ubuntu-software-service.desktop (snap-store . usr/bin/snap-store)
autostart.go:179: DEBUG: exec line: snap-store.ubuntu-software --gapplication-service
autostart.go:196: DEBUG: Command to launch is /snap/bin/snap-store --gapplication-service

While in one hacked version of snapd, where we do not break at the first desktop file and we've more debugging bits:

tool_linux.go:93: DEBUG: snap (at "/snap/core/current") is older ("2.58.3") than distribution package ("2.58.3+23.04ubuntu1")
autostart.go:261: DEBUG: autostart desktop file ubuntu-software-service.desktop
autostart.go:269: DEBUG: snap name: "snap-store"
autostart.go:161: DEBUG: Autostart desktop file is ubuntu-software-service.desktop, matching ubuntu-software-service.desktop (snap-store . usr/bin/snap-store)
autostart.go:161: DEBUG: Autostart desktop file is ubuntu-software-service.desktop, matching ubuntu-software-service.desktop (ubuntu-software . usr/bin/snap-store)
autostart.go:161: DEBUG: Autostart desktop file is , matching ubuntu-software-service.desktop (ubuntu-software-local-file . usr/bin/snap-store)
autostart.go:179: DEBUG: exec line: snap-store.ubuntu-software --gapplication-service
autostart.go:196: DEBUG: Command to launch is /snap/bin/snap-store.ubuntu-software --gapplication-service

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.