Commit Graph

39 Commits

Author SHA1 Message Date
Thomas Haller
fbcabeb7f7 libnm-glib: fix crash by taking additional ref in nm-remote-connection/result_cb
result_cb invokes a function pointer provided by the user. Nothing prevents
the user from destroying the NMRemoteConnection in the callback, which leads
to a crash. Take an additional ref of NMRemoteConnection to keep it
alive.

This probably caused a crash for nm-applet:
https://bugzilla.redhat.com/show_bug.cgi?id=1030403

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-18 23:01:35 +01:00
Dan Winship
ffa012f3ce libnm-glib: fix nm_remote_connection_delete() callback
If you called nm_remote_connection_delete() on a connection whose only
ref was held by the NMRemoteSettings, then the callback would never
get called, because NMRemoteSettings would drop its ref before then
(when the connection emitted the 'removed' signal), so the callback
would get cancelled.

Fix this by taking an extra ref on the connection around the D-Bus
call in this case.

https://bugzilla.redhat.com/show_bug.cgi?id=997568
https://bugzilla.gnome.org/show_bug.cgi?id=706141
2013-09-09 09:28:24 -04:00
Dan Williams
c41bd34570 libnm-glib: add support for new connection unsaved functionality 2013-05-28 12:26:56 -05: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
Dan Williams
a87b5a15df libnm-glib: use private connection before trying the system bus
Use the D-Bus connection helper whenever we need a connection to
NM, which by default tries to use a private connection instead of
the shared bus connection whenever the user is root.  Doing this
by default will not change the behavior of libnm-glib, and allows
tools like nmcli and libnm-glib-using clients to work in minimal
environments (those without a bus daemon) by default.
2013-04-08 11:30:32 -05:00
Dan Williams
661d09852d libnm-glib: use helpers to create dbus proxies
When using a private connection, we need to use dbus_g_proxy_new_for_peer()
because the bus isn't involved.  Since many parts of libnm-glib create a
proxy for their corresponding remote object, consolidate the proxy creation
logic.

A later patch will add logic to use a private connection versus a bus-based
one.
2013-04-08 11:30:32 -05:00
Dan Williams
b1fc88154b libnm-glib: fix memory leak of GSimpleAsyncResult getting connection settings 2013-04-01 17:18:53 -05: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
57327a6a57 libnm-util, libnm-glib: fix NMConnection:path again
24cda2bc broke the ability to set NMConnection:path back to NULL after
it had been set, as part of a hack to try to make
NMRemoteConnection:dbus-path work. Fix that by moving the hack
entirely into NMRemoteConnection.

https://bugzilla.gnome.org/show_bug.cgi?id=693829
2013-02-14 13:47:44 -05:00
Dan Winship
24cda2bc36 libnm-util, libnm-glib: Make NMRemoteConnection instantiable by NMObject
In order to resolve NMRemoteConnection-valued properties, NMObject
needs to be able to create NMRemoteConnections. But NMObject assumes
that all the objects it will be creating have "dbus-connection" and
"dbus-path" properties. So add those properties to NMRemoteConnection,
aliasing the existing "bus" and "path" properties (and ensure that
whichever version gets set, we keep that value, rather than letting it
get overwritten by the NULL default value of the other one).

https://bugzilla.gnome.org/show_bug.cgi?id=693669
2013-02-14 09:31:33 -05:00
Dan Winship
7c5cf25366 libnm-glib: fix NMRemoteConnection GInitable implementation
apparently this never got tested...

https://bugzilla.gnome.org/show_bug.cgi?id=693669
2013-02-14 09:31:33 -05:00
Dan Winship
320464490e libnm-glib: fix GAsyncInitable implementations
If a class implements init_async, it should implement init_finish too,
rather than assuming the default implementation will do the right
thing (which it briefly didn't in glib 2.33).
2012-07-17 09:43:15 -04:00
Dan Winship
be18dd06cd libnm-glib: NULL out priv fields on dispose()
In some situations, objects might get used after being disposed, so
clear out their various priv fields so we don't try to access unreffed
objects, freed strings, etc.

https://bugzilla.gnome.org/show_bug.cgi?id=674473
2012-04-23 16:09:58 -04:00
Dan Winship
410ac72325 libnm-glib: fix to not depend on newer glib 2012-02-06 17:29:49 -06:00
Dan Winship
c619365ee3 libnm-glib: asyncify NMRemoteSettings
Add nm_remote_settings_new_async/_finish, and misc other fixes
2012-02-03 10:33:44 -06:00
Dan Winship
9fd98ef91b libnm-glib: implement GInitable/GAsyncInitable in NMObject
Implement GInitable and GAsyncInitable in NMObject, with
implementations that synchronously or asynchonously load all
properties, and change _nm_object_ensure_inited() to run
g_initable_init().

Update the object/object-array property handling to initialize the
objects after creating them (synchronously or asynchronously,
according to the situation), so that they will have all of their
properties preloaded before they are ever visible to the caller.

Move the non-blocking/non-failable parts of various objects'
constructor() methods to constructed(), and move the blocking/failable
parts to init(), and implement init_async() methods with non-blocking
versions of the blocking methods.

Make nm_device_new() and nm_client_new() call
_nm_object_ensure_inited(), to preserve the behaviour formerly
enforced by their construct() methods, that properties are guaranteed
to be initialized before any signals involving them are emitted.
2012-02-03 10:33:43 -06:00
Dan Winship
8ad3ff24ad libnm-glib: don't use client-side generated dbus-glib bindings
Most of the code was using dbus_g_proxy_call() directly, but there
were some leftover uses of the generated bindings. Make things more
consistent by using dbus_g_proxy_call() everywhere, and stop building
the -bindings.h files.
2012-02-02 12:30:44 -06:00
Dan Williams
8b1de024ba libnm-glib: fix allow-none introspection annotations (rh #747302) 2011-10-26 10:53:47 -05:00
Dan Williams
a7f7e80839 libnm-glib: fix introspection annotations for callbacks and user_data (rh #747302)
user_data arguments should be annotated with (closure) and callbacks
should be marked (allow none) where it's safe to pass NULL.
2011-10-26 10:33:38 -05:00
Dan Williams
49c618a2a8 libnm-glib: fix introspection annotation for nm_remote_connection_delete() 2011-03-17 10:46:42 -05:00
Richard Hughes
4e73194500 libnm-glib: allow calling nm_remote_connection_delete() without a callback 2011-03-16 15:36:36 -05:00
Giovanni Campagna
3b57350dd6 libnm-glib: add signal documentation for NMRemoteConnection 2011-02-21 18:08:41 -06:00
Dan Williams
c7ec68e0ba libnm-glib: handle initially invisible connections correctly
Don't delete them if we don't have permission for them, since
we may get permission for them later via Update.  But to listen
for Update we need the connection around.
2011-02-12 22:00:30 -06:00
Dan Williams
d94590a52c libnm-glib: fix connection visibility handling
When the connection becomes invisible to a user (ie, the permissions
of the connection no longer allow that user to view the connection)
then we have to hid the connection from clients.  But we can't
just dispose of it, because visibility changes are signaled with
Update signals on the connection itself, and thus we need to keep
the connection around just in case it becomes visible to the user
again.  But if it's invisible, make sure we clear out the settings
since they may have changed.
2011-02-12 21:48:30 -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
Dan Williams
b3959aefa3 core: rename NMSysconfigConnection -> NMSettingsConnection 2011-01-26 11:38:12 -06:00
Dan Williams
d1979ba63e secrets: simplify GetSecrets call flow
The Settings.Connection interface is now only provided by NetworkManager
itself since there is only one settings service.  NM can validate
requests for secrets internally and thus there's no need to lock down
GetSecrets using a separate D-Bus interface, since PolicyKit provides
that functionality on systems where this is desirable (ie multi-user).
Single-user systems that do not have PolicyKit will inherently trust
the user already, or if not D-Bus auth is flexible enough to lock
down the GetSecrets method individually even if it's not on a separate
D-Bus interface.

Second, since only clients like connection editors or applets will be
calling the GetSecrets method, there's no need for 'hints' or
'request_new' arguments here since this  method should never trigger
an interactive secrets request.  Only NM should send those requests
when it knows it needs to ask the user, either during connection or
after validating the incoming GetSecrets request.  A connection editor
type application should never be able to trigger the normal
"What's your passphrase" dialog thats provided by the secret agent
for that user's session.
2011-01-26 10:17:07 -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
eb27406fdc libnm-glib: handle visibility changes for updated connections 2010-12-23 09:59:57 -06:00
Daniel Gnoutcheff
f98e2528a6 NetworkMangerSettings -> NetworkManager.Settings
Just for consistency, make settings related stuff live under the
org.freedesktop.NetworkManager namespace, rather than its own
org.freedesktop.NetworkManagerSettings namespace. Renames are done for
DBus interface names, DBus object paths, and polkit actions.
2010-08-07 01:19:46 -04:00
Daniel Gnoutcheff
fb96309899 DBus: merge NetworkManger{,SystemSettings}
Remove the org.freedesktop.NetworkManagerSystemSettings bus name and
have everybody talk to org.freedesktop.NetworkManager. Now that we have
a single settings service that's embedded in the main daemon, we don't
need separate names anymore.
2010-08-07 01:19:46 -04:00
Daniel Gnoutcheff
7f8dc06dff remove nm-settings-connection-interface
NMSettingsConnectionInterface was created to allow the daemon and NM
clients to have common code that handled both system and user
connections. It's no longer needed now that user settings services are
gone.

This concludes the flattening of libnm-glib.
2010-08-06 20:53:37 -04:00
Daniel Gnoutcheff
aee48901f4 Merged NM{Exported,Sysconfig}Connection
In continuation of the theme, the removal of user settings services
means that the distinction between NMSysconfigConnection and
NMExportedConnection is no longer needed. Merge NMExportedConnection
into NMSysconfigConnection.
2010-08-06 13:05:46 -04:00
Daniel Gnoutcheff
fa8c9304b5 libnm-*: remove user settings support
Remove code related to "connection scope" and such. Later, we will also
do lots of code flattening and simplification that's possible now that
user settings are gone.
2010-08-06 13:05:46 -04:00
Dan Williams
fe869a35e6 libnm-glib: ensure invalids secrets hash isn't used on error condition
Apparently dbus-glib just sends through a random address for the
hash table even if 'error' is set.  Make sure we don't pass that down
to subclasses.
2010-07-21 15:37:53 -07:00
Dan Williams
0ad8fc1adc libnm-glib: use max timeout for settings dbus calls
These calls may require authentication, and thus could be in-progress
for much longer than the default D-Bus timeout, which is pretty short.
2010-04-25 22:48:10 -07:00
Dan Williams
492eb70f75 libnm-glib: fix getting remote secrets 2009-09-16 13:50:35 -07:00
Dan Williams
cb0303180d libnm-glib: don't expose NMRemoteConnetions until they are valid
Give them time to get their settings from the remote settings service
first, then let subclasses/users/whatever know about them.
2009-08-11 10:33:13 -05:00
Dan Williams
0d69dfe39e libnm-glib: implement new settings interfaces
The old NMExportedConnection was used for both client and server-side classes,
which was a mistake and made the code very complicated to follow.  Additionally,
all PolicyKit operations were synchronous, and PK operations can block for a
long time (ie for user input) before returning, so they need to be async.  But
NMExportedConnection and NMSysconfigConnection didn't allow for async PK ops
at all.

Use this opportunity to clean up the mess and create GInterfaces that both
server and client objects implement, so that the connection editor and applet
can operate on generic objects like they did before (using the interfaces) but
can perform specific operations (like async PK verification of callers) depending
on whether they are local or remote or whatever.
2009-07-23 09:20:52 -04:00