Commit Graph

107 Commits

Author SHA1 Message Date
Dan Williams
1b37cd0340 core: allow ActiveConnections to be created without a device
The device may not be created yet (in the case of software devices)
when the ActiveConnection is created; in that case we still want to
proceed with authorization for the connection, but we'll create the
device when authorization is complete.
2013-10-31 14:15:09 -05:00
Dan Williams
a7bab4015e core: have ActiveConnection track device state instead of subclasses
Both NMActRequest and NMVPNConnection need to track their device's state,
so instead of both subclasses having to do so, consolidate that code into
the superclass.
2013-10-31 14:15:08 -05:00
Dan Williams
8252357dd1 core: watch master ActiveConnections and follow master deactivation 2013-10-31 14:15:08 -05:00
Dan Williams
4237df8c21 core: allow active connection 'master' to be set after object creation
We want to create the object earlier now, and figuring out the master is
a lot of code that we don't want to run before creating the object.  The
master still must be set before exporting the object over D-Bus though,
as before.
2013-10-31 14:15:08 -05:00
Dan Williams
0e595abcf3 core: pass NMAuthSubject around activation paths instead of uid + dbus sender 2013-10-31 14:15:08 -05:00
Dan Williams
3660a80c29 core: export new active connection from the manager
When we eventually do authorization in the ActiveConnection itself,
we want to make sure the AC doesn't get exported until everything
is authorized.  Thus let the manager handle exporting the objects
since it knows when the AC will be authorized or not.
2013-10-31 14:15:07 -05:00
Dan Williams
428ebf42b0 core: simplify NMActRequest
The 'connection' and 'device' private variables aren't needed since
they will always be available through the NMActiveConnection
superclass.
2013-10-31 14:15:07 -05:00
Colin Walters
5fcf647a28 nm-activation-request: Make use of libgsystem local allocations
Just cleaner code.

Reviewed-by: Pavel Šimerda <psimerda@redhat.com>
2013-08-29 15:16:34 -04:00
Pavel Šimerda
5affa446aa core: remove assume from nm-activation-request
Whether an active connection is assumed or connected from scratch is
only important during nm_device_activate(). When the activation process
is set up, there's no difference from any other active connection.

Acked-by: Dan Winship <danw@gnome.org>
Acked-by: Thomas Haller <thaller@redhat.com>
2013-08-22 22:06:47 +02:00
Jiri Pirko
23836e8146 core: add support for team device
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-15 10:54:15 -05:00
Dan Williams
0eb97f3ad5 agents: change secrets request hints back to char **
Previously I didn't think they'd be used for anything other than connection secrets
which only have one hint, but in the future we'll want to pass more information.
2013-06-25 17:43:39 -05:00
Dan Williams
22d2f571ce core: ensure ActiveConnections are torn down when device is unavailable (bgo #676285)
If a device becomes unmanaged or unavailable (eg, due to loss of carrier, becoming
unmanaged, rfkilled, supplicant crashing, etc), the ActiveConnection would simply
set state to UNKNOWN and the Manager wouldn't tear it down and remove it from the
ActiveConnections property list. Instead, these states should be treated the same
as if the device was deactivated cleanly so that the AC will accurately reflect
the device state and the Manager will clean the AC up.

Fixes comment #12 in:
https://bugzilla.gnome.org/show_bug.cgi?id=676285
2013-05-02 14:44:01 -05:00
Dan Williams
aa5013cf2d core: fix duplicating (not removing) active connections
This is a regression introduced by reworked active connections tracking:
7258dd270f core: add the NM_ACTIVE_CONNECTION_STATE_DEACTIVATED state
59420add04 core: track active connections directly in the manager

Because nm-manager.c:active_connection_state_changed() postpones active
connection removal to an idle handler (to be able to receive last property
change notifications), we also need to ensure that NM_ACTIVE_CONNECTION_STATE_DEACTIVATED
state is not changed again in the meantime in nm-activation-request.c:device_state_changed().
After the NMActRequest was deactivated (which is a terminal state) it was still
listening to state changes of its child NMDevice which could be starting a
new activation request.  Thus the new activation's NMDevice state would cause
the old activation request's state to change from DEACTIVATED.  To fix this
stop listening to the child NMDevice when DEACTIVATED becuase there's no point
to doing so anyway.

Reproducer:
Just activate already active connection by clicking it in nm-applet or
run 'nmcli con up id <connnection name>' several times, and then check
active connections with 'nmcli c s'.
2013-02-11 11:48:11 -06:00
Dan Williams
527cbf1924 Revert "core: fix duplicating (not removing) active connections"
This reverts commit df796527a4.

We found the real problem.
2013-02-11 11:48:11 -06:00
Jiří Klimeš
df796527a4 core: fix duplicating (not removing) active connections
This is a regression introduced by reworked active connections tracking:
7258dd270f core: add the NM_ACTIVE_CONNECTION_STATE_DEACTIVATED state
59420add04 core: track active connections directly in the manager

Because nm-manager.c:active_connection_state_changed() postpones active
connection removal to an idle handler (to be able to receive last property
change notifications), we also need to ensure that NM_ACTIVE_CONNECTION_STATE_DEACTIVATED
state is not changed again in the meantime in nm-activation-request.c:device_state_changed().

Reproducer:
Just activate already active connection by clicking it in nm-applet or
run 'nmcli con up id <connnection name>' several times, and then check
active connections with 'nmcli c s'.
2013-02-11 14:03:17 +01:00
Dan Williams
7258dd270f core: add the NM_ACTIVE_CONNECTION_STATE_DEACTIVATED state
We'll use this to know when to clean up and dispose of the
active connection in the manager.
2012-12-17 17:01:10 -06:00
Dan Williams
84603c2380 core: move most activation request logic to the active connection class
We'll want to use NMActiveConnection more in the manager and also fold
the PendingActivation functionality into it.  All this functionality
applies to the VPN connections too, so it makes sense to have it all
in the base class instead of both NMActRequest and NMVPNConnection.
2012-12-17 17:01:10 -06:00
Dan Williams
b4a11a86f7 core: rework master/slave handling 2012-11-30 13:21:51 -06:00
Jiří Klimeš
65ce4e52ef core: add some helper functions to activation request 2012-09-24 10:38:26 +02:00
Dan Williams
74e262b303 agents: add a "user-requested" flag to secret agent requests
Allows agents to provide different behavior depending on whether the
secrets request was initiated by a user (eg by picking a connection
from a UI menu or by 'nmcli con up') or was automatically started by
NetworkManager.

See https://bugzilla.gnome.org/show_bug.cgi?id=660293
2012-06-27 09:42:47 -05:00
Jiří Klimeš
78dda3b093 core: unblock signals for child processes we spawn out of NM (rh #739836)
Commit 217c5bf6ac fixed processing of unix
signals: signals are blocked in all threads and a dedicated thread handles the
signals using sigwait().
However, the commit forgot that child processes inherit signal mask as well.
That is why we have to unblock signals for child processes we spawn from NM, so
that they can receive signals.
2012-05-21 15:00:51 +02:00
Dan Williams
33d0cff3e4 core: use active connection dependency master instead of manually setting it
We already have the master device kept in the active connection, so
we can just use that instead of having the Policy determine and set
it manually.  This also should allow slaves to auto-activate their
master connections if the master is able to activate.
2012-03-01 17:40:18 -06:00
Dan Williams
db94e37eb5 core: wait for dependencies before continuing with device activation
Before jumping to activation stage 1, make sure dependencies are activated.
2012-03-01 17:40:17 -06:00
Dan Williams
0b8ff52fdd core: track active connection dependencies
Track a master active connection and emit wait/ready/fail when
it changes state.  This signal is intended for devices to
delay their activation until a master device is ready.
2012-03-01 17:40:17 -06:00
Dan Williams
7aa2a8271d core: use NMActiveConnection objects throughout activation paths
They are the basic class that tracks active connections, and we're
going to use them for connection dependencies.  So use the fact that
both NMVPNConnection and NMActRequest have the same base class
instead of using object paths.
2012-03-01 17:40:17 -06:00
Dan Williams
b378c3089c core: make NMActiveConnection a base class for NMActRequest and NMVPNConnection
That was always the goal, but never got there.  This time we need it
for real to abstract handling of dependent connections so bite the
bullet and make it happen.
2012-02-09 17:54:26 -06:00
Thomas Graf
1ba50e2f1b bonding: export path of master device property over DBUS
Adds a new "master" property to NMActiveConnection containing the path
of the master NMDevice if the connection has a master.

Signed-off-by: Thomas Graf <tgraf@redhat.com>
2012-01-25 11:12:43 -06:00
Dan Williams
bb8e9a0b18 api: add "Uuid" property to ActiveConnection interface
A convenience so that clients which might key certain operations off
which connections are active (checking work mail only when on VPN for
example) can more easily get which connections are active.  This would
allow those apps to store the UUID (which they would already be doing)
and not have to create a Connection proxy and then get the connection
properties just to retrieve the UUID of the connection.  Instead they
can now get it from GetAll of the ActiveConnection object, which they
would already be doing.
2011-04-22 12:29:07 -05:00
Dan Williams
390a5fb840 settings: return username of agent providing secrets
Mainly for VPN connections to grab the default username from, like
0.8 did when the applet provided the username to NM for user
connections.
2011-03-31 18:39:09 -05:00
Dan Williams
4e4bfeb499 core: add nm-secrets-flags.h for secret agent flags typedef
Make it clearer what's going on instead of using flags here and there
and numbers elsewhere.
2011-03-29 22:53:22 -05:00
Dan Williams
1701df4b75 core: add active connection state DEACTIVATING
Not used yet, but will be when device deactivating state gets
used.  Should be 100% backwards compatible with users that don't
know about it for now.
2011-03-17 14:23:21 -05:00
Dan Williams
b339074fd9 core: fix up active connection state for newer device states 2011-03-17 13:42:21 -05:00
Kjartan Maraas
b224ab8e56 trivial: let g_free and g_strdup handle NULL (bgo #644763) 2011-03-15 00:08:58 -05:00
Kjartan Maraas
c2b4b9c1d7 build: fix return types (bgo #644665)
Some functions were returning FALSE or 0 instead of NULL.
2011-03-14 01:05:51 -05:00
Kjartan Maraas
6d0d302916 build: do the right thing with config.h (bgo #644664)
1) it shouldn't be included in headers
2) it should be the first thing included in source files
3) it's needed for getting translation right
2011-03-14 01:01:22 -05:00
Dan Williams
0e6a5365d4 core: move secrets handling to NMSettingsConnection
It's the thing that owns the secrets anyway, and it simplifies things to
have the secrets handling there instead of half in NMActRequest and
half in NMManager.  It also means we can get rid of the ugly signals
that NMSettingsConnection had to emit to get agent's secrets, and
we can consolidate the requests for the persistent secrets that the
NMSettingsConnection owned into NMSettingsConnection itself instead
of also in NMAgentManager.

Since the NMActRequest and the NMVPNConnection classes already tracked
the underlying NMSettingsConnection representing the activation, its
trivial to just have them ask the NMSettingsConnection for secrets
instead of talking to the NMAgentManager.  Thus, only the
NMSettingsConnection now has to know about the agent manager, and it
presents a cleaner interface to other objects further up the chain,
instead of having bits of the secrets request splattered around the
activation request, the VPN connection, the NMManager, etc.
2011-01-27 10:41:02 -06:00
Dan Williams
4427774d57 agents: filter agents by UID for user-requested connections
When a user makes an explicit request for secrets via GetSecrets
or activates a device, don't ask other users' agents for secrets.
Restrict secrets request to agents owned by the user that made the
initial activate or GetSecrets request.

Automatic activations still request secrets from any available agent.
2011-01-26 18:36:08 -06:00
Dan Williams
6fc469d74a agent: pass setting name back in secrets callback 2011-01-26 13:32:25 -06:00
Dan Williams
b7259fd2a8 Merge remote branch 'origin/master' into rm-userset 2011-01-25 15:41:03 -06:00
Dan Williams
bc6fc7b910 vpn: fix VPN active connection D-Bus API handling (bgo #569294)
Due to limitations in dbus-glib, where one GObject cannot have more
than one introspection XML object attached to it, we used to include
more than one <interface> in the VPNConnection object introspection
XML.  This was suboptimal for two reasons:

1) it duplicated the Connection.Active introspection XML which
made it harder for clients to use the introspection data in a
dynamic fashion, besides looking ugly in the docs

2) not many other programs use this feature of dbus-glib, which
means it didn't get a lot of testing, and broke, which sucks
for NM.

To fix this issue, create a base class for NMVpnConnection that
handles the Connection.Active API, and make NMVpnConnection itself
handle just the VPN pieces that it layers on top.  This  makes
dbus-glib happy because we aren't using two <interface> blocks
in the same introspection XML, and it makes the NM code more
robust because we can re-use the existing Connection.Active
introspection XML in the NMVpnConnectionBase class.
2011-01-25 12:41:03 -06:00
Dan Williams
68ab26143b core: use GetSecrets flags everywhere 2011-01-18 14:57:44 -06:00
Dan Williams
4f058e2dc4 agent: ask secret agents for secrets when connection doesn't have any
Filter registered agents for each secrets request to ensure that the
connection for which secrets are requested is visible to that agent,
and add that agent to the queue.  Ask each agent in the queue until
one returns usable secrets.  Ensure that if new agents register
or existing agents quit during the secrets request, that the queue
is updated accordingly, and ensure that an agent that's already
been asked for secrets, unregisters, and re-registers before the
secrets request is comple, isn't asked for secrets twice.
2010-12-14 15:34:34 -06:00
Dan Williams
62a2c34e27 core: simplify secrets handling during activation
Instead of a bizare mechanism of signals back to the manager
object that used to be required because of the user/system settings
split, let each place that needs secrets request those secrets
itself.  This flattens the secrets request process a ton and
the code flow significantly.

Previously the get secrets flow was something like this:

nm_act_request_get_secrets ()
    nm_secrets_provider_interface_get_secrets ()
        emits manager-get-secrets signal
            provider_get_secerts ()
                system_get_secrets ()
                    system_get_secrets_idle_cb ()
                        nm_sysconfig_connection_get_secrets ()
                            system_get_secrets_reply_cb ()
                                nm_secrets_provider_interface_get_secrets_result ()
                                    signal failure or success

now instead we do something like this:

nm_agent_manager_get_secrets ()
    nm_agent_manager_get_secrets ()
        request_start_secrets ()
            nm_sysconfig_connection_get_secrets ()
                return failure or success to callback
2010-12-13 21:14:23 -06:00
Daniel Gnoutcheff
d503c09466 DBus API: removing user settings support
Remove bits from the external DBus API that were once needed for user
settings support.
2010-08-06 13:05:46 -04:00
Daniel Gnoutcheff
5fda5283b9 core: remove internal API refs. to user settings
Remove all references to connection scope and user-settings services
from the various internal APIs of the daemon. The external DBus API
remains unchanged, albeit in stub form for scope stuff.
2010-08-06 13:05:46 -04:00
Dan Williams
37c411abc9 core: add 'default6' property to ActiveConnection implementations 2010-04-15 15:26:11 -07:00
Dan Williams
acf8f7f531 core: update activation request logging 2010-04-07 11:36:38 -07:00
Noel J. Bergman
59d89050f2 sharing: fix sharing after 715ddd2045 (lp:444756)
Commit 715ddd2045 broke sharing because
sometimes a multi-argument string gets passed in rule->rule.  Revert
most of that commit.  A bunch of cleanups by dcbw too.
2009-10-06 16:46:46 -07:00
Tambet Ingo
715ddd2045 core: Make iptables path configurable
On some systems, it's located in different path...
2009-10-01 14:31:09 +03:00
Dan Williams
78bb1c01b7 core: implement connection assumption
Mark activation requests that contain connections to be assumed,
and use that to short-circuit various parts of the activation
process by not touching various device attributes, since they
are already set up.  Also ensure the device is not deactivated
when it initially becomes managed, because that would kill the
connection we are about to assume.
2009-08-05 18:03:09 -04:00