Commit Graph

15047 Commits

Author SHA1 Message Date
Thomas Haller
3a3b32a9f6 config: add defines for key names for keyfile 2015-12-08 11:47:56 +01:00
Thomas Haller
7685961261 active-connection: improve logging in NMActiveConnection
- cleanup _NMLOG()
- implement state_to_string() based on NM_UTILS_STRING_LOOKUP_TABLE(),
  which prints unknown values as numeric
- add logging when setting device and state
- cleanup logging in check-master-ready to consistently
  print relevant information
- update logging in set_master() to match simpler logging
  format like set_device() and set_state().
2015-12-07 21:47:01 +01:00
Thomas Haller
cc99ab81f3 macros: add nm_sprintf_bufa() 2015-12-07 21:36:16 +01:00
Thomas Haller
1104110865 device: fix crash in master_ready() logging unset priv->master
Fixes: f45f702a5e
2015-12-07 21:36:16 +01:00
Thomas Haller
03f8ba490a core: use define for NMManager's "state-changed" signal name 2015-12-07 19:54:12 +01:00
Thomas Haller
3755209039 core: use define for NMPPPManager's "state-changed" signal name 2015-12-07 19:54:11 +01:00
Thomas Haller
e1738c7c61 core: use define for NMDnsMasqManager's "state-changed" signal name 2015-12-07 19:53:14 +01:00
Thomas Haller
ee4ec4e600 core: use define for NMDevice's "state-changed" signal name 2015-12-07 19:53:14 +01:00
Thomas Haller
04c70c76bc device: cache pointer to private-data in NMDevice structure
We often lookup the private data and retrieve it via NM_DEVICE_GET_PRIVATE(),
which in turn calls G_TYPE_INSTANCE_GET_PRIVATE().

Instead cache the pointer to the private data.

There are up- and downsides:

 - requries additional sizeof(gpointer) bytes for each NMDevice.
 + retrieving the private pointer will be slightly faster.
 + easier debugging in gdb as it is currently often a pain to
   retrieve the private data.

But most importantly, the allows to change our common pattern
to first cache the private data in a variable @priv. That is
often cumbersome to write, especially for short functions.
This change gives us a choice to use self->priv directly.

Such a change should not be aimed for every class. Instead it makes
mostly sense for NMDevice, where it pays off better due to the
class' size and ubiquitous use.

https://mail.gnome.org/archives/networkmanager-list/2015-December/msg00017.html
2015-12-07 19:30:11 +01:00
Lubomir Rintel
2077dee582 device: fix a typo in assertion
It is well understood that world would implode if the device was its own master.

Fixes: f45f702a5e
2015-12-07 19:02:54 +01:00
Jiří Klimeš
e29b844f42 cli: produce new line after readline when echoing was off
The new line was missing.
Adding termios_new.c_lflag |= (ECHONL | ICANON); did not help. Why?

Fixes: a14306c2ce
2015-12-07 17:33:03 +01:00
Thomas Haller
229ea4547c device: don't pass void* pointer to NM_DEVICE_GET_PRIVATE() 2015-12-07 16:34:48 +01:00
Thomas Haller
14bb9419a0 examples: add README for python-networkmanager NetworkManager library 2015-12-07 16:06:46 +01:00
Thomas Haller
5b732c3b9f examples: add README for examples/python/gi 2015-12-07 15:59:20 +01:00
Thomas Haller
9b2a34c978 route-manager: always flush IPv6 routes during nm_route_manager_route_flush() 2015-12-07 15:23:27 +01:00
Thomas Haller
0a6cca9450 device: use NM_UTILS_STRING_LOOKUP_TABLE() for reason_to_string()
Showcase for the new macros NM_UTILS_STRING_LOOKUP_TABLE() and
NM_UTILS_STRING_LOOKUP_TABLE_DEFINE_STATIC().

It changes behavior in case of looking up an invalid/unknown
state reason. Previously it would just have returned "unknown"
-- which was indistinguishable from a regular "unknown" value.

Now it returns the numeric id as a string. The string is allocated
with alloca(), which is desired but one should be aware of the pitfalls:

- prevents the caller from being inlined
- bad idea to do in a loop.
2015-12-07 14:41:32 +01:00
Thomas Haller
a291ecc29c utils: add NM_UTILS_STRING_LOOKUP_TABLE() macro 2015-12-07 14:34:59 +01:00
Thomas Haller
01ea90b57a utils: minor refactoring of NM_UTILS_FLAGS2STR_DEFINE() macro 2015-12-07 14:34:59 +01:00
Jiří Klimeš
c52b2044cd merge: nmcli: don't show password by default, add --show-secrets (rh #759116)
https://bugzilla.gnome.org/show_bug.cgi?id=759116
2015-12-07 14:25:37 +01:00
Jiří Klimeš
629de4e689 cli: add global --show-secrets option
- it controls echoing passwords input on terminal
- it replaces --show-secrets in 'nmcli connection show', which is deprecated now
- it replaces --show-password in 'nmcli device wifi hotspot', which is deprecated now
2015-12-07 14:14:58 +01:00
Jiří Klimeš
23aff47826 cli: use nmc_readline_echo() for asking password in 'nmcli con add' 2015-12-07 14:14:58 +01:00
Jiří Klimeš
1056408fd4 cli: use nmc_readline_echo() for asking password in 'nmcli dev wifi connect' 2015-12-07 14:14:58 +01:00
Jiří Klimeš
02388060c1 cli: use new nmc_readline_echo() in polkit agent 2015-12-07 14:14:58 +01:00
Jiří Klimeš
a14306c2ce cli: do not echo passwords on terminal when asking for them
adds nmc_readline_echo() function that can disable displaying characters.
2015-12-07 14:14:58 +01:00
Thomas Haller
d5a8401686 initscript: remove all distribution initscripts
These initscripts weren't modified for a long time. Are they just
unused or flawless? It seems they are no longer best-practice
(e.g. NetworkManager supports reloading configuration via SIGHUP,
which none of these scripts implement).

Nowadays some distributions moved to systemd and quite possible
nobody uses these scripts. Also, any potential downstream user
probably has an adjusted copy of them in their repositories.

Just remove them.

https://mail.gnome.org/archives/networkmanager-list/2015-December/msg00003.html
2015-12-07 13:37:30 +01:00
Jiří Klimeš
9f2326dff0 man: rephrase a sentence in nmcli man page
for 'nmcli connection clone'
2015-12-07 12:22:45 +01:00
Jiří Klimeš
acaf7cf641 nm-import-openvpn: import 'route' option
https://bugzilla.gnome.org/show_bug.cgi?id=753578
https://git.gnome.org/browse/network-manager-openvpn/commit/?id=4eb5f3ad43cdc62c6d4d254731e24c90b87ba91a
2015-12-07 12:22:45 +01:00
Thomas Haller
72c36bd6db device/tun: fix reloading tun properties
Before the device is setup, we call nm_platform_tun_get_properties() without
a valid ifindex. That triggered an assertion [1].

Thereby, change nm_platform_tun_get_properties() to effectively clear
the tun properties when we are unable to fetch them. Also, never modify
the tun-mode of NMDeviceTun.

[1]
    #0  0x00007f0a4173e81b in g_logv (breakpoint=1) at gmessages.c:324
    #1  0x00007f0a4173e81b in g_logv (log_domain=0x561e9264ccf6 "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7ffd71a0d4d0) at gmessages.c:1081
    #2  0x00007f0a4173e98f in g_log (log_domain=<optimized out>, log_level=<optimized out>, format=<optimized out>) at gmessages.c:1119
    #3  0x0000561e9241ecec in nm_platform_tun_get_properties (self=0x561e9354ba70 [NMLinuxPlatform], ifindex=0, props=0x7ffd71a0d650) at platform/nm-platform.c:2081
    #4  0x0000561e923aad9c in reload_tun_properties (self=0x561e937fb080 [NMDeviceTun]) at devices/nm-device-tun.c:68
    #5  0x0000561e923aa795 in realize (device=0x561e937fb080 [NMDeviceTun], plink=0x7ffd71a0d818, error=0x7ffd71a0d798) at devices/nm-device-tun.c:225
    #6  0x0000561e923bdc06 in nm_device_realize (self=0x561e937fb080 [NMDeviceTun], plink=0x7ffd71a0d818, out_compatible=0x7ffd71a0d77c, error=0x7ffd71a0d798) at devices/nm-device.c:1713
    #7  0x0000561e924ad995 in platform_link_added (self=0x561e9356e230 [NMManager], ifindex=33, plink=0x7ffd71a0d818) at nm-manager.c:1947
    #8  0x0000561e924ad717 in _platform_link_cb_idle (data=0x561e937eb940) at nm-manager.c:2029
    #9  0x00007f0a41737e3a in g_main_context_dispatch (context=0x561e93547530) at gmain.c:3154
    #10 0x00007f0a41737e3a in g_main_context_dispatch (context=context@entry=0x561e93547530) at gmain.c:3769
    #11 0x00007f0a417381d0 in g_main_context_iterate (context=0x561e93547530, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3840
    #12 0x00007f0a417384f2 in g_main_loop_run (loop=0x561e935475f0) at gmain.c:4034
    #13 0x0000561e923ba3f3 in main (argc=1, argv=0x7ffd71a0dc68) at main.c:488

Fixes: 4dbaac4ba2
2015-12-07 11:32:12 +01:00
Lubomir Rintel
da528b5ccd cli: drop an extra newline 2015-12-07 11:23:39 +01:00
Lubomir Rintel
9dbf549c64 vpn-editor-plugin: improve the error handling a bit 2015-12-07 11:20:14 +01:00
Lubomir Rintel
b38a5f4cb4 cli: avoid using tmp template after it goes out of scope
Fixes: 3892b839af
2015-12-07 11:05:52 +01:00
Lubomir Rintel
4ffed27959 cli: improve the error reporting a bit 2015-12-07 10:51:49 +01:00
Lubomir Rintel
fccd48fce8 clients: add clients/common/nm-vpn-helpers.c to POTFILES.in
Fixes: b8d6bd1a98
2015-12-07 10:18:55 +01:00
Jiří Klimeš
4e9aa035c2 merge: implement nmcli con import/export for VPN connections (rh #1034105)
https://bugzilla.redhat.com/show_bug.cgi?id=1034105
2015-12-07 09:17:48 +01:00
Jiří Klimeš
3892b839af cli: add 'nmcli connection export' (rh #1034105)
Synopsis:
  nmcli connection export [ id | uuid | path] <ID> [<output file>]

for exporting VPN connections.

https://bugzilla.redhat.com/show_bug.cgi?id=1034105
2015-12-07 09:11:20 +01:00
Jiří Klimeš
9a0e4bae47 cli: add 'nmcli connection import' (rh #1034105)
Synopsis:
  nmcli connection import [--temporary] type <type> file <file to import>

Only VPN configurations can be imported at the moment.

https://bugzilla.redhat.com/show_bug.cgi?id=1034105
2015-12-07 09:11:06 +01:00
Jiří Klimeš
f28d311d13 clients: accept service without org.freedesktop.NetworkManager prefix
in nm_vpn_get_plugin_by_service()
2015-12-05 21:29:00 +01:00
Jiří Klimeš
96ab3a8a5c clients: add GError parameter to nm_vpn_get_plugin_by_service() 2015-12-05 21:29:00 +01:00
Thomas Haller
ce238a7074 tests/valgrind: rename name of logfile for valgrind run
Change the name of the file where to store the results
of the valgrind run.

Previously the file had a prefix "valgrind-", which is inconvinient.
Instead, have the file using the same name as the test executable,
with a ".valgrind-log" suffix.
2015-12-05 20:35:16 +01:00
Thomas Haller
3acb6a3667 core: merge branch 'th/device-master-slave-bgo759027'
https://bugzilla.gnome.org/show_bug.cgi?id=759027
2015-12-05 19:53:32 +01:00
Thomas Haller
f45f702a5e device: cleanup handling master/slave relationships in NMDevice
I found the handling of the master-device very confusing because it was
unclear who sets priv->master, and when it should be set.

Now:

- Setting priv->master (in a slave) always goes together with adding
  the master to priv->slaves (in the master). Previously, this was
  done at separate places, so it was not clear if master and slave
  always agree on their relationship -- in fact, they did not.

- There are now three basic functions which do the enslaving/releasing:
    (1) nm_device_master_add_slave()
    (2) nm_device_master_enslave_slave()
    (3) nm_device_master_release_one_slave()
  Step 3/release basically undoes the 1/add and 2/enslave steps.

- completing the enslaving/releasing is now done by
    (1) nm_device_slave_notify_enslave()
    (2) nm_device_slave_notify_release()
  These functions also emit signals like NM_DEVICE_MASTER.

- Derived classes no longer emit NM_DEVICE_SLAVES notification. Instead
  the notification is emited together with NM_DEVICE_MASTER, whenever a
  slaves changes state. Also, NM_DEVICE_SLAVES list now only exposes
  slaves that are actually @is_enslaved.
2015-12-05 19:34:06 +01:00
Thomas Haller
9a8d9a0d85 device: implement slave property in parent device class
Instead of reimplementing the slave property in bond, bridge
and team, just add the property to the parent class. It's not
that the parent class would be agnostic to the master/slave
implementation, all the slaves are known to the every device
type implementation.

Also, the derived class doesn't know the correct time when
to invoke the notify-changed for the slaves property.
E.g. it should be only invoked after nm_device_slave_notify_enslave()
when other components also consider the slave as enslaved.
Later this will be fixed so that the SLAVES property correspond
to what other master/slave related properties say.
2015-12-05 19:34:06 +01:00
Thomas Haller
f9404d36fd wifi: fix supplicant_connection_timeout_cb() using settings-connection
(gdb) bt
    #0  0x00007fc1c920681b in g_logv () at /lib64/libglib-2.0.so.0
    #1  0x00007fc1c920698f in g_log () at /lib64/libglib-2.0.so.0
    #2  0x00007fc1c9523237 in g_type_check_instance_cast () at /lib64/libgobject-2.0.so.0
    #3  0x00007fc1bdef10ed in supplicant_connection_timeout_cb (user_data=0x561a52451600) at nm-device-wifi.c:2207
    #4  0x00007fc1c9200893 in g_timeout_dispatch () at /lib64/libglib-2.0.so.0
    #5  0x00007fc1c91ffe3a in g_main_context_dispatch () at /lib64/libglib-2.0.so.0
    #6  0x00007fc1c92001d0 in g_main_context_iterate.isra () at /lib64/libglib-2.0.so.0
    #7  0x00007fc1c92004f2 in g_main_loop_run () at /lib64/libglib-2.0.so.0
    #8  0x0000561a511583f3 in main (argc=1, argv=0x7ffc033f1e28) at main.c:488
2015-12-05 19:34:06 +01:00
Lubomir Rintel
13d931a8da merge: branch 'lr/nmcli-monitor-rh1034158'
https://bugzilla.redhat.com/show_bug.cgi?id=1034158
2015-12-05 12:28:21 +01:00
Lubomir Rintel
d03f347b9d cli: add nmcli monitor
https://bugzilla.redhat.com/show_bug.cgi?id=1034158
2015-12-05 12:16:23 +01:00
Lubomir Rintel
e92e06bdc7 cli,connections: add connection monitor 2015-12-05 12:16:06 +01:00
Lubomir Rintel
9b49284f0c cli,devices: add device monitor 2015-12-05 12:16:04 +01:00
Lubomir Rintel
2a646a74dd cli,devices: factor out parsing of the interface list
This is duplicated already and the monitor will use it.
2015-12-05 12:05:17 +01:00
Lubomir Rintel
225f6594c4 cli,devices: factor out device_state_to_color()
We'll use this for device status monitor too.
2015-12-05 12:05:17 +01:00
Lubomir Rintel
88ae8d2b13 cli: turn should_wait into a semaphore
Count the exit blockers. We'll want to terminate the device monitor in case all
monitored devices vanish.
2015-12-05 12:05:17 +01:00