|
|
94180d |
From da354830da15e6bdeec3d5f36d84e4bab6b7fedf Mon Sep 17 00:00:00 2001
|
|
|
94180d |
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jklimes@redhat.com>
|
|
|
94180d |
Date: Tue, 25 Mar 2014 13:55:47 +0100
|
|
|
94180d |
Subject: [PATCH] core: build with SELinux; don't break /etc/hostname context
|
|
|
94180d |
(rh #1070829)
|
|
|
94180d |
|
|
|
94180d |
https://bugzilla.redhat.com/show_bug.cgi?id=1070829
|
|
|
94180d |
---
|
|
|
94180d |
configure.ac | 18 ++++++++++++++++++
|
|
|
94180d |
src/settings/plugins/ifcfg-rh/plugin.c | 29 ++++++++++++++++++++++++++++-
|
|
|
94180d |
2 files changed, 46 insertions(+), 1 deletion(-)
|
|
|
94180d |
|
|
|
94180d |
diff --git a/configure.ac b/configure.ac
|
|
|
94180d |
index f13dc9a..2ca6aed 100644
|
|
|
94180d |
--- a/configure.ac
|
|
|
94180d |
+++ b/configure.ac
|
|
|
94180d |
@@ -356,14 +356,31 @@ case $with_suspend_resume in
|
|
|
94180d |
*)
|
|
|
94180d |
AC_MSG_ERROR(--with-suspend-resume must be one of [upower, systemd])
|
|
|
94180d |
;;
|
|
|
94180d |
esac
|
|
|
94180d |
AM_CONDITIONAL(SUSPEND_RESUME_UPOWER, test "x$with_suspend_resume" = "xupower")
|
|
|
94180d |
AM_CONDITIONAL(SUSPEND_RESUME_SYSTEMD, test "x$with_suspend_resume" = "xsystemd")
|
|
|
94180d |
|
|
|
94180d |
+# SELinux support
|
|
|
94180d |
+AC_ARG_WITH(selinux, AS_HELP_STRING([--with-selinux=yes|no|auto], [Build with SELinux (default: auto)]),,[with_selinux=auto])
|
|
|
94180d |
+if test "$with_selinux" = "yes" -o "$with_selinux" = "auto"; then
|
|
|
94180d |
+ PKG_CHECK_MODULES(SELINUX, libselinux, [have_selinux=yes], [have_selinux=no])
|
|
|
94180d |
+else
|
|
|
94180d |
+ have_selinux=no
|
|
|
94180d |
+fi
|
|
|
94180d |
+if test "$with_selinux" = "yes" -a "$have_selinux" = "no"; then
|
|
|
94180d |
+ AC_MSG_ERROR([You must have libselinux installed to build --with-selinux=yes.])
|
|
|
94180d |
+fi
|
|
|
94180d |
+if test "$have_selinux" = "yes"; then
|
|
|
94180d |
+ AC_DEFINE(HAVE_SELINUX, 1, [Define if you have SELinux support])
|
|
|
94180d |
+else
|
|
|
94180d |
+ AC_DEFINE(HAVE_SELINUX, 0, [Define if you have SELinux support])
|
|
|
94180d |
+fi
|
|
|
94180d |
+AM_CONDITIONAL(HAVE_SELINUX, test "${have_selinux}" = "yes")
|
|
|
94180d |
+
|
|
|
94180d |
# libnl support for the linux platform
|
|
|
94180d |
PKG_CHECK_MODULES(LIBNL, libnl-3.0 >= 3.2.8 libnl-route-3.0 libnl-genl-3.0)
|
|
|
94180d |
AC_SUBST(LIBNL_CFLAGS)
|
|
|
94180d |
AC_SUBST(LIBNL_LIBS)
|
|
|
94180d |
|
|
|
94180d |
# uuid library
|
|
|
94180d |
PKG_CHECK_MODULES(UUID, uuid)
|
|
|
94180d |
@@ -844,14 +861,15 @@ if test "${enable_polkit}" = "yes"; then
|
|
|
94180d |
echo " policykit: yes (permissive modify.system)"
|
|
|
94180d |
else
|
|
|
94180d |
echo " policykit: yes (restrictive modify.system)"
|
|
|
94180d |
fi
|
|
|
94180d |
else
|
|
|
94180d |
echo " policykit: no"
|
|
|
94180d |
fi
|
|
|
94180d |
+echo " selinux: $have_selinux"
|
|
|
94180d |
echo
|
|
|
94180d |
|
|
|
94180d |
echo "Features:"
|
|
|
94180d |
echo " wext: $ac_with_wext"
|
|
|
94180d |
echo " wimax: $enable_wimax"
|
|
|
94180d |
echo " ppp: $enable_ppp"
|
|
|
94180d |
echo " modemmanager-1: $with_modem_manager_1"
|
|
|
94180d |
diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c
|
|
|
94180d |
index 4b70813..ca92606 100644
|
|
|
94180d |
--- a/src/settings/plugins/ifcfg-rh/plugin.c
|
|
|
94180d |
+++ b/src/settings/plugins/ifcfg-rh/plugin.c
|
|
|
94180d |
@@ -23,24 +23,30 @@
|
|
|
94180d |
|
|
|
94180d |
#include <config.h>
|
|
|
94180d |
#include <string.h>
|
|
|
94180d |
#include <unistd.h>
|
|
|
94180d |
#include <errno.h>
|
|
|
94180d |
#include <net/ethernet.h>
|
|
|
94180d |
#include <netinet/ether.h>
|
|
|
94180d |
+#include <sys/types.h>
|
|
|
94180d |
+#include <sys/stat.h>
|
|
|
94180d |
|
|
|
94180d |
#include <gmodule.h>
|
|
|
94180d |
#include <glib-object.h>
|
|
|
94180d |
#include <glib/gi18n.h>
|
|
|
94180d |
#include <gio/gio.h>
|
|
|
94180d |
|
|
|
94180d |
#include <dbus/dbus.h>
|
|
|
94180d |
#include <dbus/dbus-glib.h>
|
|
|
94180d |
#include <dbus/dbus-glib-lowlevel.h>
|
|
|
94180d |
|
|
|
94180d |
+#ifdef HAVE_SELINUX
|
|
|
94180d |
+#include <selinux/selinux.h>
|
|
|
94180d |
+#endif
|
|
|
94180d |
+
|
|
|
94180d |
#include <nm-setting-connection.h>
|
|
|
94180d |
|
|
|
94180d |
#include "common.h"
|
|
|
94180d |
#include "nm-dbus-glib-types.h"
|
|
|
94180d |
#include "plugin.h"
|
|
|
94180d |
#include "nm-system-config-interface.h"
|
|
|
94180d |
#include "nm-settings-error.h"
|
|
|
94180d |
@@ -663,16 +669,37 @@ plugin_get_hostname (SCPluginIfcfg *plugin)
|
|
|
94180d |
}
|
|
|
94180d |
|
|
|
94180d |
static gboolean
|
|
|
94180d |
plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname)
|
|
|
94180d |
{
|
|
|
94180d |
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
|
|
|
94180d |
shvarFile *network;
|
|
|
94180d |
+ gboolean ret;
|
|
|
94180d |
+#if HAVE_SELINUX
|
|
|
94180d |
+ security_context_t se_ctx_prev, se_ctx = NULL;
|
|
|
94180d |
+ struct stat file_stat = { .st_mode = 0 };
|
|
|
94180d |
|
|
|
94180d |
- if (!g_file_set_contents (HOSTNAME_FILE, hostname, -1, NULL)) {
|
|
|
94180d |
+ /* Get default context for HOSTNAME_FILE and set it for fscreate */
|
|
|
94180d |
+ stat (HOSTNAME_FILE, &file_stat);
|
|
|
94180d |
+ matchpathcon (HOSTNAME_FILE, file_stat.st_mode, &se_ctx);
|
|
|
94180d |
+ matchpathcon_fini ();
|
|
|
94180d |
+ getfscreatecon (&se_ctx_prev);
|
|
|
94180d |
+ setfscreatecon (se_ctx);
|
|
|
94180d |
+#endif
|
|
|
94180d |
+
|
|
|
94180d |
+ ret = g_file_set_contents (HOSTNAME_FILE, hostname, -1, NULL);
|
|
|
94180d |
+
|
|
|
94180d |
+#if HAVE_SELINUX
|
|
|
94180d |
+ /* Restore previous context and cleanup */
|
|
|
94180d |
+ setfscreatecon (se_ctx_prev);
|
|
|
94180d |
+ freecon (se_ctx);
|
|
|
94180d |
+ freecon (se_ctx_prev);
|
|
|
94180d |
+#endif
|
|
|
94180d |
+
|
|
|
94180d |
+ if (!ret) {
|
|
|
94180d |
PLUGIN_WARN (IFCFG_PLUGIN_NAME, "Could not save hostname: failed to create/open " HOSTNAME_FILE);
|
|
|
94180d |
return FALSE;
|
|
|
94180d |
}
|
|
|
94180d |
|
|
|
94180d |
g_free (priv->hostname);
|
|
|
94180d |
priv->hostname = g_strdup (hostname);
|
|
|
94180d |
|
|
|
94180d |
--
|
|
|
94180d |
1.9.0
|
|
|
94180d |
|
|
|
94180d |
From a2597c08168b87f5107cff6befda8b9118015ccc Mon Sep 17 00:00:00 2001
|
|
|
94180d |
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jklimes@redhat.com>
|
|
|
94180d |
Date: Wed, 26 Mar 2014 16:23:54 +0100
|
|
|
94180d |
Subject: [PATCH] ifcfg-rh: put \n after hostname when writing it to
|
|
|
94180d |
/etc/hostname
|
|
|
94180d |
|
|
|
94180d |
---
|
|
|
94180d |
src/settings/plugins/ifcfg-rh/plugin.c | 6 +++++-
|
|
|
94180d |
1 file changed, 5 insertions(+), 1 deletion(-)
|
|
|
94180d |
|
|
|
94180d |
diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c
|
|
|
94180d |
index ca92606..317c1bf 100644
|
|
|
94180d |
--- a/src/settings/plugins/ifcfg-rh/plugin.c
|
|
|
94180d |
+++ b/src/settings/plugins/ifcfg-rh/plugin.c
|
|
|
94180d |
@@ -669,43 +669,47 @@ plugin_get_hostname (SCPluginIfcfg *plugin)
|
|
|
94180d |
}
|
|
|
94180d |
|
|
|
94180d |
static gboolean
|
|
|
94180d |
plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname)
|
|
|
94180d |
{
|
|
|
94180d |
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
|
|
|
94180d |
shvarFile *network;
|
|
|
94180d |
+ char *hostname_eol;
|
|
|
94180d |
gboolean ret;
|
|
|
94180d |
#if HAVE_SELINUX
|
|
|
94180d |
security_context_t se_ctx_prev, se_ctx = NULL;
|
|
|
94180d |
struct stat file_stat = { .st_mode = 0 };
|
|
|
94180d |
|
|
|
94180d |
/* Get default context for HOSTNAME_FILE and set it for fscreate */
|
|
|
94180d |
stat (HOSTNAME_FILE, &file_stat);
|
|
|
94180d |
matchpathcon (HOSTNAME_FILE, file_stat.st_mode, &se_ctx);
|
|
|
94180d |
matchpathcon_fini ();
|
|
|
94180d |
getfscreatecon (&se_ctx_prev);
|
|
|
94180d |
setfscreatecon (se_ctx);
|
|
|
94180d |
#endif
|
|
|
94180d |
|
|
|
94180d |
- ret = g_file_set_contents (HOSTNAME_FILE, hostname, -1, NULL);
|
|
|
94180d |
+ hostname_eol = g_strdup_printf ("%s\n", hostname);
|
|
|
94180d |
+ ret = g_file_set_contents (HOSTNAME_FILE, hostname_eol, -1, NULL);
|
|
|
94180d |
|
|
|
94180d |
#if HAVE_SELINUX
|
|
|
94180d |
/* Restore previous context and cleanup */
|
|
|
94180d |
setfscreatecon (se_ctx_prev);
|
|
|
94180d |
freecon (se_ctx);
|
|
|
94180d |
freecon (se_ctx_prev);
|
|
|
94180d |
#endif
|
|
|
94180d |
|
|
|
94180d |
if (!ret) {
|
|
|
94180d |
PLUGIN_WARN (IFCFG_PLUGIN_NAME, "Could not save hostname: failed to create/open " HOSTNAME_FILE);
|
|
|
94180d |
+ g_free (hostname_eol);
|
|
|
94180d |
return FALSE;
|
|
|
94180d |
}
|
|
|
94180d |
|
|
|
94180d |
g_free (priv->hostname);
|
|
|
94180d |
priv->hostname = g_strdup (hostname);
|
|
|
94180d |
+ g_free (hostname_eol);
|
|
|
94180d |
|
|
|
94180d |
/* Remove "HOSTNAME" from SC_NETWORK_FILE, if present */
|
|
|
94180d |
network = svNewFile (SC_NETWORK_FILE);
|
|
|
94180d |
if (network) {
|
|
|
94180d |
svSetValue (network, "HOSTNAME", NULL, FALSE);
|
|
|
94180d |
svWriteFile (network, 0644);
|
|
|
94180d |
svCloseFile (network);
|
|
|
94180d |
--
|
|
|
94180d |
1.9.0
|
|
|
94180d |
|
|
|
94180d |
From e9fdfa1700845dcac3702e8869f158d068a7d8a5 Mon Sep 17 00:00:00 2001
|
|
|
94180d |
From: Thomas Haller <thaller@redhat.com>
|
|
|
94180d |
Date: Tue, 1 Apr 2014 23:44:06 +0200
|
|
|
94180d |
Subject: [PATCH] ifcfg-rh: fix compile error with HAVE_SELINUX
|
|
|
94180d |
|
|
|
94180d |
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1070829
|
|
|
94180d |
|
|
|
94180d |
Signed-off-by: Thomas Haller <thaller@redhat.com>
|
|
|
94180d |
---
|
|
|
94180d |
src/settings/plugins/ifcfg-rh/plugin.c | 2 +-
|
|
|
94180d |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
94180d |
|
|
|
94180d |
diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c
|
|
|
94180d |
index 317c1bf..1f9ed47 100644
|
|
|
94180d |
--- a/src/settings/plugins/ifcfg-rh/plugin.c
|
|
|
94180d |
+++ b/src/settings/plugins/ifcfg-rh/plugin.c
|
|
|
94180d |
@@ -35,15 +35,15 @@
|
|
|
94180d |
#include <glib/gi18n.h>
|
|
|
94180d |
#include <gio/gio.h>
|
|
|
94180d |
|
|
|
94180d |
#include <dbus/dbus.h>
|
|
|
94180d |
#include <dbus/dbus-glib.h>
|
|
|
94180d |
#include <dbus/dbus-glib-lowlevel.h>
|
|
|
94180d |
|
|
|
94180d |
-#ifdef HAVE_SELINUX
|
|
|
94180d |
+#if HAVE_SELINUX
|
|
|
94180d |
#include <selinux/selinux.h>
|
|
|
94180d |
#endif
|
|
|
94180d |
|
|
|
94180d |
#include <nm-setting-connection.h>
|
|
|
94180d |
|
|
|
94180d |
#include "common.h"
|
|
|
94180d |
#include "nm-dbus-glib-types.h"
|
|
|
94180d |
--
|
|
|
94180d |
1.9.0
|
|
|
94180d |
|