joe/joe-3.8-selinux.patch

111 lines
2.7 KiB
Diff

From d4a984eeb9978611725a9a91ccee787cddb6b38b Mon Sep 17 00:00:00 2001
From: Jan Chaloupka <jchaloup@redhat.com>
Date: Mon, 23 Mar 2015 10:57:15 +0100
Subject: [PATCH] selinux
---
configure | 1 +
joe/selinux.c | 18 +++++++++---------
joe/ufile.c | 4 ++--
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/configure b/configure
index 1293ec9..89237d6 100755
--- a/configure
+++ b/configure
@@ -5434,6 +5434,7 @@ if test "$ac_cv_header_selinux_selinux_h" = "yes" -a "$ac_cv_header_selinux_cont
$as_echo "#define HAVE_SELINUX 1" >>confdefs.h
+LIBS="$LIBS -lselinux"
fi
# Checks for typedefs, structures, and compiler characteristics.
diff --git a/joe/selinux.c b/joe/selinux.c
index 953e0fd..8bdbb0a 100644
--- a/joe/selinux.c
+++ b/joe/selinux.c
@@ -4,7 +4,9 @@
*/
#include "types.h"
-#ifdef WITH_SELINUX
+#include "config.h"
+
+#ifdef HAVE_SELINUX
#include <selinux/selinux.h>
static int selinux_enabled = -1;
#endif
@@ -13,7 +15,7 @@ int
copy_security_context(const char *from_file, const char *to_file)
{
int status = 0;
-#ifdef WITH_SELINUX
+#ifdef HAVE_SELINUX
security_context_t from_context;
security_context_t to_context;
@@ -38,9 +40,7 @@ copy_security_context(const char *from_file, const char *to_file)
}
if (getfilecon(to_file, &to_context) < 0) {
- MSG_PUTS(_(joe_gettext(_("\nCould not get security context for "))));
- msg_outtrans(to_file);
- msg_putchar('\n');
+ error(0, errno, "Could not get security context for %s", to_file);
freecon(from_context);
return 1;
}
@@ -63,7 +63,7 @@ copy_security_context(const char *from_file, const char *to_file)
int match_default_security_context(const char *from_file)
{
-#ifdef WITH_SELINUX
+#ifdef HAVE_SELINUX
security_context_t scontext;
if (selinux_enabled == -1)
@@ -102,7 +102,7 @@ int match_default_security_context(const char *from_file)
int reset_default_security_context()
{
-#ifdef WITH_SELINUX
+#ifdef HAVE_SELINUX
if (selinux_enabled == -1)
selinux_enabled = (is_selinux_enabled() > 0);
@@ -121,7 +121,7 @@ int reset_default_security_context()
int output_security_context(const char *from_file)
{
-#ifdef WITH_SELINUX
+#ifdef HAVE_SELINUX
security_context_t scontext;
if (selinux_enabled == -1)
@@ -153,7 +153,7 @@ int output_security_context(const char *from_file)
/*
Test program compile using the following command
- cc -o t t.c -DWITH_SELINUX -DTEST -lselinux
+ cc -o t t.c -DHAVE_SELINUX -DTEST -lselinux
*/
#include <stdio.h>
diff --git a/joe/ufile.c b/joe/ufile.c
index fe3c252..e0f7754 100644
--- a/joe/ufile.c
+++ b/joe/ufile.c
@@ -157,7 +157,7 @@ static int cp(char *from, char *to)
utime(to, &utbuf);
#endif
-#ifdef WITH_SELINUX
+#ifdef HAVE_SELINUX
copy_security_context(from,to);
#endif
--
1.9.3