After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 738611 - Networkmanager-0.9.10.0: NM should fallback to other listed plugins instead of failing
Networkmanager-0.9.10.0: NM should fallback to other listed plugins instead o...
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: NetworkManager maintainer(s)
NetworkManager maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-10-16 08:57 UTC by Pacho Ramos
Modified: 2014-10-30 15:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
config: set a compile time default for the main.plugins configuration option (3.47 KB, patch)
2014-10-16 10:03 UTC, Thomas Haller
none Details | Review

Description Pacho Ramos 2014-10-16 08:57:17 UTC
If we have a /etc/NetworkManager/NetworkManager.conf with this contents:
[main]
plugins=ifnet,keyfile

[ifnet]
managed=true
auto_refresh=false

We would expect it to fallback to "keyfile" if "ifnet" is not present but, instead, it simply fails:
Oct 15 07:10:47 localhost NetworkManager[24686]: <error> [1413349847.969161] [main.c:613] main(): failed to initialize settings storage: Could not load plugin 'ifnet': /usr/lib64/NetworkManager/libnm-settings-plugin-ifnet.so

Could this behavior be changed to fallback to the second listed plugin?

Thanks
Comment 1 Thomas Haller 2014-10-16 10:01:58 UTC
I don't think that is overly useful.

Specifying invalid setting plugins is a serious configuration error and I feel it's correct for NM to abort.

Note, that the available plugins are determined at compile time (or by your distribution who provides the binary package). Hence, usually it is very uncommon to ever change the main.plugins setting.
Comment 2 Thomas Haller 2014-10-16 10:03:53 UTC
Created attachment 288663 [details] [review]
config: set a compile time default for the main.plugins configuration option

In case of a missing NetworkManager.conf (or a missing configuration option
main.plugins), allow to determine the fallback at compile time

https://bugzilla.gnome.org/show_bug.cgi?id=738611

Signed-off-by: Thomas Haller <thaller@redhat.com>
Comment 3 Thomas Haller 2014-10-16 10:05:22 UTC
(In reply to comment #2)
> Created an attachment (id=288663) [details] [review]
> config: set a compile time default for the main.plugins configuration option

Btw. we always compile ibft plugin, but by default we don't enable it
in contrib/fedora/rpm/NetworkManager.conf . I think we should. (?)


In that case, maybe it would be right to:
+    #if CONFIG_PLUGIN_IFCFG_RH
+                                     "ifcfg-rh",
+                                     "ibft",
+    #endif
Comment 4 Pacho Ramos 2014-10-16 10:39:44 UTC
Thanks

Well, in our concrete case we used to use "ifnet" plugin but, now, we want people to keep with default "keyfile" then, we disable ifnet, don't install the networkmanager settings file but some people still have one they edited time ago and need to manually drop the line in their /etc file. We inform people about this... but still some forget it :|
Comment 5 Thomas Haller 2014-10-16 11:51:31 UTC
(In reply to comment #4)
> Thanks
> 
> Well, in our concrete case we used to use "ifnet" plugin but, now, we want
> people to keep with default "keyfile" then, we disable ifnet, don't install the
> networkmanager settings file but some people still have one they edited time
> ago and need to manually drop the line in their /etc file. We inform people
> about this... but still some forget it :|

With the previous patch, you could (in the future) compile NM with a default, and not set the configuration value in the provided /etc/NetworkManager/NetworkManager.conf.
Maybe even better, to provide the default configuration file that contains:

[main]
# by default, NetworkManager uses the 'keyfile' plugin
#plugins=keyfile


Also, for your case you could just patch those few lines yourself before packaging. If that is really what you want to do.

To me, this seems the wrong upstream behaviour... NM should rather not be resilient to configuration errors. But yeah, I see that this is problematic -- especially for non-technical users.
Comment 6 Dan Williams 2014-10-18 20:48:31 UTC
The patch looks fine to me, and I think (at least for this option) it's useful to allow the fallback to happen, with a warning that the configured plugin can't be found.  For other config options I think we should leave it as a hard error.

(In reply to comment #3)
> (In reply to comment #2)
> > Created an attachment (id=288663) [details] [review] [details] [review]
> > config: set a compile time default for the main.plugins configuration option
> 
> Btw. we always compile ibft plugin, but by default we don't enable it
> in contrib/fedora/rpm/NetworkManager.conf . I think we should. (?)
> 
> 
> In that case, maybe it would be right to:
> +    #if CONFIG_PLUGIN_IFCFG_RH
> +                                     "ifcfg-rh",
> +                                     "ibft",
> +    #endif

Yes.
Comment 7 Thomas Haller 2014-10-21 09:19:32 UTC
Ok, I changed it to only warn on missing plugins.

I reworked the previous patch. I pushed the new version to the th/bgo738611_load_setting_plugins branch.
Comment 8 Dan Winship 2014-10-23 13:18:49 UTC
> settings: accept missing settings plugins

> 		/* ifcfg-fedora was renamed ifcfg-rh; handle old configs here */
>-		if (!strcmp (pname, "ifcfg-fedora"))
>-			pname = "ifcfg-rh";
>+		if (!strcmp (pname, "ifcfg-fedora")) {
>+			g_free (pname);
>+			pname = g_strdup ("ifcfg-rh");
>+		}

That rename happened in NM 0.7, 6 years ago. We can probably drop the special case now...

> settings: check file permissions when loading settings plugins

The check here is the same one that nm-manager.c does for device plugins. Maybe it should be in NetworkManagerUtils.
Comment 9 Thomas Haller 2014-10-27 15:45:08 UTC
(In reply to comment #8)
> > settings: accept missing settings plugins
> 
> > 		/* ifcfg-fedora was renamed ifcfg-rh; handle old configs here */
> >-		if (!strcmp (pname, "ifcfg-fedora"))
> >-			pname = "ifcfg-rh";
> >+		if (!strcmp (pname, "ifcfg-fedora")) {
> >+			g_free (pname);
> >+			pname = g_strdup ("ifcfg-rh");
> >+		}
> 
> That rename happened in NM 0.7, 6 years ago. We can probably drop the special
> case now...

fixup pushed.

> 
> > settings: check file permissions when loading settings plugins
> 
> The check here is the same one that nm-manager.c does for device plugins. Maybe
> it should be in NetworkManagerUtils.

Indeed I copied the code over from nm-manager.c But there is not so much overlapping code as the behaviour is slightly different. 

E.g. on "if (!S_ISREG (st.st_mode))" we want to silently skip loading device plugins (which come from a readdir()), but warn for setting plugins (because they were explicitly configured).
Comment 10 Dan Williams 2014-10-28 21:14:12 UTC
> settings: accept missing settings plugins

+#define LOG(level, ...) \
+	G_STMT_START { \
+		nm_log ((level), LOGD_CORE, \
+		        "setting: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__) \
+		        _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
+	} G_STMT_END

-> "settings: "
Comment 12 Pacho Ramos 2014-10-29 20:45:57 UTC
Could it be included for 0.9.10.x branch too please (for getting it in an hypothetical upcoming 0.9.10.1 version) :)

Thanks a lot
Comment 13 Thomas Haller 2014-10-30 15:40:52 UTC
(In reply to comment #12)
> Could it be included for 0.9.10.x branch too please (for getting it in an
> hypothetical upcoming 0.9.10.1 version) :)
> 
> Thanks a lot

Sure.

Backported to nm-0-9-10:

http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=3d9c8f6b8dd395177063577ce32ff2cabf23cef9