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 728920 - nmcli con modify destroy security settings
nmcli con modify destroy security settings
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: nmcli
unspecified
Other Linux
: Normal normal
: ---
Assigned To: NetworkManager maintainer(s)
NetworkManager maintainer(s)
: 727558 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2014-04-25 01:57 UTC by Matthias Clasen
Modified: 2015-02-17 13:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Suggested fix (1.23 KB, patch)
2014-07-30 15:47 UTC, Lubomir Rintel
needs-work Details | Review

Description Matthias Clasen 2014-04-25 01:57:39 UTC
I have a connection that works fine when editing it in nm-connection-editor

Now I do

nmcli con modify id 8L3Q9 connection.zone trusted

and launch nm-connection-editor's edit window again. The zone setting has appeared just fine, but

$ nm-connection-editor 

** (nm-connection-editor:15650): WARNING **: Invalid setting Wi-Fi Security: Invalid Wi-Fi security

** (nm-connection-editor:15650): WARNING **: Invalid setting Wi-Fi Security: Invalid Wi-Fi security


The only way I've found to fix this is to delete the connection and recreate it from scratch
Comment 1 Dan Williams 2014-04-25 15:07:21 UTC
Usually secrets must be loaded since calling Update() on a connection requires the whole package of settings.  I recall it was done this way to ensure that you could selectively clear secrets by simply not including them in the dict when calling Update().  Otherwise NM wouldn't know which secrets to keep and which to clear.

However, it seems unlikely that anyone would want to clear all secrets at the same time and then build them back up.  So a potential fix for this would be:

1) if *no* secrets are sent in the Update() call, leave secrets alone, and don't call SaveSecrets() in any of the agents.

2) if it really is useful to clear all secrets at the same time, then we could add a ClearSecrets() call to the Connection object to do that (secured appropriately of course), but I'm not sure this is necessary.
Comment 2 Lubomir Rintel 2014-07-30 15:45:43 UTC
Duplicates bug #727558
Comment 3 Lubomir Rintel 2014-07-30 15:47:59 UTC
Created attachment 282086 [details] [review]
Suggested fix

I'm wondering if this makes sense?
Comment 4 Dan Winship 2014-07-31 14:14:49 UTC
Comment on attachment 282086 [details] [review]
Suggested fix

The patch shouldn't be specific to ifcfg-rh. It should happen in nm-settings-connection, when it's updating the connection with the new values (update_auth_cb()). It needs to merge in the existing secrets if there are no secrets in the new connection.
Comment 5 Jiri Klimes 2014-09-11 15:45:25 UTC
Branch jk/bgo728920-update-connection-secrets contains fixes for the issue.

The cli (last) commit adds an option for showing secrets in nmcli. But it should be enhanced to include other missing secret-type properties yet, because majority of them is missing at the moment. Though, we can leave it out from this patch set, for later enhancements of nmcli secrets handling in order not to block this bug.

I have one question about GetSecrets(). Have an empty setting_name parameter (returning secrets for the whole connection) ever worked?

Now it is blocked by
»·······/* Make sure the request actually requests something we can return */
»·······if (!nm_connection_get_setting_by_name (NM_CONNECTION (self), setting_name)) {
»·······»·······g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_SETTING,
»·······»·······             "%s.%d - Connection didn't have requested setting '%s'.",
»·······»·······             __FILE__, __LINE__, setting_name);
»·······»·······return 0;
»·······}
in nm_settings_connection_get_secrets(). And before there was just a FIXME comment /* FIXME: if setting_name is empty, return all secrets */.

This commit might be related: d8cbecec8bfc20968e1c9364b36d09faeab93f2.
Comment 6 Dan Williams 2014-09-18 15:33:55 UTC
(In reply to comment #5)
> Branch jk/bgo728920-update-connection-secrets contains fixes for the issue.
> 
> The cli (last) commit adds an option for showing secrets in nmcli. But it
> should be enhanced to include other missing secret-type properties yet, because
> majority of them is missing at the moment. Though, we can leave it out from
> this patch set, for later enhancements of nmcli secrets handling in order not
> to block this bug.
> 
> I have one question about GetSecrets(). Have an empty setting_name parameter
> (returning secrets for the whole connection) ever worked?
> 
> Now it is blocked by
> »·······/* Make sure the request actually requests something we can return */
> »·······if (!nm_connection_get_setting_by_name (NM_CONNECTION (self),
> setting_name)) {
> »·······»·······g_set_error (error, NM_SETTINGS_ERROR,
> NM_SETTINGS_ERROR_INVALID_SETTING,
> »·······»·······             "%s.%d - Connection didn't have requested setting
> '%s'.",
> »·······»·······             __FILE__, __LINE__, setting_name);
> »·······»·······return 0;
> »·······}
> in nm_settings_connection_get_secrets(). And before there was just a FIXME
> comment /* FIXME: if setting_name is empty, return all secrets */.
> 
> This commit might be related: d8cbecec8bfc20968e1c9364b36d09faeab93f2.

I'm not sure it has, actually.  The D-Bus API docs state that "if the setting_name is empty all secrets will be returned" but I'm not sure we've actually ever used that feature in either nm-applet, nm-ce, or even gnome shell.  But I believe the intention of the API docs is correct, we should fix this.  It could actually simplify code in the editor too.
Comment 7 Dan Winship 2014-09-18 15:49:31 UTC
> ifcfg-rh: fix reading HWADDR_BLACKLIST

>+transform_hwddr_blacklist (const char *blacklist)

typo: "hwaddr"

"iter-shift" needs spaces around the "-". And that logic is complicated enough that it would be good to have a test case for that (invalid hwaddrs) too.


> libnm-core: allow G_TYPE_STRV to be NULL

This should already be fixed now in master by

  6c6cec0 libnm-core: fix getting/setting 0-length array properties


> cli: add '--show-secrets' option for 'nmcli connection show'

Not sure I like this... It seems like it makes it too easy for bad guys to get them. :)
Comment 8 Jiri Klimes 2014-09-19 19:51:02 UTC
(In reply to comment #7)
> > ifcfg-rh: fix reading HWADDR_BLACKLIST
> 
> >+transform_hwddr_blacklist (const char *blacklist)
> 
> typo: "hwaddr"
> 
> "iter-shift" needs spaces around the "-". And that logic is complicated enough
> that it would be good to have a test case for that (invalid hwaddrs) too.
> 
It has been in master already, actually. Fixed now by 
7966b6c ifcfg-rh: fix typo in function name and enhance testcase

> 
> > libnm-core: allow G_TYPE_STRV to be NULL
> 
> This should already be fixed now in master by
> 
>   6c6cec0 libnm-core: fix getting/setting 0-length array properties
>
Yeah, rebased to master.
 
> 
> > cli: add '--show-secrets' option for 'nmcli connection show'
> 
> Not sure I like this... It seems like it makes it too easy for bad guys to get
> them. :)
Hmm, bad guys are bad :(. But, don't let them limit good guys :)

The branch is updated due to recent master changes and rebased to it.
Comment 9 Dan Winship 2014-09-25 13:37:58 UTC
I just merged danw/libnm-api to master, rebased jk/bgo728920-update-connection-secrets onto it (dropping "libnm: add nm_remote_connection_get_secrets_sync()") and pushed a fixup on top of it (to deal with the slightly-different synchronous get_secrets API from danw/libnm-api).

Anyway, I'm fine with the code, but would like a second opinion on whether the --show-secrets flag is a good thing or not... (I'm not super opposed to it, just semi-concerned.)
Comment 10 Jiri Klimes 2014-09-26 12:09:44 UTC
(In reply to comment #6)
> (In reply to comment #5)
> > I have one question about GetSecrets(). Have an empty setting_name parameter
> > (returning secrets for the whole connection) ever worked?
> > 
> > Now it is blocked by
> > »·······/* Make sure the request actually requests something we can return */
> > »·······if (!nm_connection_get_setting_by_name (NM_CONNECTION (self),
> > setting_name)) {
> > »·······»·······g_set_error (error, NM_SETTINGS_ERROR,
> > NM_SETTINGS_ERROR_INVALID_SETTING,
> > »·······»·······             "%s.%d - Connection didn't have requested setting
> > '%s'.",
> > »·······»·······             __FILE__, __LINE__, setting_name);
> > »·······»·······return 0;
> > »·······}
> > in nm_settings_connection_get_secrets(). And before there was just a FIXME
> > comment /* FIXME: if setting_name is empty, return all secrets */.
> > 
> > This commit might be related: d8cbecec8bfc20968e1c9364b36d09faeab93f2.
> 
> I'm not sure it has, actually.  The D-Bus API docs state that "if the
> setting_name is empty all secrets will be returned" but I'm not sure we've
> actually ever used that feature in either nm-applet, nm-ce, or even gnome
> shell.  But I believe the intention of the API docs is correct, we should fix
> this.  It could actually simplify code in the editor too.

I have created bug 737418 for that.


(In reply to comment #9)
> I just merged danw/libnm-api to master, rebased
> jk/bgo728920-update-connection-secrets onto it (dropping "libnm: add
> nm_remote_connection_get_secrets_sync()") and pushed a fixup on top of it (to
> deal with the slightly-different synchronous get_secrets API from
> danw/libnm-api).
> 
> Anyway, I'm fine with the code, but would like a second opinion on whether the
> --show-secrets flag is a good thing or not... (I'm not super opposed to it,
> just semi-concerned.)

The code is not strictly related to this bug. So I have created new bug 737415 to continue on the topic there.


Update() and ClearSecrets() part merged to master:
df230fc merge: secret handling enhancements (bgo #728920)
502eb2d core: add ClearSecrets() D-Bus call
54a5f45 settings: do not clear secrets on Update() without any secrets (bgo #728920)
Comment 11 Jiri Klimes 2015-02-17 13:11:38 UTC
*** Bug 727558 has been marked as a duplicate of this bug. ***