From 576cbb771aafce4a1aeceb9ee99bffbdd63164e7 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 7 Jun 2018 21:23:38 +0200 Subject: [PATCH] libnm: always return VPN connections's banner It's not libnm's responsibility to hide the banner depending on the VPN state. libnm should cache and expose NetworkManager's state, and if the VPN connection has a banner there, it should be returned. The previous behavior was since ever in libnm, and in libnm-glib since the banner was introduced in commit e5b834c1f9c6f6e92546695a14bc37ec7aec09c6. I think it's wrong if libnm tries too hard putting additional logic on top of what is on D-Bus. --- .../test-client.check-on-disk/test_004-021.expected | 4 ++-- .../test-client.check-on-disk/test_004-022.expected | 4 ++-- libnm/nm-vpn-connection.c | 9 +-------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/clients/tests/test-client.check-on-disk/test_004-021.expected b/clients/tests/test-client.check-on-disk/test_004-021.expected index 80be0fc8a7..5cc7aa7315 100644 --- a/clients/tests/test-client.check-on-disk/test_004-021.expected +++ b/clients/tests/test-client.check-on-disk/test_004-021.expected @@ -2,7 +2,7 @@ location: clients/tests/test-client.py:945:test_004()/21 cmd: $NMCLI con s con-vpn-1 lang: C returncode: 0 -stdout: 4326 bytes +stdout: 4356 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -90,7 +90,7 @@ GENERAL.MASTER-PATH: -- VPN.TYPE: openvpn VPN.USERNAME: -- VPN.GATEWAY: -- -VPN.BANNER: -- +VPN.BANNER: *** VPN connection con-vpn-1 *** VPN.VPN-STATE: 0 - unknown VPN.CFG[1]: key1 = val1 VPN.CFG[2]: key2 = val2 diff --git a/clients/tests/test-client.check-on-disk/test_004-022.expected b/clients/tests/test-client.check-on-disk/test_004-022.expected index 630ff498db..17b3094e96 100644 --- a/clients/tests/test-client.check-on-disk/test_004-022.expected +++ b/clients/tests/test-client.check-on-disk/test_004-022.expected @@ -2,7 +2,7 @@ location: clients/tests/test-client.py:945:test_004()/22 cmd: $NMCLI con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 4340 bytes +stdout: 4370 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -90,7 +90,7 @@ GENERAL.MASTER-PATH: -- VPN.TYPE: openvpn VPN.USERNAME: -- VPN.GATEWAY: -- -VPN.BANNER: -- +VPN.BANNER: *** VPN connection con-vpn-1 *** VPN.VPN-STATE: 0 - nieznane VPN.CFG[1]: key1 = val1 VPN.CFG[2]: key2 = val2 diff --git a/libnm/nm-vpn-connection.c b/libnm/nm-vpn-connection.c index 5a3c4e564e..bc26d0b959 100644 --- a/libnm/nm-vpn-connection.c +++ b/libnm/nm-vpn-connection.c @@ -71,16 +71,9 @@ static guint signals[LAST_SIGNAL] = { 0 }; const char * nm_vpn_connection_get_banner (NMVpnConnection *vpn) { - NMVpnConnectionPrivate *priv; - g_return_val_if_fail (NM_IS_VPN_CONNECTION (vpn), NULL); - priv = NM_VPN_CONNECTION_GET_PRIVATE (vpn); - - if (priv->vpn_state != NM_VPN_CONNECTION_STATE_ACTIVATED) - return NULL; - - return nm_str_not_empty (priv->banner); + return nm_str_not_empty (NM_VPN_CONNECTION_GET_PRIVATE (vpn)->banner); } /**