GNOME Bugzilla – Bug 683345
keyfile: uuid and id fields should be optional for configuration files created by people
Last modified: 2014-06-25 14:36:22 UTC
When the NMSettingConnection/id property is missing from a connection file. NM fails to load it. It would be nice to consider the id the filename if the id is missing.
Confirming. And the UUID should be auto-generated and not required from the beginning.
Nathanael, I guess you are talking about keyfile configuration files in /etc/NetworkManager/system-connections/. Indeed, they don't allow missing id or uuid for now. (ifcfg-rh plugin's /etc/sysconfig/network-scripts/ifcfg-* allow missing NAME and UUID)
Created attachment 223908 [details] [review] [PATCH] keyfile: allow missing id and uuid in connection files If 'id' is missing, basename of the file path is used as connection name. If 'uuid' is missing, the file path is hashed to generate an UUID.
I don't know why we didn't merge this... From duplicate bug report: Pavel Simerda [reporter] [NetworkManager developer] 2013-03-31 00:36:18 UTC The minimal [connection] section of keyfile connection configuration looks like: [connection] id=... uuid=... type=... The only significant item there is the 'type'. Others are just NetworkManager boilerplate. The 'id' attribute should default to the filename. Unless a specific 'id' is used, filenames in /etc/NetworkManager/system-connections are unique and there's no reason not to use them as the default value. Of course it can be overriden by something fancy and pretty like "Ethernet connection 1". Administrators should never be asked to generate 'uuid' for new connections. There is a bunch of possibilites what could be done for connection keyfiles without uuid: 1) It could be written there whenever the connection is read. Simple but ugly. 2) It could be stored in a separate file that would link the file name to the uuid. 3) It could be a hash of the filename. Probably the most elegant way. This bug report specifically applies to administrators who prefer writing configuration files by hand. [reply] [-] Comment 1 Dan Williams [NetworkManager developer] 2013-04-03 13:25:54 UTC This is likely fine, we'd need to do what the ifcfg-rh plugin does for creating the ID and UUID dynamically, which is to create a UUID from the filename since filenames must be unique. The ID comes from the filename too. Note that if you then renamed the file, the UUID changes, and then all sorts of stuff gets reset, like your saved DHCP leases are gone, last-connected timestamp is reset to 0, and seen-bssids are cleared, because all of this is based on the UUID. I have no problem with the administrator not being required to write an ID or UUID, but we should at least write the UUID (and maybe the ID, maybe not) out to the file whenever it gets modified. [reply] [-] Comment 2 Pavel Simerda [reporter] [NetworkManager developer] 2013-04-03 13:38:38 UTC Agreed.
*** Bug 696939 has been marked as a duplicate of this bug. ***
Comment on attachment 223908 [details] [review] [PATCH] keyfile: allow missing id and uuid in connection files yes, we should do this
I have modified the patch to apply and added a testcase: jk/keyfile-bgo683345
(In reply to comment #7) > I have modified the patch to apply and added a testcase: > jk/keyfile-bgo683345 Pushed one white space fixup! Patch looks good to me.
(In reply to comment #7) > I have modified the patch to apply and added a testcase: > jk/keyfile-bgo683345 Hm, maybe it'd be worth getting rid of the @id and @uuid variables: - id = nm_setting_connection_get_id (s_con); - if (!id) { + if (!nm_setting_connection_get_id (s_con)) { @uuid likewise.
(In reply to comment #9) > (In reply to comment #7) > > I have modified the patch to apply and added a testcase: > > jk/keyfile-bgo683345 > > Hm, maybe it'd be worth getting rid of the @id and @uuid variables: > > - id = nm_setting_connection_get_id (s_con); > - if (!id) { > + if (!nm_setting_connection_get_id (s_con)) { > > @uuid likewise. Fixed. Squashed and rebased to master branch.
Looks good to me now
c88b832 keyfile: allow missing 'id' and 'uuid' in [connection] section (bgo #683345)