syncthing-gtk creates autostart file with wrong bin

  • Done
  • quality assurance status badge
Details
3 participants
  • John Kehayias
  • Leo Famulari
  • Liliana Marie Prikler
Owner
unassigned
Submitted by
John Kehayias
Severity
normal
J
J
John Kehayias wrote on 24 Sep 2021 23:33
(name . bug-guix@gnu.org)(address . bug-guix@gnu.org)
xULpkaOJk5Q64f48ce9xy1griAdpvLDSdgaTcyiZyHYK2xOZWIcYQG9VAQlmPfp2n4MDehVPHbUH4wjEebJVQ5C-UrF7RqOYVs7ucq5EECQ=@protonmail.com
Hello,

syncthing-gtk has an option to enable autostart, which it does by creating the .desktop file in ~/.config/autostart However, this has the wrong exec line, getting the -real script instead of syncthing-gtk. This won't work as it needs to be run as syncthing-gtk. Namely, it produces:

Exec=/gnu/store/vf5h9jqhq40x8r46afaa0jgw7awg1361-syncthing-gtk-0.9.4.4-1.c46fbd8/bin/.syncthing-gtk-real

Instead of

Exec=/gnu/store/vf5h9jqhq40x8r46afaa0jgw7awg1361-syncthing-gtk-0.9.4.4-1.c46fbd8/bin/syncthing-gtk

This is due to syncthing-gtk getting its executable name to write to the .desktop file in get_executable(): https://salsa.debian.org/debian/syncthing-gtk/-/blob/master/syncthing_gtk/tools.py#L409where due to wrapping it will find something that won't work when run directly.

How should this be solved in Guix? Should we patch this part of the code to explicitly rewrite the path to have "syncthing-gtk" instead of ".syncthing-gtk-real"? Related would be the discussion at https://lists.gnu.org/r/guix-devel/2021-09/msg00088.htmlwhich I will message separately.

Thanks,
John
L
L
Liliana Marie Prikler wrote on 25 Sep 2021 00:55
33a689c52f5896213b480e01fc3498a26877b392.camel@gmail.com
Hi,

Am Freitag, den 24.09.2021, 21:33 +0000 schrieb John Kehayias:
Toggle quote (27 lines)
> Hello,
>
> syncthing-gtk has an option to enable autostart, which it does by
> creating the .desktop file in ~/.config/autostart However, this has
> the wrong exec line, getting the -real script instead of syncthing-
> gtk. This won't work as it needs to be run as syncthing-gtk. Namely,
> it produces:
>
> Exec=/gnu/store/vf5h9jqhq40x8r46afaa0jgw7awg1361-syncthing-gtk-
> 0.9.4.4-1.c46fbd8/bin/.syncthing-gtk-real
>
> Instead of
>
> Exec=/gnu/store/vf5h9jqhq40x8r46afaa0jgw7awg1361-syncthing-gtk-
> 0.9.4.4-1.c46fbd8/bin/syncthing-gtk
>
> This is due to syncthing-gtk getting its executable name to write to
> the .desktop file in get_executable():
> https://salsa.debian.org/debian/syncthing-gtk/-/blob/master/syncthing_gtk/tools.py#L409
> where due to wrapping it will find something that won't work when run
> directly.
>
> How should this be solved in Guix? Should we patch this part of the
> code to explicitly rewrite the path to have "syncthing-gtk" instead
> of ".syncthing-gtk-real"? Related would be the discussion at
> https://lists.gnu.org/r/guix-devel/2021-09/msg00088.html which I will
> message separately.
We should patch syncthing to not write a desktop file at all. Note how
even if the binary name itself was correct, syncthing would link
directly into the store, potentially producing a stale desktop file
that breaks with garbage collection.

Cheers
L
L
Leo Famulari wrote on 25 Sep 2021 01:15
Re: bug#50789: syncthing-gtk creates autostart file with wrong bin
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
YU5cJ+yKFhnSKPVr@jasmine.lan
On Sat, Sep 25, 2021 at 12:55:56AM +0200, Liliana Marie Prikler wrote:
Toggle quote (5 lines)
> We should patch syncthing to not write a desktop file at all. Note how
> even if the binary name itself was correct, syncthing would link
> directly into the store, potentially producing a stale desktop file
> that breaks with garbage collection.

Maybe we could make the desktop file execute a path like
"$HOME/.guix-profile/bin/syncthing-gtk"?
J
J
John Kehayias wrote on 25 Sep 2021 02:45
(name . Leo Famulari)(address . leo@famulari.name)
s4t48VbgNFk4NqUZBTNztiobk-4O3o5JR5yAY6e5r764ws_VairCTVbZ6B8ET9k2QhcIFLT68CHpLphYrArM7oRvEPJsIzitqhdyj3iAHoY=@protonmail.com
Hi Leo, Liliana, et al,

??????? Original Message ???????

On Friday, September 24th, 2021 at 7:15 PM, Leo Famulari wrote:

Toggle quote (4 lines)
> Maybe we could make the desktop file execute a path like
>
> "$HOME/.guix-profile/bin/syncthing-gtk"?

Hmm...these are both good points. And I think I may have run into stale files produced by some programs due to this. Actually, checking now, I see the same for redshift-gtk in the autostart .desktop file it makes (a /gnu/store link). So this is perhaps more common when programs create files like this.

I think there are a few possibilities and assumptions that go with them.

1. Rely on $PATH so that it can just be Exec=syncthing-gtk This is pretty common (non-Guix, at least) I think, but is an assumption. Seems safe for a program like this, but ambiguous, especially with Guix allowing multiple of the same-named bin to be installed at the same time.

2. Something like what was suggested by Leo, but we have to consider different profiles. Is that easy to account for in a build time patch? In my case it ends up $HOME/.config/guix/profiles/desktop/desktop/bin/syncthing-gtk Though I guess this happens at install. Perhaps the Python code can be patched to make something like this, based on its runtime path.

3. Remove the ability for these types of files to be created, as Liliana suggested. I think this is drastic though, changing the expected behavior in programs and difficult to enforce evenly. The point raised is important though, that direct /gnu/store links shouldn't be used in such a way.

Perhaps there are others. What do we currently do in Guix, or what would be preferred? From a user standpoint, I'd expect creating an autostart file (for instance) to work as created and to continue to do so.

John
L
L
Liliana Marie Prikler wrote on 25 Sep 2021 09:02
(address . 50789@debbugs.gnu.org)
e47cb526c42df7fedc22516bfced1c0a998ccc3f.camel@gmail.com
Hi John,

Am Samstag, den 25.09.2021, 00:45 +0000 schrieb John Kehayias:
Toggle quote (12 lines)
> [...]
>
> 3. Remove the ability for these types of files to be created, as
> Liliana suggested. I think this is drastic though, changing the
> expected behavior in programs and difficult to enforce evenly. The
> point raised is important though, that direct /gnu/store links
> shouldn't be used in such a way.
>
> Perhaps there are others. What do we currently do in Guix, or what
> would be preferred? From a user standpoint, I'd expect creating an
> autostart file (for instance) to work as created and to continue to
> do so.
I think the answer to that one is fairly simple. Guix should provide a
mechanism to generate/link autostart services, ideally via (guix home),
which will be upstreamed soon (idk if it has one such service already,
just throwing it out there). However, the preferred solution is to not
bother with autostart at all and instead use shepherd to manage user
services – there is a tradeoff to be made between those management
styles somewhere.

Cheers
J
J
John Kehayias wrote on 27 Sep 2021 21:04
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
6tbnn-VZChCdcqVZHxISlaQa_4plEwmzKlx8VjXPAR1Eb9br1nNHHryw7o0dgx2o8fVGVVtvNGVeZDiGasd1gqt41dwD7RjULWnR2trcUCE=@protonmail.com
Hi everyone,

??????? Original Message ???????

On Saturday, September 25th, 2021 at 3:02 AM, Liliana Marie Prikler wrote:

Toggle quote (9 lines)
> I think the answer to that one is fairly simple. Guix should provide a
> mechanism to generate/link autostart services, ideally via (guix home),
> which will be upstreamed soon (idk if it has one such service already,
> just throwing it out there). However, the preferred solution is to not
> bother with autostart at all and instead use shepherd to manage user
> services – there is a tradeoff to be made between those management
> styles somewhere.
>

I agree we can have a better "Guix way" of doing autostart, documented with examples (perhaps a Cookbook chapter on Desktop usage of Guix). User run shepherd works, at least for some basic background services I run. I don't think it is as documented or as fleshed out as XDG autostart stuff. I too am interested in guix home (just merged!) and will take a look at that.

But back to the matter at hand. Medium to long-term I support better Guix services for autostart, but that doesn't address the problem of having packages run as intended by upstream, at least with reasonable expectations. I think this is expected and reasonable behavior, that a program can create a proper .desktop file in Guix.

Looking at another non-Guix system, the autostart files I have in ~/.confg/autostart mostly (syncthing-gtk being the main exception) use just

Exec=program-name

I see this mostly true for /etc/xdg/autostart as well (non-Guix system). So I think this is an easy and typical behavior we can implement. In this case patching syncthing-gtk to produce Exec=syncthing-gtk. Perhaps upstream would consider it as well, unless they have good reason for a full path here, as opposed to other programs. (Upstream is a bit quiet in activity though.)

What do we think?

John
L
L
Liliana Marie Prikler wrote on 27 Sep 2021 23:23
(name . John Kehayias)(address . john.kehayias@protonmail.com)
0ae4d2bfcce16f79680321817ac9e55a380dd0bd.camel@gmail.com
Hi,

Am Montag, den 27.09.2021, 19:04 +0000 schrieb John Kehayias:
Toggle quote (7 lines)
> [...]
>
> But back to the matter at hand. Medium to long-term I support better
> Guix services for autostart, but that doesn't address the problem of
> having packages run as intended by upstream, at least with reasonable
> expectations. I think this is expected and reasonable behavior, that
> a program can create a proper .desktop file in Guix.
Unless you are running a dedicated desktop file/autostart editor like
alacarte or whatever gnome-tweaks has going for it, writing to
.config/autostart is not reasonable behaviour.

Toggle quote (5 lines)
> Looking at another non-Guix system, the autostart files I have
> in ~/.confg/autostart mostly (syncthing-gtk being the main
> exception) use just
>
> Exec=program-name
The "full path" desktop files used in Guix do have some advantages.
Also, on other distros when using stuff like systemd in a similar
manner to shepherd, you have full paths again.

Toggle quote (8 lines)
> I see this mostly true for /etc/xdg/autostart as well (non-Guix
> system). So I think this is an easy and typical behavior we can
> implement. In this case patching syncthing-gtk to produce
> Exec=syncthing-gtk. Perhaps upstream would consider it as well,
> unless they have good reason for a full path here, as opposed to
> other programs. (Upstream is a bit quiet in activity though.)
>
> What do we think?
I think upstream as good reasons to use full paths, e.g. to prevent the
wrong syncthing from being used when there are two in /usr and
/usr/local. Were Guix to police upstream on this matter, the decision
would clearly be to make this feature optional at the click of a button
– and not one that annoyingly pops up if Icecat is not your default
browser, if you understand what I'm trying to say.

Regards
J
J
John Kehayias wrote on 30 Sep 2021 21:29
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
FmxWeSV7EMhnmSIkVby_0QbeESPcBUPpZbJoMR_SZ0i7RBF5O9FmIlfcq352Jh168O4tswcXhSuSdMBM55Bzqbe2kDsNKnmepbBSPpbuYlo=@protonmail.com
Hello,

??????? Original Message ???????

On Monday, September 27th, 2021 at 5:23 PM, Liliana Marie Prikler wrote:

Toggle quote (17 lines)
> Hi,
>
> Am Montag, den 27.09.2021, 19:04 +0000 schrieb John Kehayias:
>
> > [...]
> >
> > But back to the matter at hand. Medium to long-term I support better
> > Guix services for autostart, but that doesn't address the problem of
> > having packages run as intended by upstream, at least with reasonable
> > expectations. I think this is expected and reasonable behavior, that
> > a program can create a proper .desktop file in Guix.
>
> Unless you are running a dedicated desktop file/autostart editor like
> alacarte or whatever gnome-tweaks has going for it, writing to
> .config/autostart is not reasonable behaviour.
>

Sorry, I don't understand this comment. I think this is just the XDG specification, user autorun desktop files go in ~/.config/autostart. If a program wants to autostart (e.g. user enables the option) this I think is the expected and conformant behavior. I see many programs doing this (and is where you'd write if you want to change the per-user behavior of something in the system autostart, which might also be relevant). Anyway, we are getting sidetracked and that's not important for the matter at hand, I don't think.

Toggle quote (27 lines)
> > Looking at another non-Guix system, the autostart files I have
> > in ~/.confg/autostart mostly (syncthing-gtk being the main
> > exception) use just
> >
> > Exec=program-name
>
> The "full path" desktop files used in Guix do have some advantages.
> Also, on other distros when using stuff like systemd in a similar
> manner to shepherd, you have full paths again.
>
> > I see this mostly true for /etc/xdg/autostart as well (non-Guix
> > system). So I think this is an easy and typical behavior we can
> > implement. In this case patching syncthing-gtk to produce
> > Exec=syncthing-gtk. Perhaps upstream would consider it as well,
> > unless they have good reason for a full path here, as opposed to
> > other programs. (Upstream is a bit quiet in activity though.)
> >
> > What do we think?
>
> I think upstream as good reasons to use full paths, e.g. to prevent the
> wrong syncthing from being used when there are two in /usr and
> /usr/local. Were Guix to police upstream on this matter, the decision
> would clearly be to make this feature optional at the click of a button
> – and not one that annoyingly pops up if Icecat is not your default
> browser, if you understand what I'm trying to say.
>

So then I think we end up wanting to patch syncthing-gtk to create something like Exec=/path/to/profile/bin/syncthing-gtk I'm not sure off the top of my head how to do that (without ending up as it currently does with the direct /gnu/store/.../.syncthing-gtk-real since that is what the program will see as the origin of the process). I can take a look if no one has the Python incantation ready. Or else default to using $PATH and/or which; probably the right thing most of the time but I'm not sure.

John
L
L
Liliana Marie Prikler wrote on 30 Sep 2021 22:00
(name . John Kehayias)(address . john.kehayias@protonmail.com)
d1454f05fb7085fd3cb462045bbea3e6c436c59d.camel@gmail.com
Hi,

Am Donnerstag, den 30.09.2021, 19:29 +0000 schrieb John Kehayias:
Toggle quote (33 lines)
> Hello,
>
> ??????? Original Message ???????
>
> On Monday, September 27th, 2021 at 5:23 PM, Liliana Marie Prikler
> wrote:
>
> > Hi,
> >
> > Am Montag, den 27.09.2021, 19:04 +0000 schrieb John Kehayias:
> >
> > > [...]
> > >
> > > But back to the matter at hand. Medium to long-term I support
> > > better Guix services for autostart, but that doesn't address the
> > > problem of having packages run as intended by upstream, at least
> > > with reasonable expectations. I think this is expected and
> > > reasonable behavior, that a program can create a proper .desktop
> > > file in Guix.
> >
> > Unless you are running a dedicated desktop file/autostart editor
> > like alacarte or whatever gnome-tweaks has going for it, writing to
> > .config/autostart is not reasonable behaviour.
> >
>
> Sorry, I don't understand this comment. I think this is just the XDG
> specification, user autorun desktop files go in ~/.config/autostart.
> If a program wants to autostart (e.g. user enables the option) this I
> think is the expected and conformant behavior. I see many programs
> doing this (and is where you'd write if you want to change the per-
> user behavior of something in the system autostart, which might also
> be relevant). Anyway, we are getting sidetracked and that's not
> important for the matter at hand, I don't think.
Just because many programs do this doesn't mean they have a good
rationale to do so. Managing autostarts joins the ranks of having an
updater for the program itself and messing with context menus or
mimetype associations. This is not the Microsoft OS, we have better
ways of managing things here.

Toggle quote (36 lines)
> > > Looking at another non-Guix system, the autostart files I have
> > > in ~/.confg/autostart mostly (syncthing-gtk being the main
> > > exception) use just
> > >
> > > Exec=program-name
> >
> > The "full path" desktop files used in Guix do have some advantages.
> > Also, on other distros when using stuff like systemd in a similar
> > manner to shepherd, you have full paths again.
> >
> > > I see this mostly true for /etc/xdg/autostart as well (non-Guix
> > > system). So I think this is an easy and typical behavior we can
> > > implement. In this case patching syncthing-gtk to produce
> > > Exec=syncthing-gtk. Perhaps upstream would consider it as well,
> > > unless they have good reason for a full path here, as opposed to
> > > other programs. (Upstream is a bit quiet in activity though.)
> > >
> > > What do we think?
> >
> > I think upstream as good reasons to use full paths, e.g. to prevent
> > the wrong syncthing from being used when there are two in /usr and
> > /usr/local. Were Guix to police upstream on this matter, the
> > decision would clearly be to make this feature optional at the
> > click of a button – and not one that annoyingly pops up if Icecat
> > is not your default browser, if you understand what I'm trying to
> > say.
> >
>
> So then I think we end up wanting to patch syncthing-gtk to create
> something like Exec=/path/to/profile/bin/syncthing-gtk I'm not sure
> off the top of my head how to do that (without ending up as it
> currently does with the direct /gnu/store/.../.syncthing-gtk-real
> since that is what the program will see as the origin of the
> process). I can take a look if no one has the Python incantation
> ready. Or else default to using $PATH and/or which; probably the
> right thing most of the time but I'm not sure.
As I stated initially you could hardcode the store path to syncthing-
gtk in its stead but it's still a store path in the end. It must go
stale by design. The only reasonable thing is to not install the file
and instead give users the tools to do so on their own.

Regards
J
J
John Kehayias wrote on 30 Sep 2021 22:13
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
17bI1MfgO4sTMxxomP-QgHLKp0qztdZkexN8PYWs-md9elisnhlMWS8ObCnD3Uw1HFhbBgwbqf_SlO8YUB0oX5KEULytAdtf_3su5KstMyE=@protonmail.com
??????? Original Message ???????

On Thursday, September 30th, 2021 at 4:00 PM, Liliana Marie Prikler wrote:

Toggle quote (7 lines)
>
> As I stated initially you could hardcode the store path to syncthing-
> gtk in its stead but it's still a store path in the end. It must go
> stale by design. The only reasonable thing is to not install the file
> and instead give users the tools to do so on their own.
>

For a medium to long-term solution, what would you advocate for? A note in a package's description that they should see the manual or cookbook for how to autostart this program if they want (since it will show up in the preferences menu)? Of course, we'll need that documentation first :) Maybe an example piece of code for using Shepherd to start, or guix home (I still need to look at that)? Perhaps this should be raised more generally in the devel list to be consistent in Guix, since this won't be the only one.

In the meantime, I'll try to find if getting the profile to bin path is not too tricky, if not at least make it so the path it does use points to syncthing-gtk and not .syncthing-gtk-real, since that is incorrect in every way.
L
L
Liliana Marie Prikler wrote on 1 Oct 2021 09:44
(name . John Kehayias)(address . john.kehayias@protonmail.com)
121bd5a47b78af306a887b5af05e17ebc9efea1d.camel@gmail.com
Hi,

Am Donnerstag, den 30.09.2021, 20:13 +0000 schrieb John Kehayias:
Toggle quote (20 lines)
> ??????? Original Message ???????
>
> On Thursday, September 30th, 2021 at 4:00 PM, Liliana Marie Prikler
> wrote:
>
> > As I stated initially you could hardcode the store path to
> > syncthing-gtk in its stead but it's still a store path in the end.
> > It must go stale by design. The only reasonable thing is to not
> > install the file and instead give users the tools to do so on their
> > own.
> >
>
> For a medium to long-term solution, what would you advocate for? A
> note in a package's description that they should see the manual or
> cookbook for how to autostart this program if they want (since it
> will show up in the preferences menu)? Of course, we'll need that
> documentation first :) Maybe an example piece of code for using
> Shepherd to start, or guix home (I still need to look at that)?
> Perhaps this should be raised more generally in the devel list to be
> consistent in Guix, since this won't be the only one.
Long-term I'd advocate having an autostart service for putting .desktop
files into the autostart folder, documented in the home-services
section with the concrete example of syncthing-gtk perhaps there or in
the Cookbook. We shouldn't change the package description, we don't do
that for packages we need at the system level (within or without a
service).

Toggle quote (4 lines)
> In the meantime, I'll try to find if getting the profile to bin path
> is not too tricky, if not at least make it so the path it does use
> points to syncthing-gtk and not .syncthing-gtk-real, since that is
> incorrect in every way.
The string you need to replace is "get_executable\\(\\)" in
syncthing_gtk/uisettingsdialog.py

Happy hacking
J
J
John Kehayias wrote on 5 Jan 2022 20:31
(name . Leo Famulari)(address . leo@famulari.name)
GCUW_O1aooNdgl3osOskwj4TjtmGWs4-cSwJ_8Qh3gbZmRS1AOhB37JUUo-fn9_gyJjTpc5RrDV_ptFK6iLzOvd9PNGKUVGNzb13DOac1E0=@protonmail.com
Hello again,

I should have sent this here directly, but I just submitted a patch for this issue. I opted to just use a plain exec line of "syncthing-gtk". Please see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=53036

As we had discussed, it is not perfect, but it will work and won't break on a store path change. I think the chance of conflicting/multiple versions of syncthing-gtk is rare and not worth worrying about over this not working at all (syncthing-gtk is just a simple frontend to the web interface of the real syncthing, after all). We can work on a more robust autostart in Guix with guix home for a future system to wrangle all this better.

Thanks,
John
L
L
Leo Famulari wrote on 5 Jan 2022 22:13
(name . John Kehayias via Bug reports for GNU Guix)(address . bug-guix@gnu.org)(address . 50789-done@debbugs.gnu.org)
YdYJ9vtYJax8pi2/@jasmine.lan
On Fri, Sep 24, 2021 at 09:33:56PM +0000, John Kehayias via Bug reports for GNU Guix wrote:
Toggle quote (10 lines)
> Hello,
>
> syncthing-gtk has an option to enable autostart, which it does by creating the .desktop file in ~/.config/autostart However, this has the wrong exec line, getting the -real script instead of syncthing-gtk. This won't work as it needs to be run as syncthing-gtk. Namely, it produces:
>
> Exec=/gnu/store/vf5h9jqhq40x8r46afaa0jgw7awg1361-syncthing-gtk-0.9.4.4-1.c46fbd8/bin/.syncthing-gtk-real
>
> Instead of
>
> Exec=/gnu/store/vf5h9jqhq40x8r46afaa0jgw7awg1361-syncthing-gtk-0.9.4.4-1.c46fbd8/bin/syncthing-gtk

Fixed with commit c37559e81979232feee07aa1eb39faacb093c5ca
?
Your comment

This issue is archived.

To comment on this conversation send an email to 50789@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 50789
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch