commit: a4cf61e8bf827dc405a547c314e840dab11fc979
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Mar 25 05:57:05 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Mar 25 06:01:38 2015 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a4cf61e8
selinux: unconditionally include the header and provide stub methods
If selinux is disabled, then stub methods will be provided instead of
calling the real methods. This removes some warnings about unused
parameters which used to be covered up with #ifdef HAVE_SELINUX.
Signed-off-by: Jason Zaman <jason <AT> perfinion.com>
src/rc/checkpath.c | 9 ++-------
src/rc/rc-selinux.h | 14 ++++++++++++++
src/rc/runscript.c | 5 -----
3 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 034cb4d..3acb040 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -45,10 +45,7 @@
#include "builtins.h"
#include "einfo.h"
#include "rc-misc.h"
-
-#ifdef HAVE_SELINUX
#include "rc-selinux.h"
-#endif
typedef enum {
inode_unknown = 0,
@@ -164,8 +161,10 @@ static int do_check(char *path, uid_t uid, gid_t gid,
mode_t mode,
}
}
+#ifdef HAVE_SELINUX
if (selinux_on)
selinux_util_label(path);
+#endif
return 0;
}
@@ -294,10 +293,8 @@ int checkpath(int argc, char **argv)
if (gr)
gid = gr->gr_gid;
-#ifdef HAVE_SELINUX
if (selinux_util_open() == 1)
selinux_on = true;
-#endif
while (optind < argc) {
if (writable)
@@ -307,10 +304,8 @@ int checkpath(int argc, char **argv)
optind++;
}
-#ifdef HAVE_SELINUX
if (selinux_on)
selinux_util_close();
-#endif
return retval;
}
diff --git a/src/rc/rc-selinux.h b/src/rc/rc-selinux.h
index e28f333..039890b 100644
--- a/src/rc/rc-selinux.h
+++ b/src/rc/rc-selinux.h
@@ -26,10 +26,24 @@
#ifndef RC_SELINUX_UTIL_H
#define RC_SELINUX_UTIL_H
+#ifdef HAVE_SELINUX
+
int selinux_util_open(void);
int selinux_util_label(const char *path);
int selinux_util_close(void);
void selinux_setup(char **argv);
+#else
+
+/* always return false for selinux_util_open() */
+#define selinux_util_open() (0)
+#define selinux_util_label(x) do { } while(0)
+#define selinux_util_close() do { } while(0)
+
+#define selinux_setup(x) do { } while(0)
+
+#endif
+
+
#endif
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 0ac1966..e59c6ae 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -66,10 +66,7 @@
#include "rc.h"
#include "rc-misc.h"
#include "rc-plugin.h"
-
-#ifdef HAVE_SELINUX
#include "rc-selinux.h"
-#endif
#define PREFIX_LOCK RC_SVCDIR "/prefix.lock"
@@ -1191,10 +1188,8 @@ openrc_run(int argc, char **argv)
eprefix(prefix);
}
-#ifdef HAVE_SELINUX
/* Ok, we are ready to go, so setup selinux if applicable */
selinux_setup(argv);
-#endif
deps = true;