Commit Graph

15047 Commits

Author SHA1 Message Date
Thomas Haller
3744544920 core: log when emitting RECHECK_ASSUME signal
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-24 16:12:45 +02:00
Thomas Haller
bda076bb3c core: add macros NM_FLAGS_HAS(), NM_FLAGS_ANY() and NM_FLAGS_ALL()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-24 16:12:45 +02:00
Dan Williams
3adeffe1f1 man: clarify that keyfile is a fallback if no distro plugin is present
Distro plugins are intended to be used by default, and keyfile only if
distro plugins cannot read/write certain connection types.
2014-09-23 12:22:22 -05:00
Jiří Klimeš
37f12088e4 tui: additional fix for 'primary' option
The entry can't be empty. Otherwise removing the value and saving connection
would result in the primary option containing only the first character of the
original value.
2014-09-23 08:27:49 +02:00
Thomas Haller
54ed36e3c0 nmtst: fix compiler warnings and make initialization of macro variables explict
clang warns about uninitialized variables @__cur_setting_name and
@__cur_property_name as used inside @__code. Before calling to @__code,
explicitly initialize the values.

    Making all in tests
    make[4]: Entering directory `./NetworkManager/libnm-core/tests'
      CC       test-general.o
    test-general.c:2730:24: error: variable '__cur_property_name' is uninitialized when used here [-Werror,-Wuninitialized]
                                  NMTST_VARIANT_DROP_PROPERTY (NM_SETTING_CONNECTION_SETTING_NAME,
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../include/nm-test-utils.h:1079:20: note: expanded from macro 'NMTST_VARIANT_DROP_PROPERTY'
                                && !strcmp (__cur_property_name, __property_name)) \
                                            ^~~~~~~~~~~~~~~~~~~
    ../../include/nm-test-utils.h:1023:3: note: expanded from macro 'NMTST_VARIANT_EDITOR'
                    __code; \
                    ^
    test-general.c:2729:2: note: variable '__cur_property_name' is declared here
            NMTST_VARIANT_EDITOR (connection_dict,
            ^
    ../../include/nm-test-utils.h:1015:3: note: expanded from macro 'NMTST_VARIANT_EDITOR'
                    const char *__cur_setting_name, *__cur_property_name; \
                    ^
    [...]

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-22 16:34:18 +02:00
Thomas Haller
1aeb0c6df3 nmtst: move #endif to hide NMTST_VARIANT_* macros if not needed
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-22 16:32:01 +02:00
Thomas Haller
351cf9b328 libnm: fix warning about returning zero instead of %NULL in _nm_object_create()
clang warns:
    make[4]: Entering directory `./NetworkManager/libnm'
      CC       nm-object.lo
    nm-object.c:640:11: error: expression which evaluates to zero treated as a null pointer constant of type 'GObject *' (aka 'struct _GObject *') [-Werror,-Wnon-literal-null-conversion]
                            return G_TYPE_INVALID;
                                   ^~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:57:26: note: expanded from macro 'G_TYPE_INVALID'
    #define G_TYPE_INVALID                  G_TYPE_MAKE_FUNDAMENTAL (0)
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:221:36: note: expanded from macro 'G_TYPE_MAKE_FUNDAMENTAL'
    #define G_TYPE_MAKE_FUNDAMENTAL(x)      ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    nm-object.c:655:11: error: expression which evaluates to zero treated as a null pointer constant of type 'GObject *' (aka 'struct _GObject *') [-Werror,-Wnon-literal-null-conversion]
                            return G_TYPE_INVALID;
                                   ^~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:57:26: note: expanded from macro 'G_TYPE_INVALID'
    #define G_TYPE_INVALID                  G_TYPE_MAKE_FUNDAMENTAL (0)
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:221:36: note: expanded from macro 'G_TYPE_MAKE_FUNDAMENTAL'
    #define G_TYPE_MAKE_FUNDAMENTAL(x)      ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    2 errors generated.

Fixes: b3c4917b0f
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-22 16:32:01 +02:00
Thomas Haller
85566e46d9 libnm-core: fix crash in update-secrets when trying to clear all settings without providing a connection variant
When the caller wants to clear all settings (thus providing
@setting_name NULL), a NM_VARIANT_TYPE_CONNECTION variant is
expected. This would lead to a crash when constructing the
@error literal due to uninitialized @key.

Clang also warns:

    Making all in .
    make[4]: Entering directory `./NetworkManager/libnm-core'
      CC       nm-connection.lo
    ../libnm-core/nm-connection.c:1016:25: error: variable 'key' is uninitialized when used here [-Werror,-Wuninitialized]
                                                 key);
                                                 ^~~
    ../libnm-core/nm-connection.c:962:17: note: initialize the variable 'key' to silence this warning
            const char *key;
                           ^
                            = NULL
    1 error generated.

Fixes: acf86f68b3
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-22 16:16:41 +02:00
Jiří Klimeš
3784678177 cli: create a connection if none exist in 'nmcli dev connect' (rh #1113941)
https://bugzilla.redhat.com/show_bug.cgi?id=1113941
2014-09-22 13:10:43 +02:00
Jiří Klimeš
cb4c9d9dba merge: enhance nmcli checks whether NetworkManager is running (bgo #698060) 2014-09-22 12:54:18 +02:00
Jiří Klimeš
dc1c17fd30 cli: get NMClient early and remove duplicated code 2014-09-22 12:53:46 +02:00
Jiří Klimeš
f27a259ee6 cli: when NM is not running, give this error in 'nmcli connection'
Check whether NM is running before comparing nmcli and NM versions. Returning
NMC_RESULT_ERROR_NM_NOT_RUNNING is in accordance with other nmcli commands.
2014-09-22 12:53:46 +02:00
Lubomir Rintel
82947737b1 cli: return a failure status when the daemon is not running (bgo #698060)
Applies to status commands such as "nmcli radio" or "nmcli g status".
This is consistent with other commands.

The "RUNNING" field is now always "running", the tool will just return
an error instead of setting it to "not running". It never signalled
whether the daemon was actually running anyway, only whether the client
managed to connect to it.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
2014-09-22 12:53:46 +02:00
Jiří Klimeš
2f369559cb tui: fix displaying bond ARP IP targets
GLib-GObject-WARNING **: g_object_set_valist: object class `NmtAddressList' has no property named `string'
2014-09-22 12:30:44 +02:00
Jiří Klimeš
b0b51ec5ef tui: don't call g_strv_length() on NULL
GLib-CRITICAL **: g_strv_length: assertion `str_array != NULL' failed
2014-09-22 12:25:20 +02:00
Lubomir Rintel
efd09845c4 platform: increase NL buffer for systems with lots of interfaces (rh #1141256)
Seems like 128k is not enough for systems with many interfaces. This adds 4k
per device, while keeping the 128k minimum. Therefore this change only
affects systems with more than 32 interfaces.

https://bugzilla.redhat.com/show_bug.cgi?id=1141256
2014-09-22 11:17:12 +02:00
Lubomir Rintel
a36a3a9a52 tui/bond: remove primary option if mode is not active-backup (rh #1142864)
Just drop it as we disable the widget in UI.

https://bugzilla.redhat.com/show_bug.cgi?id=1142864
2014-09-22 10:54:15 +02:00
Jiří Klimeš
8ee53b79f6 cli: fix crash by getting addresses and routes
Broken by commit 6793a32a8c that changed
return values from GSlist to GPtrArray.
2014-09-19 22:59:39 +02:00
Jiří Klimeš
7966b6c05f ifcfg-rh: fix typo in function name and enhance testcase
The testcase now includes an invalid value too.

Added by commit  8657b4229c.
2014-09-19 21:19:18 +02:00
Dan Williams
24ab568826 core: fix stray 'break' in switch
From 82222d389 "core: move carrier handling to NMDevice"
2014-09-19 12:07:00 -05:00
Dan Williams
e4f218875d core: fix 'tun' device owner/group property getters
The properties are int64, but get_property() was was using
g_value_set_uint().
2014-09-19 12:07:00 -05:00
Dan Winship
f6f79aa433 libnm: simplify private D-Bus connection tracking
dcbw points out that g_dbus_connection_get_unique_name() can be used
to distinguish private from bus connections without us needing to keep
track ourselves.
2014-09-19 10:45:12 -04:00
Dan Winship
8f7b1e87c2 libnm: fix private bus async codepaths
_nm_dbus_new_connection_async() wasn't marking the connection as
private when it was private, causing
_nm_dbus_new_proxy_for_connection*() to pass the wrong args. Fix that.
2014-09-19 10:35:04 -04:00
Dan Winship
c6f4c354fe tui: fix an earlier bugfix
Fix to f69842aa; the arguments weren't swapped, one of them was just
completely superfluous.
2014-09-19 10:05:46 -04:00
Dan Winship
2e197706b7 tui: fix a double free
The dictionary passed to the NMSecretAgent get_secrets callback will
get sunk if it's floating, so we shouldn't be unreffing it.
2014-09-19 09:43:01 -04:00
Dan Winship
783e37a288 tui: bind the leap-username property to its entry 2014-09-19 09:10:24 -04:00
Dan Winship
f49f57591b all: fix client handling of hidden SSIDs (bgo #736802) 2014-09-19 09:08:50 -04:00
Jiří Klimeš
4359e556e4 tui,examples: accept null SSID gracefully
Signed-off-by: Jiří Klimeš <jklimes@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=736802
2014-09-19 09:07:16 -04:00
Dan Winship
8f6d056b31 libnm: fix nm_access_point_get_ssid() return value
nm_access_point_get_ssid() used to return NULL if the AP didn't have a
visible SSID. This got broken in the NM_TYPE_SSID -> G_TYPE_BYTES
change. Fix that. (Fixes a crash in nmtui and nmcli with SSID-less
APs.)

https://bugzilla.gnome.org/show_bug.cgi?id=736802
2014-09-19 09:06:20 -04:00
Lubomir Rintel
b769c059f3 contrib/rpm: libnm-vpn is no more
Removed in: [280b1e506] libnm: merge libnm-vpn into libnm

https://bugzilla.gnome.org/show_bug.cgi?id=736954
2014-09-19 08:35:21 -04:00
Lubomir Rintel
5f54ed3a27 libnm: avoid init_async NULL dereference on cancellable=0x0
(gdb) run c add type bond
  Starting program: /usr/bin/nmcli c add type bond
  Got object file from memory but can't read symbols: File truncated.
  [Thread debugging using libthread_db enabled]
  Using host libthread_db library "/lib64/libthread_db.so.1".
  [New Thread 0x7ffff39b2700 (LWP 13042)]
  [New Thread 0x7fffec4bc700 (LWP 13043)]

  (process:13038): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

  Program received signal SIGTRAP, Trace/breakpoint trap.
  g_logv (log_domain=0x7ffff5cda224 "GLib-GObject", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd290) at gmessages.c:1046
  1046              g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
  (gdb) bt
  #0  0x00007ffff59b6c70 in g_logv (log_domain=0x7ffff5cda224 "GLib-GObject", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd290) at gmessages.c:1046
  #1  0x00007ffff59b6eaf in g_log (log_domain=log_domain@entry=0x7ffff5cda224 "GLib-GObject", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7ffff5a25a9d "%s: assertion '%s' failed")
      at gmessages.c:1079
  #2  0x00007ffff59b6ee9 in g_return_if_fail_warning (log_domain=log_domain@entry=0x7ffff5cda224 "GLib-GObject", pretty_function=pretty_function@entry=0x7ffff5cdd6b3 <__FUNCTION__.13314> "g_object_ref", expression=expression@entry=0x7ffff5cdc388 "G_IS_OBJECT (object)") at gmessages.c:1088
  #3  0x00007ffff5cb39aa in g_object_ref (_object=_object@entry=0x0) at gobject.c:3041
  #4  0x00007ffff7ad5418 in _nm_dbus_new_connection_async (cancellable=0x0, callback=<optimized out>, user_data=<optimized out>) at nm-dbus-helpers.c:131
  #5  0x00007ffff7ae58f1 in handle_property_changed (synchronously=0, pi=0x5555558a9610, value=0x7fffe40138a0, property_name=<optimized out>, self=0x555555831980 [NMRemoteSettings]) at nm-object.c:1115
  #6  0x00007ffff7ae58f1 in handle_property_changed (self=self@entry=0x555555831980 [NMRemoteSettings], dbus_name=<optimized out>, value=<optimized out>, synchronously=synchronously@entry=0) at nm-object.c:1186
  #7  0x00007ffff7ae59cb in process_properties_changed (self=0x555555831980 [NMRemoteSettings], properties=<optimized out>, synchronously=0) at nm-object.c:1218
  #8  0x00007ffff7ae5a7a in property_proxy_signal (proxy=<optimized out>, sender_name=<optimized out>, signal_name=<optimized out>, parameters=<optimized out>, user_data=0x555555831980) at nm-object.c:1234
  #9  0x00007ffff4d34d60 in ffi_call_unix64 () at ../src/x86/unix64.S:76
  #10 0x00007ffff4d347d1 in ffi_call (cif=cif@entry=0x7fffffffd7e0, fn=<optimized out>, rvalue=0x7fffffffd740, avalue=avalue@entry=0x7fffffffd6c0) at ../src/x86/ffi64.c:525
  #15 0x00007ffff5cca2ef in <emit signal ??? on instance 0x555555881c10 [NMDBusSettingsProxy]> (instance=instance@entry=0x555555881c10, signal_id=<optimized out>, detail=detail@entry=0) at gsignal.c:3365
      #11 0x00007ffff5caf6f4 in g_cclosure_marshal_generic (closure=0x5555558aa400, return_gvalue=0x0, n_param_values=<optimized out>, param_values=<optimized out>, invocation_hint=<optimized out>, marshal_data=0x0) at gclosure.c:1448
      #12 0x00007ffff5caeed5 in g_closure_invoke (closure=0x5555558aa400, return_value=return_value@entry=0x0, n_param_values=4, param_values=param_values@entry=0x7fffffffda10, invocation_hint=invocation_hint@entry=0x7fffffffd9b0) at gclosure.c:768
      #13 0x00007ffff5cc1202 in signal_emit_unlocked_R (node=node@entry=0x555555819270, detail=detail@entry=0, instance=instance@entry=0x555555881c10, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7fffffffda10) at gsignal.c:3553
      #14 0x00007ffff5cca0c1 in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7fffffffdbd0) at gsignal.c:3309
  #16 0x00007ffff63d8bcc in on_signal_received (connection=<optimized out>, sender_name=0x0, object_path=<optimized out>, interface_name=<optimized out>, signal_name=0x7fffe40195b0 "PropertiesChanged", parameters=0x7fffe4031000, user_data=0x5555558a3f30) at gdbusproxy.c:917
  #17 0x00007ffff63c83b4 in emit_signal_instance_in_idle_cb (data=0x7fffe403a6d0) at gdbusconnection.c:3753
  #18 0x00007ffff59afb6b in g_main_context_dispatch (context=0x5555557eb530) at gmain.c:3064
  #19 0x00007ffff59afb6b in g_main_context_dispatch (context=context@entry=0x5555557eb530) at gmain.c:3663
  #20 0x00007ffff59aff08 in g_main_context_iterate (context=0x5555557eb530, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3734
  #21 0x00007ffff59b0232 in g_main_loop_run (loop=0x5555557e3440) at gmain.c:3928
  #22 0x000055555556fd57 in main (argc=<optimized out>, argv=<optimized out>) at nmcli.c:587
  (gdb)

https://bugzilla.gnome.org/show_bug.cgi?id=736962
2014-09-19 08:33:15 -04:00
Jiří Klimeš
1b229c4d95 libnm-core: don't return with a value in function returning void
set_property_from_dbus()
2014-09-19 09:36:24 +02:00
Dan Winship
67853793cf Port libnm and clients to gdbus (bgo #622927) 2014-09-18 11:51:13 -04:00
Dan Winship
6793a32a8c libnm: port to GDBus
Port libnm-core/libnm to GDBus.

The NetworkManager daemon continues to use dbus-glib; the
previously-added connection hash/variant conversion methods are now
moved to NetworkManagerUtils (along with a few other utilities that
are now only needed by the daemon code).
2014-09-18 11:51:09 -04:00
Dan Winship
16871ebc38 libnm-core: update tests to be fully variant-based
Use nmtst_variant_editor() to rewrite the libnm-core tests to work
entirely in connection dictionaries, not connection hash tables.
2014-09-18 11:51:09 -04:00
Dan Winship
58f278fbfb nmtst: add NMTST_VARIANT_EDITOR()
Several test programs create connection hashes and then modify them in
various ways. This becomes much more complicated with GVariants, since
they are immutable. Add NMTST_VARIANT_EDITOR() to simplify the process
of iterating the old variant and building a new, slightly-modified one.
2014-09-18 11:51:09 -04:00
Dan Winship
acf86f68b3 libnm-core: change connection hash tables to variants in API
In preparation for porting to GDBus, make nm_connection_to_dbus(),
etc, represent connections as GVariants of type 'a{sa{sv}}' rather
than as GHashTables-of-GHashTables-of-GValues.

This means we're constantly converting back and forth internally, but
this is just a stepping stone on the way to the full GDBus port, and
all of that code will go away again later.
2014-09-18 11:51:09 -04:00
Dan Winship
4750559548 libnm: rename nm-dbus-helpers-private.h to nm-dbus-helpers.h
The .h file should have the same name as the .c file.
2014-09-18 11:51:08 -04:00
Dan Winship
acf4b5a572 libnm: split nm-dbus-helpers utils into sync/async versions
dbus-glib's functions to get a DBusGConnection or a DBusGProxy return
right away, but gdbus's corresponding functions do some initial setup
and communication as part of initialization, and so either block or
run async. So split _nm_dbus_new_connection() and
_nm_dbus_new_proxy_for_connection() into sync and async versions now,
and update NMObject to use the correct one depending on whether it is
working synchronously or asynchronously.
2014-09-18 11:51:08 -04:00
Dan Winship
b3c4917b0f libnm: move most of the subclass-type-deciding code into NMObject
NMObject has a system that lets devices and active connections get
created as the correct subtypes (NMDeviceFoo / NMActiveConnection vs
NMVpnConnection). But it was much more generic than it needed to be,
because NMDevice and NMActiveConnection both did the same thing (fetch
a D-Bus property and then look at its value). So move the
property-fetching part into NMObject, and only use the callback for
converting the property value to a GType.
2014-09-18 11:51:08 -04:00
Dan Winship
b728d1fb70 libnm: let NMObject create all D-Bus proxies
Add _nm_object_class_add_interface(), for declaring that a class
implements a particular interface, and then have NMObject create the
corresponding proxies itself. (The subclass can get a copy with
_nm_object_get_proxy() if it needs it for something).

(In GDBus, creating a proxy is a heavier operation than in dbus-glib,
so we'll need to create the proxies asynchronously. Moving the
creation to NMObject makes that easier since we can do it as part
of the existing init/init_async.)
2014-09-18 11:51:08 -04:00
Dan Winship
aa18b88a4f libnm: don't hardcode things like "org.freedesktop.DBus.Properties"
Use the #defines provided by libdbus instead.
2014-09-18 11:51:08 -04:00
Dan Winship
280b1e5067 libnm: merge libnm-vpn into libnm
There's not much point in keeping them separate: all existing
libnm-glib-vpn users also link against libnm-glib, and the amount of
extra code added to libnm by merging in libnm-vpn is negligible.

Additionally, nm-vpn-plugin will later need access to some
libnm-internal APIs.

So, merge them together.
2014-09-18 11:51:07 -04:00
Dan Winship
bc003f6273 tools: fix test-networkmanager-service Settings.Connections
The test settings service wasn't exporting a Connections property.
2014-09-18 11:51:07 -04:00
Dan Winship
5f5a89b98a Port callouts to gdbus (bgo #622927) 2014-09-18 11:50:23 -04:00
Dan Winship
8d26c45184 dispatcher: make test-dispatcher-envp not take an argument
Compile srcdir into test-dispatcher-envp rather than passing it on the
command-line, to make it easier to run by hand, and so we can use
automake's TESTS support.
2014-09-18 11:34:21 -04:00
Dan Winship
1a5cfc1f45 dispatcher: port to GDBus
Port nm-dispatcher to GDBus, mostly, using dbus-glib's GVariant
utilities to translate the return value of nm_connection_to_dbus().
2014-09-18 11:26:59 -04:00
Dan Winship
408e86dd35 dispatcher: trivial code rearrangement
Reorganize some code in preparation for the GDBus port. (Most of the
diff is actually just reindentation.)

This also makes explicit something that was probably a bug;
IP4_NUM_ROUTES is always set, even if it's "0" (while the same is not
true of IP6_NUM_ROUTES). (This behavior is preserved for
compatibility.)
2014-09-18 11:04:26 -04:00
Dan Winship
ab4199c785 libnm-core: add GVariant-based versions of IP structure-manipulating utilities 2014-09-18 11:04:25 -04:00
Dan Winship
4fab71b466 callouts: port nm-avahi-autoipd.action to GDBus 2014-09-18 11:04:25 -04:00