Update to NetworkManager 1.2-beta3

This commit is contained in:
Lubomir Rintel 2016-03-29 17:36:47 +02:00
parent bb908ed4e4
commit 9093f6263e
7 changed files with 15 additions and 415 deletions

1
.gitignore vendored
View File

@ -322,3 +322,4 @@ network-manager-applet-0.8.1.tar.bz2
/NetworkManager-1.2.0.tar.xz
/NetworkManager-1.1.90.tar.xz
/NetworkManager-1.1.91.tar.xz
/NetworkManager-1.1.92.tar.xz

View File

@ -1,197 +0,0 @@
From f94c3736cd1c84aacaea1879154a0acdb58667d0 Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Thu, 18 Feb 2016 18:19:30 +0100
Subject: [PATCH 1/3] core: use hostnamed to set the transient hostname
In commit 6dc35e66d45e ("settings: add hostnamed support") we started
to use systemd-hostnamed for setting the system static hostname
(i.e. the one written to /etc/hostname), but nm-policy.c still called
sethostname() to set the transient (dynamic) hostname when this needs
to be changed, for example after a reverse lookup of our dynamic IP
address.
Thus, when using systemd the hostname change failed because process'
capabilities are restricted and sethostname() requires CAP_SYS_ADMIN.
We should set also the transient hostname through hostnamed when this
is available.
https://bugzilla.redhat.com/show_bug.cgi?id=1308974
---
src/nm-policy.c | 45 ++++++++++++++++++++++++-----------
src/settings/nm-settings.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++
src/settings/nm-settings.h | 7 ++++++
3 files changed, 97 insertions(+), 14 deletions(-)
diff --git a/src/nm-policy.c b/src/nm-policy.c
index 68e50a1..cfb140f 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -118,9 +118,32 @@ get_best_ip6_device (NMPolicy *self, gboolean fully_activated)
#define FALLBACK_HOSTNAME4 "localhost.localdomain"
-static gboolean
-set_system_hostname (const char *new_hostname, const char *msg)
+static void settings_set_hostname_cb (const char *hostname,
+ gboolean result,
+ gpointer user_data)
{
+ int ret = 0;
+
+ if (!result) {
+ ret = sethostname (hostname, strlen (hostname));
+ if (ret != 0) {
+ int errsv = errno;
+
+ nm_log_warn (LOGD_DNS, "couldn't set the system hostname to '%s': (%d) %s",
+ hostname, errsv, strerror (errsv));
+ if (errsv == EPERM)
+ nm_log_warn (LOGD_DNS, "you should use hostnamed when systemd hardening is in effect!");
+ }
+ }
+
+ if (!ret)
+ nm_dispatcher_call (DISPATCHER_ACTION_HOSTNAME, NULL, NULL, NULL, NULL, NULL, NULL);
+}
+
+static void
+set_system_hostname (NMPolicy *self, const char *new_hostname, const char *msg)
+{
+ NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
char old_hostname[HOST_NAME_MAX + 1];
const char *name;
int ret;
@@ -138,21 +161,16 @@ set_system_hostname (const char *new_hostname, const char *msg)
/* Don't set the hostname if it isn't actually changing */
if ( (new_hostname && !strcmp (old_hostname, new_hostname))
|| (!new_hostname && !strcmp (old_hostname, FALLBACK_HOSTNAME4)))
- return FALSE;
+ return;
}
name = (new_hostname && strlen (new_hostname)) ? new_hostname : FALLBACK_HOSTNAME4;
nm_log_info (LOGD_DNS, "Setting system hostname to '%s' (%s)", name, msg);
- ret = sethostname (name, strlen (name));
- if (ret != 0) {
- int errsv = errno;
-
- nm_log_warn (LOGD_DNS, "couldn't set the system hostname to '%s': (%d) %s",
- name, errsv, strerror (errsv));
- if (errsv == EPERM)
- nm_log_warn (LOGD_DNS, "You should use hostnamed when systemd hardening is in effect!");
- }
+ nm_settings_set_transient_hostname (priv->settings,
+ name,
+ settings_set_hostname_cb,
+ NULL);
return (ret == 0);
}
@@ -196,8 +214,7 @@ _set_hostname (NMPolicy *policy,
nm_dns_manager_set_hostname (priv->dns_manager, priv->cur_hostname);
- if (set_system_hostname (priv->cur_hostname, msg))
- nm_dispatcher_call (DISPATCHER_ACTION_HOSTNAME, NULL, NULL, NULL, NULL, NULL, NULL);
+ set_system_hostname (policy, priv->cur_hostname, msg);
}
static void
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
index ee48e71..f79bbfa 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -1525,6 +1525,65 @@ impl_settings_reload_connections (NMSettings *self,
g_dbus_method_invocation_return_value (context, g_variant_new ("(b)", TRUE));
}
+typedef struct {
+ char *hostname;
+ NMSettingsSetHostnameCb cb;
+ gpointer user_data;
+} SetHostnameInfo;
+
+static void
+set_transient_hostname_done (GObject *object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GDBusProxy *proxy = G_DBUS_PROXY (object);
+ gs_free SetHostnameInfo *info = user_data;
+ gs_unref_variant GVariant *result = NULL;
+ gs_free_error GError *error = NULL;
+
+ result = g_dbus_proxy_call_finish (proxy, res, &error);
+
+ if (error) {
+ nm_log_warn (LOGD_SETTINGS, "couldn't set the system hostname to '%s' using hostnamed: %s",
+ info->hostname, error->message);
+ }
+
+ info->cb (info->hostname, !error, info->user_data);
+ g_free (info->hostname);
+}
+
+void
+nm_settings_set_transient_hostname (NMSettings *self,
+ const char *hostname,
+ NMSettingsSetHostnameCb cb,
+ gpointer user_data)
+{
+ NMSettingsPrivate *priv;
+ SetHostnameInfo *info;
+
+ g_return_if_fail (NM_IS_SETTINGS (self));
+ priv = NM_SETTINGS_GET_PRIVATE (self);
+
+ if (!priv->hostname.hostnamed_proxy) {
+ cb (hostname, FALSE, user_data);
+ return;
+ }
+
+ info = g_new0 (SetHostnameInfo, 1);
+ info->hostname = g_strdup (hostname);
+ info->cb = cb;
+ info->user_data = user_data;
+
+ g_dbus_proxy_call (priv->hostname.hostnamed_proxy,
+ "SetHostname",
+ g_variant_new ("(sb)", hostname, FALSE),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ set_transient_hostname_done,
+ info);
+}
+
static gboolean
write_hostname (NMSettingsPrivate *priv, const char *hostname)
{
diff --git a/src/settings/nm-settings.h b/src/settings/nm-settings.h
index 923b164..051c209 100644
--- a/src/settings/nm-settings.h
+++ b/src/settings/nm-settings.h
@@ -71,6 +71,8 @@ typedef struct {
void (*agent_registered) (NMSettings *self, NMSecretAgent *agent);
} NMSettingsClass;
+typedef void (*NMSettingsSetHostnameCb) (const char *name, gboolean result, gpointer user_data);
+
GType nm_settings_get_type (void);
NMSettings *nm_settings_new (void);
@@ -127,4 +129,9 @@ gint nm_settings_sort_connections (gconstpointer a, gconstpointer b);
gboolean nm_settings_get_startup_complete (NMSettings *self);
+void nm_settings_set_transient_hostname (NMSettings *self,
+ const char *hostname,
+ NMSettingsSetHostnameCb cb,
+ gpointer user_data);
+
#endif /* __NM_SETTINGS_H__ */
--
2.5.0

View File

@ -1,44 +0,0 @@
From ca5da5d80f3a21847bb807021e2e40d25bca50d0 Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Fri, 11 Mar 2016 15:36:35 +0100
Subject: [PATCH] device: fix handling of available connections
The prune list is for elements that must be deleted from the list of
available connections. So, when processing all the existing
connections an element must be deleted from the prune list iff it's
available.
Fixes: 8b2abe0e2c8f162544a2562fc18a7becbc55d233
https://bugzilla.redhat.com/show_bug.cgi?id=1316488
---
src/devices/nm-device.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 51a84bf..f4e2ce1 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -9664,14 +9664,13 @@ nm_device_recheck_available_connections (NMDevice *self)
connection = NM_CONNECTION (iter->data);
if (nm_device_check_connection_available (self,
- connection,
- NM_DEVICE_CHECK_CON_AVAILABLE_NONE,
- NULL)) {
+ connection,
+ NM_DEVICE_CHECK_CON_AVAILABLE_NONE,
+ NULL)) {
if (available_connections_add (self, connection))
changed = TRUE;
- } else {
- if (prune_list && g_hash_table_remove (prune_list, connection))
- changed = TRUE;
+ if (prune_list)
+ g_hash_table_remove (prune_list, connection);
}
}
--
2.5.0

View File

@ -1,48 +0,0 @@
From ff9c310454e36acf996491ad154487c85b19f87a Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Mon, 22 Feb 2016 10:01:30 +0100
Subject: [PATCH 2/3] policy: simplify set_system_hostname()
Move some conditionals to the beginning of the function.
---
src/nm-policy.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/nm-policy.c b/src/nm-policy.c
index cfb140f..fca4005 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -148,8 +148,13 @@ set_system_hostname (NMPolicy *self, const char *new_hostname, const char *msg)
const char *name;
int ret;
- if (new_hostname)
- g_warn_if_fail (strlen (new_hostname));
+ if (!new_hostname)
+ name = FALLBACK_HOSTNAME4;
+ else if (!new_hostname[0]) {
+ g_warn_if_reached ();
+ name = FALLBACK_HOSTNAME4;
+ } else
+ name = new_hostname;
old_hostname[HOST_NAME_MAX] = '\0';
errno = 0;
@@ -159,13 +164,10 @@ set_system_hostname (NMPolicy *self, const char *new_hostname, const char *msg)
errno, strerror (errno));
} else {
/* Don't set the hostname if it isn't actually changing */
- if ( (new_hostname && !strcmp (old_hostname, new_hostname))
- || (!new_hostname && !strcmp (old_hostname, FALLBACK_HOSTNAME4)))
+ if (nm_streq (name, old_hostname))
return;
}
- name = (new_hostname && strlen (new_hostname)) ? new_hostname : FALLBACK_HOSTNAME4;
-
nm_log_info (LOGD_DNS, "Setting system hostname to '%s' (%s)", name, msg);
nm_settings_set_transient_hostname (priv->settings,
name,
--
2.5.0

View File

@ -1,112 +0,0 @@
From 078179c836fb39a81173ab5ce7db1ccc05eb3f7a Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Mon, 22 Feb 2016 10:10:15 +0100
Subject: [PATCH 3/3] policy: move code from set_system_hostname() to
_set_hostname()
---
src/nm-policy.c | 74 ++++++++++++++++++++++++++++-----------------------------
1 file changed, 36 insertions(+), 38 deletions(-)
diff --git a/src/nm-policy.c b/src/nm-policy.c
index fca4005..84d1e7e 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -141,48 +141,14 @@ static void settings_set_hostname_cb (const char *hostname,
}
static void
-set_system_hostname (NMPolicy *self, const char *new_hostname, const char *msg)
-{
- NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
- char old_hostname[HOST_NAME_MAX + 1];
- const char *name;
- int ret;
-
- if (!new_hostname)
- name = FALLBACK_HOSTNAME4;
- else if (!new_hostname[0]) {
- g_warn_if_reached ();
- name = FALLBACK_HOSTNAME4;
- } else
- name = new_hostname;
-
- old_hostname[HOST_NAME_MAX] = '\0';
- errno = 0;
- ret = gethostname (old_hostname, HOST_NAME_MAX);
- if (ret != 0) {
- nm_log_warn (LOGD_DNS, "couldn't get the system hostname: (%d) %s",
- errno, strerror (errno));
- } else {
- /* Don't set the hostname if it isn't actually changing */
- if (nm_streq (name, old_hostname))
- return;
- }
-
- nm_log_info (LOGD_DNS, "Setting system hostname to '%s' (%s)", name, msg);
- nm_settings_set_transient_hostname (priv->settings,
- name,
- settings_set_hostname_cb,
- NULL);
-
- return (ret == 0);
-}
-
-static void
_set_hostname (NMPolicy *policy,
const char *new_hostname,
const char *msg)
{
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (policy);
+ char old_hostname[HOST_NAME_MAX + 1];
+ const char *name;
+ int ret;
/* The incoming hostname *can* be NULL, which will get translated to
* 'localhost.localdomain' or such in the hostname policy code, but we
@@ -214,9 +180,41 @@ _set_hostname (NMPolicy *policy,
priv->cur_hostname = g_strdup (new_hostname);
priv->hostname_changed = TRUE;
+ /* Notify the DNS manager of the hostname change so that the domain part, if
+ * present, can be added to the search list.
+ */
nm_dns_manager_set_hostname (priv->dns_manager, priv->cur_hostname);
- set_system_hostname (policy, priv->cur_hostname, msg);
+ /* Finally, set kernel hostname */
+
+ if (!priv->cur_hostname)
+ name = FALLBACK_HOSTNAME4;
+ else if (!priv->cur_hostname[0]) {
+ g_warn_if_reached ();
+ name = FALLBACK_HOSTNAME4;
+ } else
+ name = priv->cur_hostname;
+
+ old_hostname[HOST_NAME_MAX] = '\0';
+ errno = 0;
+ ret = gethostname (old_hostname, HOST_NAME_MAX);
+ if (ret != 0) {
+ nm_log_warn (LOGD_DNS, "couldn't get the system hostname: (%d) %s",
+ errno, strerror (errno));
+ } else {
+ /* Don't set the hostname if it isn't actually changing */
+ if (nm_streq (name, old_hostname))
+ return;
+ }
+
+ nm_log_info (LOGD_DNS, "setting system hostname to '%s' (%s)", name, msg);
+
+ /* Ask NMSettings to update the transient hostname using its
+ * systemd-hostnamed proxy */
+ nm_settings_set_transient_hostname (priv->settings,
+ name,
+ settings_set_hostname_cb,
+ NULL);
}
static void
--
2.5.0

View File

@ -7,10 +7,10 @@
%global ppp_version %(rpm -q ppp-devel >/dev/null && rpm -q --qf '%%{version}' ppp-devel || echo -n bad)
%global snapshot .beta2
%global git_sha %{nil}
%global snapshot .beta3
#global git_sha %{nil}
%global rpm_version 1.2.0
%global real_version 1.1.91
%global real_version 1.1.92
%global release_version 0.7
%global epoch_version 1
@ -22,7 +22,7 @@
%global _hardened_build 1
%global git_sha_version %(test -n '%{git_sha}' && echo '.%{git_sha}')
%global git_sha_version %{?git_sha:.%{git_sha}}
###############################################################################
@ -91,10 +91,7 @@ Source1: NetworkManager.conf
Source2: 00-server.conf
Source3: 20-connectivity-fedora.conf
Patch0: 0001-device-fix-handling-of-available-connections.patch
Patch1: 0001-core-use-hostnamed-to-set-the-transient-hostname.patch
Patch2: 0002-policy-simplify-set_system_hostname.patch
Patch3: 0003-policy-move-code-from-set_system_hostname-to-_set_ho.patch
#Patch1: 0001-some.patch
Requires(post): systemd
Requires(preun): systemd
@ -335,11 +332,6 @@ by nm-connection-editor and nm-applet in a non-graphical environment.
%prep
%setup -q -n NetworkManager-%{real_version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%build
autoreconf --install --force
@ -446,6 +438,11 @@ rm -f %{buildroot}%{_libdir}/NetworkManager/*.la
# Ensure the documentation timestamps are constant to avoid multilib conflicts
find %{buildroot}%{_datadir}/gtk-doc |xargs touch --reference configure.ac
%if 0%{?__debug_package}
mkdir -p %{buildroot}%{_prefix}/src/debug/NetworkManager-%{real_version}
cp valgrind.suppressions %{buildroot}%{_prefix}/src/debug/NetworkManager-%{real_version}
%endif
%check
%if %{with test}
@ -636,6 +633,9 @@ fi
%endif
%changelog
* Tue Mar 29 2016 Lubomir Rintel <lkundrak@v3.sk> - 1:1.2.0-0.7.beta3
- Update to NetworkManager 1.2-beta3
* Tue Mar 22 2016 Lubomir Rintel <lkundrak@v3.sk> - 1:1.2.0-0.7.beta2
- Fix obtaining the hostname from DNS (rh #1308974)

View File

@ -1 +1 @@
b8ef71b3218ead86a5717a8d4440da32 NetworkManager-1.1.91.tar.xz
ae4143fdfcf35e703e11c1f3d4b21637 NetworkManager-1.1.92.tar.xz