Commit Graph

105 Commits

Author SHA1 Message Date
Thomas Haller
97935382f4 coverity: fix various warnings detected with Coverity
These are (most likely) only warnings and not severe bugs.
Some of these changes are mostly made to get a clean run of
Coverity without any warnings.

Error found by running Coverity scan

https://bugzilla.redhat.com/show_bug.cgi?id=1025894

Co-Authored-By: Jiří Klimeš <jklimes@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:29:24 +01:00
Thomas Haller
f059298896 trivial: whitespace fix
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-07 21:32:08 +01:00
Dan Winship
5bcdfd3985 libnm-util: remove reference to non-existent "Posix" namespace
There's no way in gobject-introspection to annotate something as
returning an arbitrary C struct type, so don't try.
2013-10-11 10:16:41 -04:00
Dan Winship
76cc2bd9df libnm-util, libnm-glib: fix up some gtk-doc comments
gtk-doc recognizes that #NMFoos is the plural of #NMFoo now, so you
don't need to put an empty comment between the type name and the "s"
to make it work. (Unfortunately, it's not smart enough to realize that
"NMIP4Addresses" is the plural of "NMIP4Address".)

Also, add some missing "#"s noticed along the way.
2013-10-11 10:16:14 -04:00
Daniel Drake
3f4811be22 libnm-util: accept old-style UUIDs as valid
Old versions such as 0.9.4 generated 40-character UUIDs with no
hashes, but libnm-util regards them as invalid. That means that
existing connections stop working when upgrading from 0.9.4.

Continue accepting such UUIDs as valid, and add a test so that
we don't forget in future.
2013-09-09 08:20:37 -05:00
Jiří Klimeš
0e57603e43 libnm-util: nm_utils_hwaddr_aton_len() allow hyphens in MAC string (rh #1002553)
http://en.wikipedia.org/wiki/MAC_address#Notational_conventions
Both 01:23:45:67:89:ab and 01-23-45-67-89-ab are used and valid.
2013-09-02 10:08:02 +02:00
Dan Winship
9a73db17d5 libnm-util: add nm_utils_hwaddr_valid() 2013-06-13 15:52:51 -03:00
Dan Winship
82ac7da754 libnm-util: add hwaddr functions that take length rather than type
Add nm_utils_hwaddr_ntoa_len() and nm_utils_hwaddr_aton_len(), which
take a length rather than a type, which is generally more convenient,
and also necessary if you might be encountering devices of unknown
types.
2013-06-11 09:27:45 -03:00
Dan Winship
43617d4c1d libnm-util: deprecate nm_utils_slist_free(), use g_slist_free_full() 2013-05-29 17:13:30 -03:00
Jiří Klimeš
bfc20af513 libnm-util: fix WEP key type comparison in nm_utils_wep_key_valid() 2013-05-03 10:11:56 +02: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 Winship
5fec30d98e Revert :carrier-detect properties and associated code
Ignoring carrier is generally something you want at the machine level
(eg, for a server), not at the connection level.
2013-04-03 10:23:49 -04:00
Jiří Klimeš
2109f41cc6 libnm-util: consolidate hex-string <-> bin conversion functions
and move them to libnm-util's nm-utils.s so that they are easily available.
2013-03-28 16:59:58 +01:00
Dan Winship
331b69bd90 libnm-util: split GValue transforms out of nm-utils.c
nm-utils.c is really big, so split the GValue transforms out into
their own file.
2013-03-26 12:15:49 -04: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 Williams
80886c2866 libnm-glib: work around possible compiler bug with GValueArray deprecation workarounds
GValueArray is deprecated.  Unfortunately, it's part of our API right now,
so we have to keep it around for a while.  But since it's deprecated, and
we want to know about *other* deprecations, we have to suppress deprecations
about GValueArray.  Unfortunately using macros to do that (eg in
nm-gvaluearray-compat.h) exposes some compiler bugs due to the combination
of parentheses/braces and #pragma from G_GNUC_BEGIN_IGNORE_DEPRECATIONS,
resulting in warnings like:

nm-utils.c:920:9: error: expected expression before ‘#pragma’

Work around this by not trying to stuff what's now a macro (eg
g_value_array_get_nth) into what's already a macro (G_VALUE_TYPE).
There's probably a better way to do this...
2013-02-27 17:16:27 +01:00
Dan Winship
ed9e2d8377 build: avoid GValueArray deprecation warnings
Avoid warnings about GValueArray being deprecated by adding macros
that wrap G_GNUC_BEGIN_IGNORE_DEPRECATIONS /
G_GNUC_END_IGNORE_DEPRECATIONS around the GValueArray calls.
2013-02-26 13:07:33 +01:00
Dan Williams
873550592c libnm-util: add Since tags to new functions and properties 2013-02-22 08:34:06 -06:00
Dan Winship
5266e25e2b libnm-utils: add :carrier-detect properties
For settings corresponding to devices that have a :carrier property
(ie bond, bridge, infiniband, vlan, and wired), add a :carrier-detect
property specifying how that affects the connection:

  yes: The connection can only be activated when the device
      has carrier, and will be deactivated if the device loses
      carrier (for more than 4 seconds).
  no: The connection ignores carrier on the device; it can be
      activated when there is no carrier, and stays activated
      when carrier is lost.
  on-activate: The connection can only be activated when the
      device has carrier, but it will not be deactivated if the
      device loses carrier.

https://bugzilla.gnome.org/show_bug.cgi?id=688284
2013-02-15 13:40:38 -05:00
Dan Winship
d04f286327 all: remove pointless NULL checks
g_malloc(), etc, never return NULL, by API contract. Likewise, by
extension, no other glib function ever returns NULL due to lack of
memory. So remove lots of unnecessary checks (the vast majority of
which would have immediately crashed had they ever run anyway, since
g_set_error(), g_warning(), and nm_log_*() all need to allocate
memory).

https://bugzilla.gnome.org/show_bug.cgi?id=693678
2013-02-13 13:38:13 -05:00
Jiří Klimeš
bf610255a1 libnm-util: move verify_wep_key() and verify_wpa_psk() to nm-utils.c
and rename them to nm_utils_wep_key_valid(), nm_utils_wpa_psk_valid().
They are general functions and can also be used elsewere usefully.
2013-02-06 13:29:58 +01:00
Jiří Klimeš
c0458cb433 docs: correct the description of nm_utils_ap_mode_security_valid() 2012-10-18 11:01:06 +02:00
Dan Williams
e6bdb8bc55 libnm-util: add methods for AP-mode security filtering
Add a helper like nm_utils_security_valid() except for access point
mode.  We can't use nm_utils_security_valid() without changing the
arguments, hence the new function.  Plus in AP mode all you care about
are the device capabilities, not AP flags since the device *is*
the AP.
2012-10-17 14:07:37 -05:00
Dan Winship
6878d20ac4 all: Don't use ctype.h macros
The ctype macros (eg, isalnum(), tolower()) are locale-dependent. Use
glib's ASCII-only versions instead.

Also, replace isascii() with g_ascii_isprint(), since isascii()
accepts control characters, which isn't what the code wanted in any of
the places where it was using it.
2012-09-26 12:14:37 -04:00
Dan Winship
74b6b9c768 libnm-util: move nm_utils_is_uuid() here
This is useful outside the daemon too, so move it into libnm-utils.
2012-09-26 12:14:37 -04:00
Dan Williams
81ff3b0f44 libnm-util: minor cleanups for nm_utils_iface_valid_name() 2012-08-29 17:55:03 -05:00
Thomas Graf
b46508b5c6 libnm-util: move dev_valid_name() to libnm-util and make it public
The bridging code needs it as well.
2012-08-29 17:46:54 -05:00
Dan Williams
f19c33b56f docs: clarify byte order of returned value from nm_utils_ip4_prefix_to_netmask() 2012-08-13 11:00:54 -05:00
Jiří Klimeš
00297f49fb libnm-util: add nm_utils_file_is_pkcs12() for checking PKCS#12 file format 2012-07-16 14:59:59 +02:00
Colin Walters
c9aa5f76cf Fix various bits of broken gtk-doc
There was some duplication, syntax errors, etc.
2012-06-14 13:56:48 -04:00
Dan Williams
69247a00ea wifi: disable Ad-Hoc WPA connections (lp:905748)
The kernel is broken for Ad-Hoc WPA, and creates the connections
as open connections instead.  Yeah, eventually we can use
wpa_supplicant with RSN support, but for now we just have to
disable Ad-Hoc WPA because it's a problem to say we're creating
a protected network but then have the kernel not do that for
us.  Will be re-enabled once all the necessary bits have been
fixed.

Note that Ad-Hoc WPA has been broken since at least 2.6.32 with
mac80211-based drivers, which is what most users will be using.
2012-03-16 17:58:23 -05:00
Jiří Klimeš
bb6da998b2 libnm-util: do not assert on buggy drivers with no WEP cipher capabilities
The crash happens with ipw2200, kernel 3.2.0 when a user tries to connect
to a hidden network using nm-applet.
g_assert (have_ap); is hit in 'case NMU_SEC_STATIC_WEP:' branch.

Reported by Mathieu Trudel-Lapierre.
See also:
(lp:908516)
(lp:908380)
2012-03-13 15:37:11 +01:00
Dan Williams
ca27121ad6 libnm-util: register more GValue transformations for debugging 2012-02-07 12:33:03 -06:00
Dan Williams
a080a1ed08 libnm-util: fix some introspection annotations 2011-12-22 11:04:56 -06:00
Dan Williams
1f8090fb58 libnm-util: add nm_utils_hwaddr_type()
Returns the address type given the length.
2011-12-02 13:09:16 -06:00
Dan Williams
6e4eb4902e libnm-util: fix nm_utils_hwaddr_aton() for input with no leading zeros
ether_aton() allows addresses like "0:1:2:3:4:5" which was casusing
some problems when reading connections after switching callers of
ether_aton() to nm_utils_hwaddr_aton().
2011-12-02 13:09:16 -06:00
Dan Winship
2510c617ec libnm-util: add ether_ntoa/ether_aton-like utility methods
nm_utils_hwaddr_ntoa() and nm_utils_hwaddr_aton() are like
ether_ntoa()/ether_aton(), but handle IPoIB too.

nm_utils_hwaddr_atoba() is like _aton() but returns a GByteArray,
since that's what's wanted in many places.

Also remove nm_ether_ntop() and replace uses of it with
nm_utils_hwaddr_ntoa().
2011-11-17 13:37:08 -06:00
Dan Williams
a5c2c47b3e wifi: make wireless-helper.h private to src/
The less stuff that needs WEXT the better.
2011-11-09 21:28:02 -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
2a5617c22b docs: update documentation for nm_utils_security_valid() 2011-08-22 20:33:07 -05:00
Dan Williams
07c9de48df libnm-util: fix symbol export checks to catch un-exported ones too
The current check caught stuff in the .ver file that was outdated, but
didn't quite get stuff that was supposed to be exported but wasn't,
in some cases.  Update the regex to ensure that symbols that are
not exported, but that start with "nm_" (and aren't GObject
boilerplate) get flagged during the check.

Update internal code to return to a previous pattern of treating symbols
that start with "_" internal, and expecting symbols that start with
"nm_" to be exported.

Also fixes cases where random glibc symbols would get flagged:

00040ff4 l     O *ABS*  00000000              .hidden _GLOBAL_OFFSET_TABLE_
00041380 l     O .data  00000000              .hidden __dso_handle
000406e8 l     O .dtors 00000000              .hidden __DTOR_END__
0000fbe4 l     F .text  00000000              .hidden __i686.get_pc_thunk.cx
0002f980 l     F .text  00000014              .hidden __stack_chk_fail_local
0000b1e7 l     F .text  00000000              .hidden __i686.get_pc_thunk.bx
00040e60 l     O *ABS*  00000000              .hidden _DYNAMIC
2011-05-05 12:26:17 -05:00
Dan Williams
a2fc80b0ea libnm-util: document nm_utils_ip6_dns_to_gvalue() 2011-05-02 22:54:28 -05:00
Dan Williams
5b0ef4c201 libnm-util: don't ever deinit crypto methods (bgo #646300)
Because we can't ever know if we're the last user of NSS or gnutls
when nm_utils_deinit() is called, just don't bother deiniting
the crypto providers.  And atexit handlers are generally frowned
upon for the exact same reason.  You never know what library linked
into your process might be also using NSS or gnutls, so basically
if these libraries suck enough to use global data and not reference
count it, just let the data leak.  If we do clean stuff up that
can lead to crashes when other libraries might try to use NSS or
gnutls after the atexit handler or nm_utils_deinit() has been run.

See also:  https://bugzilla.mozilla.org/show_bug.cgi?id=54189#c1
2011-03-31 13:29:19 -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
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
b599e3e5dc libnm-util: simplify nm_utils_ssid_to_utf8()
It's always used with a GByteArray anyway, as are most
functions in nm-utils.h.  Even better, we can skip the
memcpy since it turns out to be pointless.
2011-02-23 11:24:58 -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
Jiří Klimeš
b3800183b4 libnm-util: fix nm_utils_security_valid() checks for Ad-Hoc APs (rh #632123)
Without the fix fake Ad-Hoc APs created by nm-applet's "Create New Wireless
Network..." don't pass the check and nm-applet can crash.
2010-12-16 14:03:04 +01:00
Dan Williams
f257c98193 libnm-util: register transform func for G_TYPE_STRV to GPtrArray
Needed for S390 subchannels property of the wired setting.
2010-07-28 10:05:22 -07:00
Dan Williams
a5d8872c3e Merge remote branch 'origin/master' into zvm 2010-06-17 21:14:09 -07:00