Commit Graph

99 Commits

Author SHA1 Message Date
Jiří Klimeš
0d4a5f0328 Revert "libnm-util: refactor NMSetting construction, assert of setting name"
This reverts commit f43586fc17.

This broke stuff as "name" was set on various places after construction. So we
revert the commit for now, and will rework it.
2013-11-28 11:18:54 +01:00
Thomas Haller
f43586fc17 libnm-util: refactor NMSetting construction, assert of setting name
Make the name property CONSTRUCT_ONLY. With this there is also no more
need to overwrite the constructor().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-27 23:10:17 +01:00
Jiří Klimeš
0f02392123 doc: fix description of nm_setting_set_secret_flags() 2013-11-18 15:59:05 +01:00
Dan Winship
f4c3e2f643 libnm-util: centralize find_setting_by_name code
Several settings types' verify() functions need to find a particular
setting from the all_settings list that NMConnection passes them. Add
a convenience function for this.
2013-10-24 12:25:08 -04:00
Dan Williams
1d8ab72a60 libnm-util: fix hashing of secrets broken by 4d326182
4d326182 changed connection hashing slightly such that now base type settings
are always returned even if they are empty. Unfortunately a bunch of code in
the settings hashed connections with the ONLY_SECRETS flag and then checked
whether the returned hash was NULL or not to determine whether there were
any secrets, and then called nm_connection_update_secrets() with the hash.

nm_connection_update_secrets() would fail in the case where a setting
name was given, but the passed-in secrets hash did not contain any secrets
for the requested setting.  Instead, the function should return success
to match the semantics of passing in an entire connection hash which may
not have any secrets either.
2013-05-20 13:56:48 -05:00
Dan Williams
0a5f272c35 libnm-util: correct documentation for nm_setting_update_secrets() 2013-05-04 13:18:28 -05:00
Dan Winship
4d32618264 libnm-util: handle "empty" connection-type settings correctly
nm_setting_to_hash() would return NULL if the setting had entirely
default values, but this effectively meant that you could never have a
connection whose "connection type" setting (eg, NMSettingWired) had
all default values. (This ended up not usually being a problem in
practice because most such settings had at least one property with a
mandatory string value where the GObject property had a default value
of NULL.)

However, NMSettingGeneric will have no properties, so it would always
get stripped out when converting to a hash, invalidating the
connection. Fix that.
2013-05-03 08:39:10 -04:00
Dan Winship
6cb786f569 libnm-util: move setting priority functions to nm-setting.c
None of these take an NMConnection; they logically belong in
NMSetting.
2013-05-03 08:39:06 -04:00
Martin Pitt
57a9fb3c89 Use %NULL macro in doc strings
Mass-converted "NULL" to "%NULL" in docstrings with

  find -name '*.c'| xargs sed -i '/^ \*.*[^%]NULL/ s/NULL\b/%NULL/g'
2013-04-19 10:08:17 -04:00
Martin Pitt
6226fb9b59 libnm-util: Fix transfer annotations of nm_{connection,setting}_need_secrets()
The various need_secrets() implementation do allocate a fresh GPtrArray, but
add static strings to them without dup'ing. Thus callers must _not_ free the
array elements, only the array itself. Adjust documentation and annotations
accordingly.

Also adjust the corresponding comment in the goi-list-connections.py example.

https://bugzilla.gnome.org/show_bug.cgi?id=698175
2013-04-19 09:43:56 -04:00
Dan Williams
6c7c2b874d libnm-util: convert nm_setting_new_from_hash() to GHashTableIter 2013-04-01 17:18:54 -05:00
Jiří Klimeš
82fb1978a4 all: use G_VALUE_INIT to initialize GValue variables
It makes the initializations more explicit.
G_VALUE_INIT is available since glib 2.30, and NM now require glib >= 2.32
2013-03-25 08:41:18 +01:00
Dan Winship
6f44b7f3c6 all: remove redundant return-if-fail checks
NM_IS_FOO(x) returns FALSE if x is NULL, so we don't need a separate
(x != NULL) check before it.
2013-03-07 07:32:27 -05:00
Dan Winship
839eab5564 Use glib-mkenums to generate enum types
Rather than generating enum classes by hand (and complaining in each
file that "this should really be standard"), use glib-mkenums.

Unfortunately, we need a very new version of glib-mkenums in order to
deal with NM's naming conventions and to fix a few other bugs, so just
import that into the source tree temporarily.

Also, to simplify the use of glib-mkenums, import Makefile.glib from
https://bugzilla.gnome.org/654395.

To avoid having to run glib-mkenums for every subdirectory of src/,
add a new "generated" directory, and put the generated enums files
there.

Finally, use Makefile.glib for marshallers too, and generate separate
ones for libnm-glib and NetworkManager.
2012-02-15 11:42:15 -05:00
Dan Williams
a080a1ed08 libnm-util: fix some introspection annotations 2011-12-22 11:04:56 -06:00
Thomas Graf
1cd8d52061 bonding: add nm_connection_get_virtual_iface_name() to abstract kernel interface binding
Some connection types such as bonding, bridging and VLAN require
specific virtual kernel interfaces identified by name to be auto
connected to the connection.

The function nm_connection_get_virtual_iface_name() returns the name
of the kernel interface if the connection type requires this
functionatlity.

Each connection base type settings class can implement the function
get_virtual_iface_name() if the connection needs to be auto connected
to a specific kernel interface.

Signed-off-by: Thomas Graf <tgraf@redhat.com>
2011-12-08 09:56:47 -06:00
Dan Winship
7b7d7bce2f libnm-util: add some more introspection annotations to silence warnings 2011-10-14 10:09:46 -05:00
Dan Williams
2b2404bbef settings: preserve agent secrets the right way
What we want to do here is keep separate caches of system and
agent secrets.  For system secrets, we cache them because NM
periodically clears secrets using nm_connection_clear_secrets() to
ensure they don't stay around in memory, and that transient secrets
get requested again when they are needed.  For agent secrets, we
only want them during activation, but a connection read from disk
will not include agent secrets becuase by definition they aren't
stored in system settings along with the connection.  Thus we need
to keep the agent/transient secrets somewhere for the duration of
the activation to ensure they don't get deleted.

This removes the copy-back hack in update_auth_cb() which copied
agent/transient secrets back into the connection over top of the
transient secrets that had been copied back in
nm_settings_connection_replace_settings().  No reason to copy
them twice if we keep an agent/transient secrets hash and do
the right thing with it.
2011-08-16 16:19:23 -05:00
Dan Williams
864db9f9e8 libnm-util: add new compare flags for ignoring various types of secrets
It turns out we need a way to ignore transient (agent-owned or unsaved)
secrets during connection comparison.  For example, if the user is
connecting to a network where the password is not saved, other
changes could trigger a writeout of that connection to disk when
connecting, which would the connection back in due to inotify, and the
re-read connection would then no longer be recognized as the same as
the in-memory connection due to the transient secret which obviously
wasn't read in from disk.

Adding these compare flags allows the code to not bother writing the
connection out to disk when the only difference between the on-disk
and in-memory connections are secrets that shouldn't get written to
disk anyway.
2011-06-07 18:22:48 -05:00
Dan Williams
9ff4914ccc libnm-util: fix some GObject Introspection annotations
Unfortunately, GObject Introspection can no longer describe deeper
types, like those inside nested hash tables, which NM uses extensively
for the NMConnection type and other places.  So we have to remove
those descriptions.  But this moves us back into compliance with
GOI annotation formats.
2011-05-10 13:24:07 -05:00
Dan Williams
07b9660263 libnm-util: simplify nm_setting_update_secrets()
Don't touch tmp_error after we've freed it; it's not actually
a problem since we're not dereferencing tmp_error, but it's
cleaner this way.
2011-02-23 19:36:17 -06:00
Dan Williams
eab5851145 libnm-util: remove nm_warning/nm_info/nm_error macros
Clients need to do their own logging using glib or whatever; these
macros while somewhat helpful were not flexible and are not a
substitute for actual logging in the client.  g_warning, g_message,
and g_error are more suitable anyway.
2011-02-23 11:42:04 -06:00
Dan Williams
54918e32e4 libnm-util: add nm_connection_diff()
Returns a list of keys that differ between the settings in each
connection.  nm_connection_compare() can't do that.
2011-02-22 23:36:43 -06:00
Dan Williams
ad56cfa914 libnm-util: don't return empty hashes from nm_setting_to_hash() 2011-02-07 13:44:28 -06:00
Dan Williams
899b8a40dc libnm-util: NM_SETTING_SECRET_FLAG_SYSTEM_OWNED -> NM_SETTING_SECRET_FLAG_NONE
Make it a bit clearer that this value is not actually a value that
can be used as a flag, since its 0x00.
2011-02-06 23:37:39 -06:00
Dan Williams
a5103bf234 libnm-util: silently ignore non-secrets when updating connection secrets 2011-02-02 17:25:56 -06:00
Dan Williams
c36c81e2b9 libnm-util: fix updating secrets
Broken by 5dd4f1ea01
2011-02-02 17:18:50 -06:00
Dan Williams
fb033b0f05 libnm-util: fix setting property iteration when getting secret flags
g_object_class_find_property() needs the object's class, not the
object itself.
2011-02-02 11:58:19 -06:00
Dan Williams
93cbc77154 libnm-util: handle get_secret_flags/set_secret_flags for WirelessSecurity setting
Becuase there's only one 'flags' property for WEP keys (because it's pretty
dumb to have different flags for all 4 WEP keys) we need to do some tap dancing
with the secret name, so that requests for "wep-keyX" look up the "wep-key-flags"
property.
2011-01-31 19:57:48 -06:00
Dan Williams
092a6535e0 libnm-util: add generic functions for getting/setting secret flags
And remove the VPN-specific ones.  It's useful to have this stuff be
generic and the functionality wasn't really VPN-specific anyway.
2011-01-31 12:41:54 -06:00
Dan Williams
562246cb80 libnm-util: fix handling of secrets flags
It's a bitfield, not a single value.  Update GObject property
max accordingly.
2011-01-31 12:36:53 -06:00
Dan Williams
e68e27aa75 libnm-util: add 'flags' argument to nm_connection_to_hash() and nm_setting_to_hash()
Simplifies code internally, and makes it easier for clients as well in
some cases where they want to control what ends up in the resulting
hash and what does not.
2011-01-26 14:14:37 -06:00
Giovanni Campagna
3ebecd2a29 introspection: add GObject introspection support (bgo #637032)
Add the necessary annotations (the mininum required, that is those
on return values. NULL parameters or container types may require
more), and the Autotools stuff to get a NetworkManager GIR for
libnm-util and a NMClient for libnm-glib.
2011-01-21 14:46:09 -06:00
Dan Williams
5dd4f1ea01 libnm-util: fix possible crash in nm_setting_update_secrets()
If a pointer to a valid GError was not passed the function could
crash.  Make it simpler and fix the possible crash by just converting
to hash table iters instead.
2011-01-19 18:17:40 -06:00
Jiří Klimeš
d4ac3cd593 libnm-util: fix a memory leaks in nm_setting_to_string() 2010-12-13 20:55:02 +01:00
Dan Williams
14089e8b26 doc: update some setting properties descriptions 2009-11-10 12:36:20 -08:00
Pablo Martí
6029288ffb libnm-util:keyfile: typo fixes 2009-06-03 09:27:44 -04:00
Dan Williams
ccb84b15d5 libnm-util: fix use-after-free when updating setting secrets 2009-03-31 13:08:07 -04:00
Dan Williams
ccbd9155ec Documentation updates
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4331 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-11-24 04:30:36 +00:00
Dan Williams
2328650d2e Documentation fixes
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4328 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-11-23 22:55:03 +00:00
Dan Williams
93f1c85b26 2008-11-20 Dan Williams <dcbw@redhat.com>
Patch from Tambet Ingo <tambet@gmail.com>

	* libnm-util/nm-setting.c
	  libnm-util/nm-setting.h
		- (NMSettingValueIterFn): instead of just a gboolean for secrets, take
			all the GParamSpec flags of the property

	* system-settings/plugins/keyfile/nm-keyfile-connection.c
	  system-settings/plugins/keyfile/reader.c
	  system-settings/plugins/keyfile/writer.c
		- Update for NMSettingValueIterFn change



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4322 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-11-20 21:23:55 +00:00
Dan Williams
07cccfebb7 Documentation updates
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4315 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-11-20 15:49:46 +00:00
Dan Williams
320c3f378c 2008-11-20 Dan Williams <dcbw@redhat.com>
* libnm-util/libnm-util.ver
	  libnm-util/nm-setting.c
	  libnm-util/nm-setting.h
		- Add NMSetting errors
		- (nm_setting_update_secrets): return errors

	* libnm-util/nm-connection.c
	  libnm-util/nm-connection.h
		- (nm_connection_update_secrets): return errors

	* libnm-util/nm-setting-vpn.c
	  src/nm-activation-request.c
	  src/vpn-manager/nm-vpn-connection.c
		- Handle update secrets errors



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4314 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-11-20 15:44:57 +00:00
Dan Williams
034c1705ce Documentation updates
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4313 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-11-20 15:22:25 +00:00
Dan Williams
6e40cdb3a5 2008-11-20 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-setting.c
	  libnm-util/nm-setting.h
	  libnm-util/libnm-util.ver
		- (nm_setting_new_from_hash): rename from nm_setting_from_hash() to be
			consistent with nm_connection_new_from_hash()

	* src/nm-activation-request.c
	  libnm-util/nm-connection.c
		- Handle rename



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4312 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-11-20 14:47:08 +00:00
Dan Williams
9fd459f326 more documentation
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4310 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-11-20 12:33:08 +00:00
Dan Williams
c47cdcf0e7 2008-11-19 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-setting.h
	  libnm-util/nm-setting.c
	  src/nm-device.c
	  src/nm-manager.c
	  system-settings/plugins/ifcfg-fedora/plugin.c
		- Prefix compare flag defines with NM_SETTING_



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4299 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-11-19 16:20:47 +00:00
Dan Williams
c438326110 2008-10-27 Dan Williams <dcbw@redhat.com>
Patch from Tambet Ingo <tambet@gmail.com>

	* libnm-util/nm-setting.h
	  libnm-util/nm-setting.c
		- Make properties private and add accessor functions

	* libnm-util/nm-connection.c
	  libnm-util/nm-setting-8021x.c
	  libnm-util/nm-setting-cdma.c
	  libnm-util/nm-setting-connection.c
	  libnm-util/nm-setting-gsm.c
	  libnm-util/nm-setting-ip4-config.c
	  libnm-util/nm-setting-ip6-config.c
	  libnm-util/nm-setting-ppp.c
	  libnm-util/nm-setting-pppoe.c
	  libnm-util/nm-setting-serial.c
	  libnm-util/nm-setting-template.c
	  libnm-util/nm-setting-vpn.c
	  libnm-util/nm-setting-wired.c
	  libnm-util/nm-setting-wireless-security.c
	  libnm-util/nm-setting-wireless.c
	  system-settings/plugins/keyfile/reader.c
	  system-settings/plugins/keyfile/writer.c
		- Use setting accessors



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4228 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-10-27 17:36:18 +00:00
Dan Williams
4a15d37c27 Add compare flag to ignore secrets
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4058 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-11 20:54:02 +00:00
Dan Williams
281791ac77 2008-07-27 Dan Williams <dcbw@redhat.com>
* libnm-util/*
		- Relicense to LGPLv2+



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3859 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-07-27 20:03:46 +00:00