How to "forget" a manual disconnect of an auto-connected interface

So, I did this sequence of steps:

  1. snap install arduino which auto-connects to raw-usb.
  2. snap disconnect arduino raw-usb
  3. snap remove arduino --purge
  4. snap install arduino

What I expect is that the arduino snap is auto-connected to raw-usb again. However, this does not seem to be the case:

$ snap connections arduino
Interface               Plug                     Slot                              Notes
content[gtk-2-engines]  arduino:gtk-2-engines    gtk2-common-themes:gtk-2-engines  -
content[gtk-2-themes]   arduino:gtk-2-themes     gtk-common-themes:gtk-2-themes    -
content[icon-themes]    arduino:icon-themes      gtk-common-themes:icon-themes     -
content[sound-themes]   arduino:sound-themes     gtk-common-themes:sound-themes    -
home                    arduino:home             :home                             -
network                 arduino:network          :network                          -
raw-usb                 arduino:raw-usb          -                                 -
removable-media         arduino:removable-media  -                                 -
serial-port             arduino:serial-port      -                                 -
unity7                  arduino:unity7           :unity7                           -
x11                     arduino:x11              :x11                              -

It seems like the manual disconnect is “remembered” even after removing a snap. Is this intended behavior? Is there any way to “forget” a previously manually removed auto-connection?

I found it very unexpected that it remembered my disconnection, especially after removing using the purge flag.

There is snap disconnect --forget for this purpose. Try running that after you remove the Arduino snap

1 Like

That’s good to know, thanks!

In order to make this less unexpected and more visible to users I propose two tweaks:

  • Give manual disconnects the Manual label in snap connections, like the command does for manual connects. Currently there is no way of knowing whether a slot is manually disconnected.
  • Have snap remove --purge also forget manual connects and disconnects. apt purge also removes any configuration of an app.

What do you think of this?

1 Like

This is a good idea, I agree with this.

Hmm, historically --purge was just about removing data, not necessarily state. Perhaps when a snap is removed the disconnection should always be removed/forgotten and the fact that it is not is a bug…

Is there other state that is saved after a snap is removed? I think as long as state persists after --purge, people will be confused about it, because it had such a specific meaning in apt. But if a normal remove also removes all state, then that issue is solved.

Note: I don’t see old snapshots as “persisting state” because a snapshot is not automatically reverted when you re-install an app

It seems this command is only included in snapd 2.45. I installed it from the edge channel and the UX of undesirable connections seems really weird.

  1. snap disconnect --forget requires an enabled connection to work. So you can’t use this command to forget an undesired connection.
  2. When you manually connect an undesired connection, it becomes a manual connection. When you remove that manual connection, it is simply removed; it does not become undesired again. So on the next snap refresh, it will be connected again. This seems like a security issue…

Can you file a bug detailing the steps you took and what you expected to happen? AFAIK your use case is exactly what we designed snap disconnect --forget for so if it’s not working then probably there’s a bug somewhere

I started a PR for showing undesirable connections, but I’m not sure what the actual output should be. I created an RFC here: RFC: Showing undesired connections