Commit graph

140 commits

Author SHA1 Message Date
Jiří Klimeš
9549c70d94 core: fix auto-connect to hidden SSIDs (rh #707406)
Previously (in NM 0.8.x) most WiFi connection were from user settings service.
And the service updated 'seen-bssids' property when got connected.
But the settings service in 0.9 don't do that. That inhibits auto-connecting to
hidden networks. This commit takes care of updating 'seen-bssids'. However, we
don't want to write out the conection each time it's activated (touching /etc).
So, seen BSSIDs are kept separately from the connection in a look-aside file.

Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
2011-06-08 14:51:27 -05:00
Jiří Klimeš
060e865ecd core: trivial whitespace fixes 2011-06-08 14:51:27 -05:00
Dan Williams
9cba854fa0 settings: ensure transient secrets are ignored when rereading connections (rh #703785)
When a connection changes on-disk, the in-memory copy of it may contain
transient secrets (agent-owned or not saved) that dont' get written out
to disk.  When comparing the on-disk copy to the in-memory copy make sure
transient secrets are ignored so that we don't re-read the on-disk copy
needlessly.
2011-06-07 18:39:18 -05:00
Dan Williams
d2ae0bac82 keyfile: better handle cert/key files that don't exist (bgo #649807)
The keyfile code has to handle a few different formats of cert/key values,
and wasn't doing a good enough job of detecting plain paths as values.  By
default the writer will write out a plain path (ie, not prefixed with file://)
and the reader will handle that correctly, *unless* that file does not
exist, at which the reader assumed it was a byte array.  This caused the
read-in keyfile not to match the in-memory connection (since the in-memory
connection though the cert/key held a path, but the read-in one thought it
contained a blob) and this seems to eventually have triggered a write-out
with the new values (as a blob), which would then drop a .pem file into
system-connections/ containing the path that should have been in the
keyfile in the first place.

This all happened because we assumed that the given path for the cert or
key would actually be valid, which doesn't seem to be the case for a lot
of people.  Clearly these connections won't work (since the certificate or
key does not exist) but the keyfile plugin shouldn't be messing up the
connection's settings at the very least.

Fix that by handling the check of whether the cert/key data is a path or
not in a less restrictive manner and add some testcases to make sure that
everything works as we expect.
2011-06-01 16:51:47 -05:00
Dan Williams
0f37efd77b keyfile: write relative cert/key paths too
If the cert/key path is relative to the keyfile then don't
bother writing the absolute path out.  This also prevents the
keyfile plugin from rewriting a relative path to an absolute one,
preventing some annoyance for people that hand-edit keyfiles.
2011-06-01 16:51:47 -05:00
Dan Williams
06ec2a5382 keyfile: convert relative cert/key paths to absolute ones when reading
Passing a relative path to wpa_supplicant does no good since the supplicant
may not have the same working directory as NetworkManager.  Relative paths
used in keyfiles are assumed to be relative to the keyfile itself anyway,
so actually use the absolute path we compute for the cert/key instead of
leaving it relative.
2011-06-01 16:10:58 -05:00
Dan Williams
c1dd530798 keyfile: ignore .pem and .der file changes
Since the keyfile plugin only stores the paths of these files,
we don't really care about what's in them.  We also don't want
to attempt to read them as keyfiles, which produces warnings
in the logs.
2011-06-01 13:26:25 -05:00
Dan Williams
232bb3cea2 settings: suppress warnings about NULL hash tables 2011-05-26 19:43:19 -05:00
Dan Williams
e75f5bc862 settings: only update transient secrets if they exist
Otherwise here the transient_secrets GHashTable will be NULL, and
g_hash_table_iter_init() doesn't like that much.
2011-05-25 18:52:55 -05:00
Dan Williams
730f10d707 settings: ensure connection changes don't overwrite transient secrets
Here's the problem:

- NM requests secrets
- secret agent returns secrets including some that are agent-owned or
  not-saved (ie, transient secrets)
- for whatever reason (other secrets are system-owned, whatever) the
  connection gets written back out to disk
- at some point later inotify triggers a connection re-read from disk
- the connection is read from disk, but doesn't contain the agent-owned
  or not-saved secrets, because they obviously don't get saved
- nm_settings_connection_replace_and_commit() blows away the agent-owned
  or not-saved secrets that the agent originally returned
- device activation no longer has the transient secrets

Re-reading connection data from disk shouldn't change transient secrets;
instead we need to merge the just-read system-owned secrets with whatever
transient secrets an agent sent.  Transient secrets should only be cleared
by nm_connection_clear_secrets() to ensure that they stick around for as
long as we need them.
2011-05-25 11:44:28 -05:00
David Woodhouse
1951029908 core: complete the openconnect migration hack; add flags for the saved secrets too (bgo #650383)
Commit e083cd5c63 stopped openconnect from
saving its secrets. It'd been working for a whole three minutes since my
previous commit.

We need to have at least one secret with an *extant* flags setting of
NM_SETTING_SECRET_FLAG_NONE, in order to trigger a write-out of the new
set of secrets. And we might as well list all the secrets we *know* the
auth-dialog is going to use, although we know there will be some secrets
that we cannot predict in advance (the form entry boxes).
2011-05-23 13:54:03 -05:00
Dan Williams
c0387ffbc5 core: treat VPN secrets without flags as system-owned
All non-VPN secrets are considered system-owned if they do not
have any explicitly set secret flags, and this makes VPN secrets
treated the same way.  As part of the import process plugins and
the applet already update secret flags.  This ensures that VPN
secrets are treated consistently throughout the codebase.
2011-05-23 13:45:51 -05:00
Dan Williams
e083cd5c63 settings: when checking for system-owned secrets ignore NOT_SAVED
Previously a secret marked NOT_SAVED or NOT_REQUIRED would be
treated as a system secret when checking returned secrets.  That's
incorrect since unsaved or not required secrets aren't stored
by system settings.
2011-05-19 13:14:51 -05:00
David Woodhouse
05a959d1d6 settings: fix VPN secret flag handling in secrets returned from agents
We need to push one more level down into VPN secrets when checking
the secret flags on VPN settings.
2011-05-19 13:11:49 -05:00
Dan Williams
304d0b869b core: openconnect migration hack
Evil hack; but the problem is that before this commit anyone who
migrated connections wouldn't have the right secrets flag set in
their openconnect connections.  Figuring out some way of updating
those connections now is harder and we don't want people to have
to go through the delete-connection-file-change-applet-stamp-rerun
dance.  So we'll live with this for now...
2011-05-18 22:45:24 -05:00
Dan Williams
f79dcb9560 core: consolidate PolicyKit code
Use one global PolkitAuthority object; we only really need to use it
in one place anyway.  So consolidate the code that uses polkit into
nm-manager-auth.c.
2011-05-18 22:20:24 -05:00
Dan Williams
2bcd4016b4 settings: clean up signal handlers when destroying connections
Otherwise we might get crashes later.
2011-05-04 17:13:03 -05:00
Dan Williams
30c63ddcb7 settings: fix assertion checks 2011-05-04 17:12:35 -05:00
Dan Williams
4cae0bb0fa settings: add a GetConnectionByUuid method
If the client knows the UUID, add a convenience function to get
the connection path directly, instead of having to iterate the
whole connection list and get each connection's details and then
check the UUID.
2011-04-22 12:29:07 -05:00
Jiří Klimeš
e30287aa84 ifcfg-rh: fix emitting signal for unmanaged specs when removing connection (rh #698202)
The signal was emitted in case the removed connection was managed instead of
for unmanaged connection. Thus the signal had no effect.
That caused incorrect behaviour in case of changing NM_CONTROLLED=no to yes.
That didn't enable the device; only after the file was changed for the second time.
2011-04-20 12:26:20 -04:00
Dan Williams
258912524e ifcfg-rh: fix writing out WPA connection which is changed to open (rh #695604)
We need to remember to clear out keys that aren't getting used since
we're not rewriting the whole ifcfg file.
2011-04-19 15:42:08 -05:00
Dan Williams
b946cbb3b8 settings: simplify some code 2011-04-19 00:26:07 -05:00
Dan Williams
6cbaf8a7ef settings: fix refcount mismatch (bgo #647066)
The default wired connection should own a reference to the device
it's made for, but that got dropped in
78df8c49a1, which used to use a
set_property handler with g_value_dup_object() which obviously
increments the reference count.  But that ref got dropped when
the object initialization was simplified.
2011-04-19 00:23:43 -05:00
Dan Williams
a234c6b80c trivial: remove some dead code 2011-04-19 00:22:46 -05:00
Jiří Klimeš
0acd1d322b ifcfg-rh: fix some memory leaks in tests (test-ifcfg-rh.c) 2011-04-14 16:57:34 +02:00
Jiří Klimeš
0937b985da ifcfg-rh: fix some memory leaks in ifcfg-rh plugin 2011-04-14 16:56:20 +02:00
Jiří Klimeš
dae8ab9be9 ifcfg-rh: fix memory leaks in tests (test-ifcfg-rh-utils.c) 2011-04-14 12:00:32 +02:00
Jiří Klimeš
92b55e709a ifcfg-rh: fix read-after-free error in reader.c 2011-04-14 11:41:55 +02:00
Jiří Klimeš
b7b5599fb3 ifcfg-rh: add testcases for IPv4 manual addresses 2011-04-14 10:53:26 +02:00
Jiří Klimeš
ccd39a8cb9 ifcfg-rh: adjust handling IPADDRn, PREFIXn (NETMASKn) and GATEWAYn (rh #658907)
Now that initscripts also support IPADDRn syntax, update the implementation
to match the intitscripts' one (see rh #633984)
Basically, writer produces IPADDR0 .. IPADDR255. reader is more tolerant and
supports older configs too: IPADDR, IPADDR0, IPADDR1 could be missing, from
IPADDR2 up the indexes have to be contiguous.
2011-04-14 10:30:51 +02:00
Dan Williams
d90e6423c8 ifcfg-rh: fix up s390 CTC adapter reading and writing (bgo #647578) (rh #641986) 2011-04-12 15:38:47 -05:00
Dan Williams
5af6a4baec ifcfg-rh: add testcase for S390 CTC-type connections (bgo #647578) (rh #641986) 2011-04-12 15:03:09 -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
85d364d765 settings: fix getting default wired connection name with no connections
Due to an error in the loop logic, if there were no connections yet (like
a fresh install or a livecd or whatever) no default name would be returned
and thus ethernet devices wouldn't come up automatically.  Fix that loop
error and add testcases for it.
2011-03-30 12:02:50 -05:00
Dan Williams
bc9803f92d settings: fix requesting new secrets when the old ones don't work
If the connection had system secrets, previously the settings core
would consider those sufficient even if the device code had requested
new secrets because the old ones didn't work.
2011-03-29 22:56:08 -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
78df8c49a1 settings: name the default wired connection "Wired connection x"
Where 'x' is a number that's not yet used by any existing connection.
And clean up the default wired class initialization.  This name is
more friendly than "Auto eth0" which was confusing to quite a few
people.  This also checks to ensure there's no other connection with
the same name, which the old method did not.

Suggested by Jon McCann.
2011-03-27 16:57:14 -05:00
Dan Williams
6cbb44bc97 ifcfg-rh: fix some missing tests in tarball
The tests were missing, and because of the way the test was structured,
the tests passed.
2011-03-21 17:44:47 -05:00
Dan Williams
d815cb9f33 logging: fix format string/argument disagreement
Now that the logging fixes make format checking actually work, fix
the issues it brings up.
2011-03-19 12:44:14 -05:00
Mu Qiao
8d60cafd18 ifnet: fix tests and distcheck 2011-03-17 11:05:46 -05:00
Dan Williams
c3dc2a0608 agents: only commit connection changes if there were system secrets
It's pointless to save the connection if there weren't any system
secrets being changed.
2011-03-16 20:53:49 -05:00
Dan Williams
e89a50d779 agents: don't complain when there aren't any system secrets 2011-03-16 20:53:13 -05:00
Mu Qiao
08b2fa5401 ifnet: plugin updates and shared connection support 2011-03-16 15:39:13 -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
af7e26b39a ifcfg-rh: fix reading and writing of Dynamic WEP with EAP-LEAP connections
These are distinct from old-school LEAP (ie, Network EAP) in that
they are standard Dynamic WEP with LEAP as an EAP method and use
open-system authentication.  Old LEAP uses the non-standard LEAP
authentication algorithm.  The config for each is different and thus
we need to make sure we handle both cases.
2011-03-14 00:25:14 -05:00
Dan Williams
eaeb43bfad keyfile: ignore temp files ending with ~ 2011-03-13 23:59:09 -05:00
Michael Biebl
8119ecf6b0 core: depend on stable gudev API 2011-03-10 03:19:27 -06:00
Dan Williams
5c260cfe4a keyfile: trivial whitespace fixes 2011-03-08 10:19:01 -06:00