Commit graph

11493 commits

Author SHA1 Message Date
Petr Vorel
2d9befcb41 examples: bash: print errors int stderr
+ whitespace

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
(cherry picked from commit 1e646f30f2)
2015-03-18 15:08:31 -05:00
Lubomir Rintel
6a147dff87 device: if there's a ll address already don't re-commit it
Configuration commit is an unsafe thing to do for assumed connections,
it can remove an externally added address we don't know about yet.

The device already has a link-local address; for an assumed connection
it's the reason we assumed the method=link-local in the first place.

(cherry picked from commit 396dc2b3b4)
2015-03-17 17:19:00 +01:00
Lubomir Rintel
409c0fb544 device: fix a couple of copy & paste errors
(cherry picked from commit a8a9955d75)
2015-03-17 17:18:59 +01:00
Lubomir Rintel
4c8cbc6534 device: do not touch sysctls after the device was removed
Paths to sysctls don't use ifindex and device names can be reused. If someone
removes a device and quickly creates a device with the same name, chances are
we're cleaning up the device that was just added.

Sadly, it seems there's no better API than sysctl-- neither netlink nor procfs
symlinks with ifindex or anything like that.

(cherry picked from commit f85513b8e4)
2015-03-17 17:18:58 +01:00
Thomas Haller
71316327bb libnm: fix error prefix in NMSettingGsm:verify()
(cherry picked from commit d198618aa7)
2015-03-17 12:10:49 +01:00
Dan Williams
46c836e5cd connectivity: disable HTTP keepalive for connectivity checks
There won't be any further requests, so there's no point in keeping
the connection alive.  Even if the HTTP server doesn't care, proxy
servers in-between might keep the connection open for a couple seconds
for keepalive, and we might as well be nice to them and tell them we
don't need to keep it alive.

(cherry picked from commit 90692e3eff)
2015-03-16 10:49:36 -05:00
Thomas Haller
da27c799ad valgrind: fix suppressions for Fedora 20
Fixes: 266f133797
(cherry picked from commit 641a57994c)
2015-03-16 11:46:51 +01:00
Dan Williams
0bf4c1e5d5 valgrind: fix suppression for newer glib
(cherry picked from commit 28983b705c)
2015-03-16 11:43:17 +01:00
Dan Williams
266f133797 valgrind: update suppressions for newer glib and toolchain changes
It appears that the .isra and .part pieces can change depending on
how glib was built, so ignore those parts.  Add some new suppressions
for newer glib too.

(cherry picked from commit 3cde821344)
2015-03-16 11:43:17 +01:00
Lubomir Rintel
97541f055a libnm,nm-object: fix tracing of object removal
When a new connection is activated and presently active connection goes away,
the active-connection-removed signal is not emitted for the old connection.
This is what happens:

1.) Initially, nm-manager::active-connections = [ActiveConnection/old]

2.) First PropertyChange is signalled for the new connection addition:
nm-manager::active-connections = [ActiveConnection/old,ActiveConnection/new]

This triggers load of ActiveConnection/new object.

3.) Another PropertyChange is signalled for the old connection removal:
nm-manager::active-connections = [ActiveConnection/new]

This removes the ActiveConnection/old object from
nm-manager::active-connections and enqueues active-connection-removed
signal. The signal is not emmitted as there's a reload from 2.) in progress.

4.) ActiveConnection/new reload finished

object_property_complete() compares
[ActiveConnection/old,ActiveConnection/new] from its odata to current
nm-manager::active-connections and incorrectly concludes that
ActiveConnection/old was just added and removes the enqueued
active-connection-removed signal.

This patch fixes the issue by remembering the original
nm-manager::active-connections property value at 2.).

[thaller@redhat.com: fixed an integer overflow and odata->array unreffing]

https://bugzilla.redhat.com/show_bug.cgi?id=1079353
(cherry picked from commit dba4e8ece8)
2015-03-16 10:57:09 +01:00
Thomas Haller
050301d4d7 merge branch 'th/memleaks-nm-1-0' into nm-1-0
Backport several memleak fixes from master and enable
VALGRIND for most tests.

With valgrind enabled, I get sometimes non-reproducible failures
in src/tests/test-general-with-expect (monotonic_timestamp_get())
and libnm/tests/test-nm-client.c:911.

Still, merge it to have tests enabled in the first place. Possibly
fix them later.

https://mail.gnome.org/archives/networkmanager-list/2015-March/msg00041.html
2015-03-13 12:06:01 +01:00
Thomas Haller
545fbd2b09 config/test: fix memleaks in test-config.c 2015-03-13 11:50:51 +01:00
Thomas Haller
d510f0a039 config: fix memleak in merge_no_auto_default_state() 2015-03-13 11:50:51 +01:00
Thomas Haller
537ce96fa2 config/tests: inject NMDBusManager for tests in NMDevice stub
We don't need the bus for the tests and the manager may warn when it
is not available.

  $ (cd src/tests/config/; env -i DBUS_SYSTEM_BUS_ADDRESS=meow ./test-config)

  /config/parse-error: OK
  /config/no-auto-default: NetworkManager-Message: <info>  Could not connect to the system bus; only the private D-Bus socket will be available.
  /bin/sh: line 5: 29997 Trace/breakpoint trap   ${dir}$tst
  FAIL: test-config

This reverts commit 6994454461 for the
most part. It's not sufficient to disable logging warnings. Creating
a DBus Manager might affect the system in undesired ways.

(cherry picked from commit 5040a8a851)
2015-03-13 11:50:51 +01:00
Thomas Haller
36a136fb58 config/test: move test over to nm-test-util
(partially cherry picked from commit 13c7f6a56d)

Conflicts:
	src/tests/config/test-config.c
2015-03-13 11:50:51 +01:00
Thomas Haller
91144ee070 dbus-manager: add nm_dbus_manager_setup() function for testing
(cherry picked from commit 9b16e85ece)
2015-03-13 11:50:50 +01:00
Thomas Haller
07786f6ee6 dbus-manager: refactor singleton getter dropping g_once_init_enter()
The class itself is not thread-safe, so no need for guarding
the creation with g_once_init_*().

Also, assert against multiple creation and log a line when
creating the singleton. The getter is now more similar to what
is created by NM_DEFINE_SINGLETON_GETTER().

(cherry picked from commit 99465a34ca)
2015-03-13 11:50:50 +01:00
Thomas Haller
04f22b9a44 dbus: destroy singleton instance of NMDBusManager on exit
Don't have the singleton instance of NMDBusManager owned by
the main function. Instead use NM_DEFINE_SINGLETON_DESTRUCTOR()
which also logs what's happening.

(cherry picked from commit 1208c0dd13)

Conflicts:
	src/main.c
2015-03-13 11:50:50 +01:00
Thomas Haller
62bff65e14 core/trivial: rename singleton variables according to default name
(cherry picked from commit 822cb293ef)
2015-03-13 11:50:50 +01:00
Thomas Haller
d1c79fbe93 all: add macro NM_DEFINE_SINGLETON_GETTER()
(cherry picked from commit e725887c3a)
2015-03-13 11:50:50 +01:00
Thomas Haller
cea32bd0dc core: fix memleak in NMDBusManager:private_server_new()
(cherry picked from commit 96b8b99c7d)
2015-03-13 11:50:50 +01:00
Dan Williams
c505658815 ifcfg-rh: fix memleak in test-ifcfg-rh.c
(cherry picked from commit ad90f2f0ea)
2015-03-13 11:50:50 +01:00
Dan Williams
33264396c9 tests: fix memleaks in test-wifi-ap-utils.c
(cherry picked from commit 51b3540ae4)
2015-03-13 11:50:50 +01:00
Thomas Haller
ca7aac000c tests: allow running tests without valgrind by setting NMTST_NO_VALGRIND
When configuring with --with-valgrind, tests will be invoked
via valgrind. That significantly slows down the tests. Allow
user to set the environment variable NMTST_NO_VALGRIND to invoke
tests directly, even when valgrind was enabled at configure time.

(cherry picked from commit 95a750e4fa)
2015-03-13 11:50:50 +01:00
Lubomir Rintel
411fa7d002 test: initialize auto-destructed pointers
Otherwise the compiler complains that they could be left uninitialized in case
the function returns too early.

Fixes: 76745817c3
(cherry picked from commit 2981839bde)
2015-03-13 11:50:50 +01:00
Thomas Haller
87dc7af2dd libnm-glib/tests: fix calling tests without valgrind
Fixes: e7356ef0a6
(cherry picked from commit b0b15e4718)
2015-03-13 11:50:50 +01:00
Thomas Haller
7ab98c3e6f core: merge branch 'th/memleaks'
Fix memleaks and enable valgrind checks for most unit tests except
ifupdown plugin. For ifupdown tests, there are some leaks that are
not yet fixed. This is still to do.

To run checks with valgrind, configure with --with-valgrind.

Especially for libnm and libnm-glib tests, there are several leaks
that are (probably?) not the fault of NetworkManager code. Hence,
several suppressions were added to valgrind.suppressions.
On different systems and different version of glib, these suppressions
might not match and the test will fail there.

The valgrind.suppressions should be reviewed, cleaned up and adjusted
for more systems (and different glib library versions).

(cherry picked from commit 2f595aba80)
2015-03-13 11:50:37 +01:00
Thomas Haller
fed9958ae4 tests: fail valgrind script if log file is non-empty
(cherry picked from commit cfa4560073)
2015-03-13 11:50:05 +01:00
Thomas Haller
26406d0868 libnm/tests: enable valgrind for libnm tests
(cherry picked from commit e7356ef0a6)
2015-03-13 11:50:05 +01:00
Thomas Haller
ab09532c6b libnm/tests: add valgrind suppressions
(cherry picked from commit bf68917ca3)
2015-03-13 11:50:05 +01:00
Thomas Haller
26f96871a1 libnm/tests: fix memleaks in test code for valgrind
(cherry picked from commit 76745817c3)
2015-03-13 11:50:05 +01:00
Thomas Haller
b9a8f3c059 tests: enable valgrind tests for tests
(cherry picked from commit c50f30e79c)
2015-03-13 11:50:04 +01:00
Thomas Haller
c2cd7e631f platform/tests: reenable valgrind tests
valgrind tests for platform were wrongly disabled.

Fixes: e3784fa618
(cherry picked from commit 6853d07f05)
2015-03-13 11:50:04 +01:00
Thomas Haller
e92ba835ad tests: add valgrind suppression for callouts tests
(cherry picked from commit d5f8312996)
2015-03-13 11:50:04 +01:00
Thomas Haller
eab46bce70 tests: add valgrind suppression for test-general-with-expect
==8781== Syscall param rt_sigaction(act->sa_flags) points to uninitialised byte(s)
    ==8781==    at 0x5E547DD: __libc_sigaction (sigaction.c:64)
    ==8781==    by 0x8149025: unref_unix_signal_handler_unlocked (gmain.c:4981)
    ==8781==    by 0x81490BF: g_child_watch_finalize (gmain.c:5025)
    ==8781==    by 0x8149535: g_source_unref_internal (gmain.c:1997)
    ==8781==    by 0x814C377: g_main_context_dispatch (gmain.c:3094)
    ==8781==    by 0x814C627: g_main_context_iterate.isra.24 (gmain.c:3713)
    ==8781==    by 0x814CA39: g_main_loop_run (gmain.c:3907)
    ==8781==    by 0x11AC8B: test_nm_utils_kill_child_async_do (test-general-with-expect.c:90)
    ==8781==    by 0x119769: test_nm_utils_kill_child (test-general-with-expect.c:292)
    ==8781==    by 0x81705E0: g_test_run_suite_internal (gtestutils.c:2067)
    ==8781==    by 0x81707A5: g_test_run_suite_internal (gtestutils.c:2138)
    ==8781==    by 0x8170B1A: g_test_run_suite (gtestutils.c:2189)
    ==8781==  Address 0xffeffed28 is on thread 1's stack
    ==8781==
    {
       <insert_a_suppression_name_here>
       Memcheck:Param
       rt_sigaction(act->sa_flags)
       fun:__libc_sigaction
       fun:unref_unix_signal_handler_unlocked
       fun:g_child_watch_finalize
       fun:g_source_unref_internal
       fun:g_main_context_dispatch
       fun:g_main_context_iterate.isra.24
       fun:g_main_loop_run
       fun:test_nm_utils_kill_child_async_do
       fun:test_nm_utils_kill_child
       fun:g_test_run_suite_internal
       fun:g_test_run_suite_internal
       fun:g_test_run_suite
    }

(cherry picked from commit 171a9eabc6)
2015-03-13 11:50:04 +01:00
Thomas Haller
692619ea89 supplicant/tests: fix memleaks in test code for valgrind
(cherry picked from commit 624aa51614)
2015-03-13 11:50:04 +01:00
Thomas Haller
12ee98f471 dhcp/tests: fix memleaks in test code for valgrind
(cherry picked from commit d74a3d0a02)
2015-03-13 11:50:04 +01:00
Thomas Haller
4f685b4310 config/tests: fix memleak in test code for valgrind
(cherry picked from commit 63f5a22ad7)
2015-03-13 11:50:04 +01:00
Thomas Haller
a369923d03 device: refactor dispose/cleanup of NMDevice to free members in finalize
NMTestDevice does not invoke dispose(), hence it leaks memory which causes
false warnings in testing.
Some minor refactring to let dispose() clear the fields, but free it
later in finalize(). This avoids memleaks in the NMTestDevice stub.

(cherry picked from commit a82d94a64e)
2015-03-13 11:50:04 +01:00
Thomas Haller
2eb71b6229 libnm/tests: fix memleaks in tests for valgrind
(cherry picked from commit ae73320b8c)
2015-03-13 11:50:04 +01:00
Thomas Haller
e25d06cf71 ifcfg-rh/tests: fix memleaks in test code for valgrind
(cherry picked from commit 0750d934bf)
2015-03-13 11:50:04 +01:00
Thomas Haller
72666156e3 ibft/tests: fix memleaks in test code for valgrind
(cherry picked from commit fbe8c0ed87)
2015-03-13 11:50:04 +01:00
Thomas Haller
f334c4a7f1 keyfile/tests: fix memleaks in test code for valgrind
(cherry picked from commit 9a2f2ed7fd)
2015-03-13 11:50:04 +01:00
Thomas Haller
ac8ea4f799 callouts/tests: fix memleak in test code for valgrind
(cherry picked from commit 1ba16f44cf)
2015-03-13 11:50:04 +01:00
Thomas Haller
b352d0a26b core/tests: fix memleak in tests to avoid valgrind warnings
(cherry picked from commit 1680bf3ad1)
2015-03-13 11:50:04 +01:00
Thomas Haller
84ff53ec76 dhcp: fix memleak in process_dhclient_rfc3442_route()
(cherry picked from commit 1935fca09a)
2015-03-13 11:50:04 +01:00
Thomas Haller
825eb5cb62 ifcfg-rh: fix memleak in write_ip4_aliases() and assert against overflow
(cherry picked from commit a9bfe9f4bb)
2015-03-13 11:50:04 +01:00
Thomas Haller
273576b01c ifcfg-rh: fix memleaks in reader
(cherry picked from commit 53796f0beb)
2015-03-13 11:50:04 +01:00
Thomas Haller
856962cea8 ifcfg-rh: fix memleak due to make_wpa_setting() returning both wsec and error
==10501== 353 (32 direct, 321 indirect) bytes in 1 blocks are definitely lost in loss record 1,579 of 1,641
    ==10501==    at 0x7EE3728: g_type_create_instance (gtype.c:1847)
    ==10501==    by 0x7EC75B4: g_object_new_internal (gobject.c:1746)
    ==10501==    by 0x7EC945C: g_object_newv (gobject.c:1890)
    ==10501==    by 0x7EC9C23: g_object_new (gobject.c:1556)
    ==10501==    by 0x1CD87C: nm_setting_wireless_security_new (nm-setting-wireless-security.c:122)
    ==10501==    by 0x16F70B: make_wpa_setting (reader.c:3010)
    ==10501==    by 0x16F33F: make_wireless_security_setting (reader.c:3188)
    ==10501==    by 0x161F4C: wireless_connection_from_ifcfg (reader.c:3464)
    ==10501==    by 0x16109A: connection_from_file_full (reader.c:4763)
    ==10501==    by 0x1614EE: connection_from_file_test (reader.c:4862)
    ==10501==    by 0x13D1D6: test_read_wifi_wpa_psk_unquoted2 (test-ifcfg-rh.c:4316)
    ==10501==    by 0x1281FD: main (test-ifcfg-rh.c:12513)
    ==10501==

(cherry picked from commit fcfd8f487a)
2015-03-13 11:50:04 +01:00
Thomas Haller
2ceea73dc3 ifcfg-rh: fix memleak in svSetValue()
(cherry picked from commit 98a0299265)
2015-03-13 11:50:04 +01:00