Commit Graph

1021 Commits

Author SHA1 Message Date
Dan Winship
3bfb163a74 all: consistently include config.h
config.h should be included from every .c file, and it should be
included before any other include. Fix that.

(As a side effect of how I did this, this also changes us to
consistently use "config.h" rather than <config.h>. To the extent that
it matters [which is not much], quotes are more correct anyway, since
we're talking about a file in our own build tree, not a system
include.)
2014-11-13 17:18:42 -05:00
Jiří Klimeš
beec6c87ff libnm-util: fix typos in libnm-util documentation 2014-11-13 10:21:34 +01:00
Thomas Haller
ce7fc351db libnm: add NMSettingIPConfig:route-metric
https://bugzilla.gnome.org/show_bug.cgi?id=735512
https://bugzilla.redhat.com/show_bug.cgi?id=663730

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:06 +01:00
Dan Williams
1f544d337c vpn: allow plugins to indicate 'can-persist' capability
The plugin can indicate that this connection can persist across link
changes and other connectivity dropouts by passing this option
back in the SetConfig() calls.
2014-11-06 21:17:34 -06:00
Dan Williams
2b9e442013 libnm/libnm-util: add VPN 'persistent' property
This property will indicate that the user wishes the VPN connection
to stay active until explicitly disconnected, even across link changes
or other interruptions.
2014-11-06 21:16:57 -06:00
Thomas Haller
b77567b225 build: fix -Wstrict-prototypes warnings
We disabled -Wstrict-prototypes in commit
db9b1df0e4 .
Fix compiler warnings.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-29 12:30:11 +01:00
Thomas Haller
1cc7b8d027 libnm-util: add _nm_setting_get_property() function
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 21:17:17 +02:00
Thomas Haller
1464c5a11e libnm: add function _nm_setting_get_setting_priority()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 21:17:17 +02:00
Thomas Haller
68bc95c12f libnm-util: let nm_setting_diff() be symetric not to return properties that are set to default
Previously, nm_setting_diff() (and thus nm_connection_diff()), returned
only properties that are different AND not set to the default value.
However, if the opposite setting 'B' was missing, it would always
include all properties from 'A', even the default ones.

This behaviour was asymetric. Add two new compare flags
@NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT and
@NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT to control the
behaviour of whether to include default properties.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 21:17:17 +02:00
Thomas Haller
978724da96 libnm-util: don't assert in nm_setting_get_secret_flags() and avoid assertion in agent_secrets_done_cb()
When secret providers return the connection hash in GetSecrets(),
this hash should only contain secrets. However, some providers also
return non-secret properties.

for_each_secret() iterated over all entries of the @secrets hash
and triggered the assertion in nm_setting_get_secret_flags() (see
below).

NM should not assert against user provided input. Change
nm_setting_get_secret_flags() to silently return FALSE, if the property
is not a secret.

Indeed, handling of secrets is very different for NMSettingVpn and
others. Hence nm_setting_get_secret_flags() has only an inconsistent
behavior and we have to fix all call sites to do the right thing
(depending on whether we have a VPN setting or not).

Now for_each_secret() checks whether the property is a secret
without hitting the assertion. Adjust all other calls of
nm_setting_get_secret_flags(), to anticipate non-secret flags and
assert/warn where appropriate.

Also, agent_secrets_done_cb() clears now all non-secrets properties
from the hash, using the new argument @remove_non_secrets when calling
for_each_secret().

  #0  0x0000003370c504e9 in g_logv () from /lib64/libglib-2.0.so.0
  #1  0x0000003370c5063f in g_log () from /lib64/libglib-2.0.so.0
  #2  0x00007fa4b0c1c156 in get_secret_flags (setting=0x1e3ac60, secret_name=0x1ea9180 "security", verify_secret=1, out_flags=0x7fff7507857c, error=0x0) at nm-setting.c:1091
  #3  0x00007fa4b0c1c2b2 in nm_setting_get_secret_flags (setting=0x1e3ac60, secret_name=0x1ea9180 "security", out_flags=0x7fff7507857c, error=0x0) at nm-setting.c:1124
  #4  0x0000000000463d03 in for_each_secret (connection=0x1deb2f0, secrets=0x1e9f860, callback=0x464f1b <has_system_owned_secrets>, callback_data=0x7fff7507865c) at settings/nm-settings-connection.c:203
  #5  0x000000000046525f in agent_secrets_done_cb (manager=0x1dddf50, call_id=1, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_username=0x1e51710 "thom", agent_has_modify=1, setting_name=0x1e91f90 "802-11-wireless-security",
      flags=NM_SETTINGS_GET_SECRETS_FLAG_ALLOW_INTERACTION, secrets=0x1e9f860, error=0x0, user_data=0x1deb2f0, other_data2=0x477d61 <get_secrets_cb>, other_data3=0x1ea92a0) at settings/nm-settings-connection.c:757
  #6  0x00000000004dc4fd in get_complete_cb (parent=0x1ea6300, secrets=0x1e9f860, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_username=0x1e51710 "thom", error=0x0, user_data=0x1dddf50) at settings/nm-agent-manager.c:1139
  #7  0x00000000004dab54 in req_complete_success (req=0x1ea6300, secrets=0x1e9f860, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_uname=0x1e51710 "thom") at settings/nm-agent-manager.c:502
  #8  0x00000000004db86e in get_done_cb (agent=0x1e89530, call_id=0x1, secrets=0x1e9f860, error=0x0, user_data=0x1ea6300) at settings/nm-agent-manager.c:856
  #9  0x00000000004de9d0 in get_callback (proxy=0x1e47530, call=0x1, user_data=0x1ea10f0) at settings/nm-secret-agent.c:267
  #10 0x000000337380cad2 in complete_pending_call_and_unlock () from /lib64/libdbus-1.so.3
  #11 0x000000337380fdc1 in dbus_connection_dispatch () from /lib64/libdbus-1.so.3
  #12 0x000000342800ad65 in message_queue_dispatch () from /lib64/libdbus-glib-1.so.2
  #13 0x0000003370c492a6 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
  #14 0x0000003370c49628 in g_main_context_iterate.isra.24 () from /lib64/libglib-2.0.so.0
  #15 0x0000003370c49a3a in g_main_loop_run () from /lib64/libglib-2.0.so.0
  #16 0x000000000042e5c6 in main (argc=1, argv=0x7fff75078e88) at main.c:644

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 21:17:17 +02:00
Dan Winship
a91e60902e libnm-core: make NMSettingSerial:parity an enum
NMSettingSerial:parity was defined as a char-typed property that could
have the (case-sensitive!) values 'n', 'E', or 'o'. This is zany. Add
an NMSettingSerialParity enum, and use that instead.
2014-10-03 09:36:28 -04:00
Thomas Haller
47555449fa libnm: add bonding option "lacp_rate" to NMSettingBond
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-02 16:36:03 +02:00
Dan Winship
98e4a2be30 libnm-core, libnm-util: remove some useless code in nm-settings.c
g_object_class_list_properties() can't return NULL if called
correctly.

Also remove two failed attempts to use g_value_transform():
nm_setting_new_from_hash() was transforming src_value to its own type
(rather than to param_spec->value_type, which was presumably
intended), so it was a no-op (in addition to being unnecessary anyway,
since GObject will attempt to transform the value internally if
needed). And update_one_secret() was calling g_value_transform() on an
uninitialized GValue, so it would have always hit a
g_return_val_if_fail() in g_value_transform() if that code was ever
reached (which apparently it wasn't).
2014-09-04 09:17:36 -04:00
Dan Winship
799922c14b libnm-util: generate-plugin-docs.pl-related fixes
generate-plugin-docs.pl was assuming that it was being run out of
srcdir, and so failed in srcdir!=builddir builds (such as "make
distcheck"). Fix that.

Also, update .gitignore
2014-09-03 23:06:00 -04:00
Jiří Klimeš
291674d82e libnm-util: add ifcfg-rh specific description for properties
as comments in libnm-util/nm-setting-*.c files
The comments are parsed by generate-plugin-docs.pl script.
2014-08-29 13:59:54 +02:00
Jiří Klimeš
71e07344ab libnm-util: add keyfile specific description for properties
as comments in libnm-util/nm-setting-*.c files
The comments are parsed by generate-plugin-docs.pl script.
2014-08-29 13:59:54 +02:00
Jiří Klimeš
1c2174a802 libnm-util: generate-plugin-docs.pl script for extracting plugin docs
The scripts extracts plugin description from document comments for particular
properties and builds a XML file out of the data. The XML file can be used
later for generating manual pages or other documentation.

Unfortunately, gtk-doc won't allow descriptions that would be separated from
the main gtk-doc stuff. But it is still useful to have plugin description bits
co-located with property definitions. We use our home-grown comments and parse
them ourself. Afterall it's not that bad, and in addition it brings us a
freedom in shaping the comments to our needs.
2014-08-29 13:59:44 +02:00
Thomas Haller
0fe0e62d68 libnm-util: properly disconnect "notify" signal for settings in NMConnection
When removing/replacing a NMSetting in an NMConnection, we have
to disconnect setting_changed_cb() from the "notify" signal.

Backport commit dfba4ce1e1 from
libnm-core.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-22 15:26:34 +02:00
Thomas Haller
8bb4c54090 libnm-core: fix NMSettingConnection:verify() not to modify interface-name
verify() used to modify interface-name of the base settings. This is
discouraged, because verify() should not touch the connection.

For libnm-core we can change behavior and only modify the connection
in normalize().

Also, be more strict not to verify() sucessfully on invalid
interface-name.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-22 15:24:31 +02:00
Thomas Haller
66d88dc00f libnm-core: add normalize of MTU for NMSettingInfiniband
Previously, NMSettingInfiniband:verify() silently modifies the
setting for invalid MTU. verify() should not do that.

For libnm-core we can change behavior and implement normalization
of MTU. This changes behavior for NMSettingInfiniband:verify() so
that MTU gets no longer fixed by verify() alone. Instead verify()
fails with a verification error.

Due the possibility to normalize the MTU, NM still can receive
invalid settings and fix it.

For libnm-core we don't change behavior, merely add a code comment.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-22 15:24:31 +02:00
Dan Williams
e7381662fe trivial: don't shadow rand(3)
Reported by Jordan Messina

(cherry picked from commit 365ca198c0d688e759cd2481d9446ba16f8e78ca)
2014-08-20 14:18:14 -05:00
Thomas Haller
25aa0a0705 libnm-core: fix crash in NMSettingAdsl:verify()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-19 00:13:11 +02:00
Thomas Haller
c6a1ca53cd build: fix generate-setting-docs.py to work with python3
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-12 13:04:35 +02:00
Dan Winship
b64c82a3ed libnm-util: don't warn about unrecognized properties
libnm-util is expected to end up behind the curve in terms of knowing
about new NMSetting properties, so if it sees an unknown property, it
should just assume that there will also be a backward-compatibility
equivalent rather than printing a warning.

(In particular, it should not warn when it sees the
"ipv4.address-labels" property now that it now longer knows about it.)
2014-08-08 12:15:10 -04:00
Dan Winship
964b9f3513 libnm-core, libnm-util: convert test-crypto, test-setting-8021x.c to gtestutils
Rather than having test-crypto and test-setting-8021x be programs that
you have to pass arguments to to get them to run a single test, just
have them run all of the tests themselves.

This lets us get rid of the big "check-local" rule in Makefile.am and
just use TESTS to run everything.

https://bugzilla.gnome.org/show_bug.cgi?id=734388
2014-08-07 15:57:19 -04:00
Thomas Haller
242d350fcf libnm-util/test: fix tests not to write a core file
test_libnm_linking() executes ./test-libnm-linking which
is supposed to crash. When the user set `ulimit -c unlimited`
before, this will leave a left-over core file.

In case of `make distcheck`, this is quite bad because it lets
the make target fail:

    ERROR: files left in build directory after distclean:
    ./libnm-util/tests/core.31481

Fix this by setting the (soft) rlimit for writing core files
to 0 before executing the test binary.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-04 16:17:36 +02:00
Thomas Haller
536029a96d libnm-util/tests: fix build for older glib with unknown G_SPAWN_DEFAULT
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-04 13:30:37 +02:00
Thomas Haller
cb5a976191 libnm-util/test: fix build for clang due to deprecated warning
For clang, we have to include nm-glib-compat.h to redefine
G_GNUC_BEGIN_IGNORE_DEPRECATIONS.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 21:42:04 +02:00
Dan Winship
d7b56c7b7e libnm, libnm-utils: error out if mixed libnm/libnm-util symbols are detected
If a program accidentally ends up linking in both libnm and libnm-util
(presumably via different dependencies), error out immediately.
2014-08-01 14:34:40 -04:00
Dan Winship
b9fef07fff libnm-util: remove NM_UTIL_PRIVATE_CALL, NMSettingIP4Config:address-labels
Since libnm-util is no longer used from within NM, its copy of
NM_UTIL_PRIVATE_CALL is now useless, and the internal-only
NMSettingIP4Config:address-labels property is no longer needed.
2014-08-01 14:34:05 -04:00
Thomas Haller
b835111129 libnm-util, core: fix warning about signed integer overflow (-Wstrict-overflow)
gcc warns:

    make[4]: Entering directory `./NetworkManager/libnm-util'
      CC       nm-value-transforms.lo
    nm-value-transforms.c: In function '_nm_utils_convert_op_array_to_string':
    nm-value-transforms.c:121:6: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
       if (i > 0)
          ^
    nm-value-transforms.c: In function '_nm_utils_convert_string_array_to_string':
    nm-value-transforms.c:121:6: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
       if (i > 0)
          ^

    make[7]: Entering directory `./NetworkManager/src/settings/plugins/ifcfg-rh'
      CC       reader.lo
    reader.c: In function 'make_wired_setting':
    reader.c:3295:6: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
       if (!found)
          ^
    reader.c: In function 'wireless_connection_from_ifcfg':
    reader.c:3295:6: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
       if (!found)
          ^

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 13:17:01 +02:00
Thomas Haller
22ca469011 libnm-util: fix warning converting between enum types in nm-setting-8021x.c
clang warns:

    make[4]: Entering directory `./NetworkManager/libnm-util'
      CC       nm-setting-8021x.lo
    nm-setting-8021x.c:1824:17: error: implicit conversion from enumeration type 'NMCryptoFileFormat' to different enumeration type 'NMSetting8021xCKFormat' [-Werror,-Wenum-conversion]
                    *out_format = format;
                                ~ ^~~~~~
    nm-setting-8021x.c:2135:17: error: implicit conversion from enumeration type 'NMCryptoFileFormat' to different enumeration type 'NMSetting8021xCKFormat' [-Werror,-Wenum-conversion]
                    *out_format = format;
                                ~ ^~~~~~

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 13:16:59 +02:00
Dan Williams
fa809c2636 build: clean nm-version.h
Now that nm-version.h.in lives in libnm-util/, a stale nm-version.h
from include/ messes up the build with errors about NM_VERSION_*.
Clean both old & new nm-version.h on 'make clean' so that we can
switch branches between nm-0-9-8, nm-0-9-10, and git master and
just run 'make clean' and get things to work.
2014-07-31 21:31:20 -05:00
Dan Winship
1c7e3d85fc libnm-util: fix enum member names in a gtk-doc comment 2014-07-23 17:18:03 -04:00
Dan Winship
7d1e0c3781 libnm-util: fix gtk-doc syntax in nm-version.h to avoid a warning 2014-07-23 17:18:03 -04:00
Thomas Haller
ac4fafe7a4 platform: assert against the maximum length of link_get_address()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-23 12:42:45 -05:00
Jiří Klimeš
4c36ff7062 include: add NM_DEVICE_CAP_IS_SOFTWARE capability
for marking software devices.
2014-07-22 14:24:42 +02:00
Thomas Haller
2fdaa29f08 libnm-util: fix leak in _nm_connection_verify()
Regression introduced by commit 2570c5a17c.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-15 21:57:34 +02:00
Dan Winship
30c74c6007 build: more srcdir!=builddir fixes
nm-version.h was getting disted, making srcdir!=builddir work for
tarball builds, but not for git builds.

Also, remove "-I${top_builddir}/include" from all Makefile.ams, since
there's nothing generated in include/ any more.
2014-07-15 11:37:19 -04:00
Dan Winship
6e51e460df libnm-util: NetworkManager.h/NetworkManagerVPN.h doc fixups
Add gtk-docs for enum types that previously didn't have them.

Explicitly note the relationship between NetworkManager.h /
NetworkManagerVPN.h types and the corresponding introspection/*.xml
types.
2014-07-15 09:44:55 -04:00
Dan Winship
2570c5a17c libnm-util, libnm-glib: whitespace fixes
Fix indentation, kill trailing whitespace, split some long lines.
2014-07-15 09:44:55 -04:00
Dan Winship
cb7e1893e7 libnm-util, libnm-glib: standardize copyright/license headers
- Remove list of authors from files that had them; these serve no
  purpose except to quickly get out of date (and were only used in
  libnm-util and not libnm-glib anyway).

- Just say "Copyright", not "(C) Copyright" or "Copyright (C)"

- Put copyright statement after the license, not before

- Remove "NetworkManager - Network link manager" from the few files
  that contained it, and "libnm_glib -- Access network status &
  information from glib applications" from the many files that
  contained it.

- Remove vim modeline from nm-device-olpc-mesh.[ch], add emacs modeline
  to files that were missing it.
2014-07-15 09:44:54 -04:00
Dan Winship
4223fa47e4 libnm-util, libnm-glib: tweak (element-type) annotations in docs
g-i allows you to specify types in annotations using either their
fully-qualified introspected names (eg, "NMClient.Device") or their
plain C names ("NMDevice"). Switch from the former to the latter (so
that they'll still be correct when migrated to libnm later).
2014-07-15 09:44:54 -04:00
Dan Winship
7eb0288aa0 libnm-util: move NetworkManager.h, etc, from include/ to here
NetworkManager.h, NetworkManagerVPN.h, and nm-version.h are part of
the libnm-util API, so move them to libnm-util.

include/ still contains headers that are strictly NM-internal (eg,
nm-glib-compat.h).
2014-07-15 09:44:54 -04:00
Dan Winship
09da178639 libnm-util: fix build with --with-crypto=gnutls
The non-"_t"-suffixed type names in gnutls have been deprecated since
1.x, and in recent versions will trigger deprecation warnings. Fix by
using "gnutls_datum_t" instead of "gnutls_datum".
2014-07-11 12:09:39 -04:00
Dan Winship
da25a788fa trivial: add a missing word to documentation 2014-07-07 14:04:51 -04:00
Thomas Haller
63070fff02 build: call generate-setting-docs.py directly instead of through strace
This was added for debugging, but is no longer necessary.
Also, strace might not be installed on any system so don't depend on it.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-04 13:43:59 +02:00
Dan Williams
6cb6d39725 libnm-util: merge nm-util-private and nm-utils-private
No reason to have two differently named files for the
same general purpose.
2014-07-02 13:33:58 -05:00
Dan Williams
2428401f5e docs: fix multi-line Since notation 2014-07-01 15:47:54 -05:00
Thomas Haller
29d538239f libnm-util: normalize IP settings in connection
This is the same behaviour as nm_utils_normalize_connection(),
which will soon be removed in favor of nm_connection_normalize().

This takes care, that normal connections always have an IP4 and IP6 setting,
and that slave connections never have it.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-30 18:35:46 +02:00