On Wed, 2022-08-10 at 18:44 +0300, Andrei Borzenkov wrote:
> On 10.08.2022 13:09, Thomas Haller wrote:
> > On Wed, 2022-08-10 at 09:01 +0300, Andrei Borzenkov via
> > networkmanager-
> > list wrote:
> > > When automatic connection is deleted/modified, interface is added
> > > to
> > > /var/lib/NetworkManager/no-auto-default.state. Is there any
> > > device
> > > property to show "no-auto-default" state? Is there any command/D-
> > > Bus
> > > API
> > > to remove interface from this list?
> > 
> > 
> > there is no such API.
> > 
> > I guess you can delete the file, or modify it with "sed". That gets
> > complicated, because NetworkManager only loads the file ones and
> > writes
> > it anew at unpredictable times. To get it right, you'd have to stop
> > NM,
> > modify the file, start NM.
> > 
> > Btw, `sudo NetworkManager --print-config` prints the content of the
> > no-
> > auto-default.state flag. Note that as NetworkManager loads the file
> > only once and remembers it, the running NetworkManager may not have
> > cached what --print-config shows.
> > 
> 
> OK, thanks. I overlooked this option.
> 
> > 
> > Why do you want that?
> > 
> 
> Mostly to reset NetworkManager state to clean default. Usually it is
> frowned upon direct editing of internal state files and this file is
> certainly internal state.

That's a good choice to avoid internal state.

In practice, the files in /var/lib/NetworkManager are reasonably
simple. So if you edit them with the current understanding of how it is
structured, also when upgrading to a newer NetworkManager version it
must still work. That is, because when upgrading to a new
NetworkManager version, NetworkManager must cope with the current form
of those files anyway and it cannot break behavior in a bad way anyway.
So while this is not stable API, we must reasonably stick to the
behavior in the future.

The bigger problem is that NetworkManager reads and writes those files
at unpredicatable times. The only really correct way to handle it is by
first stopping NetworkManager, the modifying the files, then
(re)starting NetworkManager.

> 
> If you say that editing it is OK it is fine for me.
> 

To forget the state as if it were a reboot, delete /run/NetworkManager.
To forget the state as if it were a factory reset, delete
/var/lib/NetworkManager and /etc/NetworkManager.

Graned, your distro might install some files in /etc/NetworkManager.
Possibly it should avoid that. But it means you might want to take care
before wiping /etc/NeworkManager. NetworkManager itself is fine to
start without empty /etc/NetworkManager.



Thomas

_______________________________________________
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list

Reply via email to