All of lore.kernel.org
 help / color / mirror / Atom feed
From: william.c.roberts@intel.com
To: selinux@tycho.nsa.gov, seandroid-list@tycho.nsa.gov, sds@tycho.nsa.gov
Subject: [PATCH 1/2] libselinux: introduce configurable backends
Date: Mon, 26 Sep 2016 10:33:38 -0700	[thread overview]
Message-ID: <1474911219-20465-2-git-send-email-william.c.roberts@intel.com> (raw)
In-Reply-To: <1474911219-20465-1-git-send-email-william.c.roberts@intel.com>

From: William Roberts <william.c.roberts@intel.com>

On Android for both the host build, and the target, certain
backends are not needed:
 - X Backend
 - DB Backend
 - Media Backend

Introduce the following defines for removing them from the
built library:

 - NO_X_BACKEND
 - NO_DB_BACKEND
 - NO_MEDIA_BACKEND

When configured with these options and an attempt
is made to use them, selabel_open() will return
ENOTSUP.

Signed-off-by: William Roberts <william.c.roberts@intel.com>
---
 libselinux/src/label.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/libselinux/src/label.c b/libselinux/src/label.c
index 963bfcb..96a4ff1 100644
--- a/libselinux/src/label.c
+++ b/libselinux/src/label.c
@@ -17,15 +17,33 @@
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
+#ifdef NO_MEDIA_BACKEND
+#define CONFIG_MEDIA_BACKEND(fnptr) NULL
+#else
+#define CONFIG_MEDIA_BACKEND(fnptr) &fnptr
+#endif
+
+#ifdef NO_X_BACKEND
+#define CONFIG_X_BACKEND(fnptr) NULL
+#else
+#define CONFIG_X_BACKEND(fnptr) &fnptr
+#endif
+
+#ifdef NO_DB_BACKEND
+#define CONFIG_DB_BACKEND(fnptr) NULL
+#else
+#define CONFIG_DB_BACKEND(fnptr) &fnptr
+#endif
+
 typedef int (*selabel_initfunc)(struct selabel_handle *rec,
 				const struct selinux_opt *opts,
 				unsigned nopts);
 
 static selabel_initfunc initfuncs[] = {
 	&selabel_file_init,
-	&selabel_media_init,
-	&selabel_x_init,
-	&selabel_db_init,
+	CONFIG_MEDIA_BACKEND(selabel_media_init),
+	CONFIG_X_BACKEND(selabel_x_init),
+	CONFIG_DB_BACKEND(selabel_db_init),
 	&selabel_property_init,
 };
 
@@ -325,6 +343,11 @@ struct selabel_handle *selabel_open(unsigned int backend,
 		goto out;
 	}
 
+	if (!initfuncs[backend]) {
+		errno = ENOTSUP;
+		goto out;
+	}
+
 	rec = (struct selabel_handle *)malloc(sizeof(*rec));
 	if (!rec)
 		goto out;
-- 
1.9.1

  reply	other threads:[~2016-09-26 17:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-26 17:33 Android Fork william.c.roberts
2016-09-26 17:33 ` william.c.roberts [this message]
2016-09-26 17:33 ` [PATCH 2/2] libselinux: add ifdef'ing for ANDROID and BUILD_HOST william.c.roberts
2016-09-26 19:22   ` Stephen Smalley
2016-09-26 17:49 ` Android Fork William Roberts
2016-09-26 19:10 ` Stephen Smalley
2016-09-26 19:47   ` William Roberts
2016-09-27 14:50 ` Jason Zaman
2016-09-27 14:59   ` William Roberts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1474911219-20465-2-git-send-email-william.c.roberts@intel.com \
    --to=william.c.roberts@intel.com \
    --cc=sds@tycho.nsa.gov \
    --cc=seandroid-list@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.