From patchwork Mon Sep 26 20:53:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Roberts, William C" X-Patchwork-Id: 9351289 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 940EA6077B for ; Mon, 26 Sep 2016 20:54:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A01028D4E for ; Mon, 26 Sep 2016 20:54:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E93A28E30; Mon, 26 Sep 2016 20:54:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received: from emsm-gh1-uea10.nsa.gov (smtp.nsa.gov [8.44.101.8]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8CE1028D4E for ; Mon, 26 Sep 2016 20:54:12 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.30,401,1470700800"; d="scan'208";a="17985063" IronPort-PHdr: =?us-ascii?q?9a23=3A6YrtuxaRxXqKkRRp4eVnOzj/LSx+4OfEezUN459i?= =?us-ascii?q?sYplN5qZpcW4bnLW6fgltlLVR4KTs6sC0LuM9fm7EjVdvN6oizMrSNR0TRgLiM?= =?us-ascii?q?EbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpQAbFhi3Dwdp?= =?us-ascii?q?POO9QteU1JXtkbnpsMSOPk1hv3mUWftKNhK4rAHc5IE9oLBJDeIP8CbPuWZCYO?= =?us-ascii?q?9MxGlldhq5lhf44dqsrtY4q3wD888784Z8dYmyP+FhFf0LRAghZns44MztqAnr?= =?us-ascii?q?URqE5nxaVH4f1BVPHUyN9xzzWJvrtSr28+58wzWyIdz9TbdyXy+rqahsVlugky?= =?us-ascii?q?scHyIo+2HQzMprheRUpwzyiQZ4xtvLYYWRNfN7OKibZ9QQSHBdRe5QUTBMBsW3?= =?us-ascii?q?aI5cXKI6Ie9Eotyl9BM1phykCFzpXbvi?= X-IPAS-Result: =?us-ascii?q?A2HIBADMielX/wHyM5BdGwEBAQMBAQEJAQEBFwEBBAEBCgE?= =?us-ascii?q?BgxIBAQEBAR6BU6Y7lEQgh2lMAQEBAQEBAQECAQJbJ4IyBAMTBYIYAjcUIA4DC?= =?us-ascii?q?QIXCCEICAMBLRUYBwsFGASIKr90ASSIO4ZmEQGFegWINoZ1ikuPaAKJe4VuSJA?= =?us-ascii?q?fVIUlUgGFRniBJwEBAQ?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea10.nsa.gov with ESMTP; 26 Sep 2016 20:54:10 +0000 Received: from prometheus.infosec.tycho.ncsc.mil (prometheus [192.168.25.40]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u8QKroGA003795; Mon, 26 Sep 2016 16:53:55 -0400 Received: from tarius.tycho.ncsc.mil (tarius.infosec.tycho.ncsc.mil [144.51.242.1]) by prometheus.infosec.tycho.ncsc.mil (8.15.2/8.15.2) with ESMTP id u8QKrIVs254207 for ; Mon, 26 Sep 2016 16:53:18 -0400 Received: from goalie.tycho.ncsc.mil (goalie [144.51.242.250]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u8QKrIvK003775; Mon, 26 Sep 2016 16:53:18 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1CGBACXielX/yNjr8ZdGgEBAQECAQEBAQgBAQEBgz0BAQEBAR6BU7ZzhBMUhgqBZEwBAgEBAQEBAl6GCDCBDxKIS79mATCIO4lgC4MHBYg2hnWKS49oAo9pSJAfVIUlHjQBh2UBAQE X-IPAS-Result: A1CGBACXielX/yNjr8ZdGgEBAQECAQEBAQgBAQEBgz0BAQEBAR6BU7ZzhBMUhgqBZEwBAgEBAQEBAl6GCDCBDxKIS79mATCIO4lgC4MHBYg2hnWKS49oAo9pSJAfVIUlHjQBh2UBAQE X-IronPort-AV: E=Sophos;i="5.30,401,1470715200"; d="scan'208";a="5729707" Received: from emsm-gh1-uea11.corp.nsa.gov (HELO emsm-gh1-uea11.nsa.gov) ([10.208.41.37]) by goalie.tycho.ncsc.mil with ESMTP; 26 Sep 2016 16:53:18 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3ARIyvlRWeY7n5/VcO/2rF9Br7NNnV8LGtZVwlr6E/?= =?us-ascii?q?grcLSJyIuqrYZxWAt8tkgFKBZ4jH8fUM07OQ6PG6HzVbqs/c6jgrS99lb1c9k8?= =?us-ascii?q?IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUiv2OQc9?= =?us-ascii?q?HOnpAIma153xjLHovcSIKFwV3nKUWvBbFF2OtwLft80b08NJC50a7V/3mEZOYP?= =?us-ascii?q?lc3mhyJFiezF7W78a0+4N/oWwL46pyv+YJa6jxfrw5QLpEF3xmdjltvIy4gyLE?= =?us-ascii?q?VxeC6kERWWQOyFIIX1CEv1nGWcLqvy/7sPdt8DWLNs3xC7YvUHKt6LkvAATlgS?= =?us-ascii?q?ELLTk4/CTTi9dspL5KqxKm4RpkysjbZ5/RfOFyZYvBbNgaQixHRc8XWCtfUa2m?= =?us-ascii?q?aI5aEOsFOedRqs/24UEJpxakGRKEBeXzxzsOjXjzjv5y6PgoDQyThF9oJNkJqn?= =?us-ascii?q?mB6YutOQ=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0ETBAAMiulX/yNjr8ZdGgEBAQECAQEBA?= =?us-ascii?q?QgBAQEBFgEBAQMBAQEJAQEBgxIBAQEBAR6BU6Y7kDiEExSGCoFkTAEBAQEBAQE?= =?us-ascii?q?BAgECWyeCMgQBFQWDEDCBDxKIS79rAQsliDuJYAuDBwWINoZ1ikuPaAKPaUiQH?= =?us-ascii?q?1SFJR40AYYlgUABAQE?= X-IPAS-Result: =?us-ascii?q?A0ETBAAMiulX/yNjr8ZdGgEBAQECAQEBAQgBAQEBFgEBAQM?= =?us-ascii?q?BAQEJAQEBgxIBAQEBAR6BU6Y7kDiEExSGCoFkTAEBAQEBAQEBAgECWyeCMgQBF?= =?us-ascii?q?QWDEDCBDxKIS79rAQsliDuJYAuDBwWINoZ1ikuPaAKPaUiQH1SFJR40AYYlgUA?= =?us-ascii?q?BAQE?= X-IronPort-AV: E=Sophos;i="5.30,401,1470700800"; d="scan'208";a="19566591" Received: from fmsmga002-icc.fm.intel.com ([198.175.99.35]) by emsm-gh1-uea11.nsa.gov with ESMTP; 26 Sep 2016 20:53:13 +0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga002-icc.fm.intel.com with ESMTP; 26 Sep 2016 13:53:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,401,1470726000"; d="scan'208";a="884022532" Received: from rbella-mobl.amr.corp.intel.com (HELO wcrobert-MOBL1.amr.corp.intel.com) ([10.252.203.45]) by orsmga003.jf.intel.com with ESMTP; 26 Sep 2016 13:53:12 -0700 From: william.c.roberts@intel.com To: selinux@tycho.nsa.gov, seandroid-list@tycho.nsa.gov, sds@tycho.nsa.gov Subject: [PATCH v2] libselinux: add ANDROID_HOST=y build option Date: Mon, 26 Sep 2016 13:53:09 -0700 Message-Id: <1474923189-26431-1-git-send-email-william.c.roberts@intel.com> X-Mailer: git-send-email 1.9.1 X-BeenThere: selinux@tycho.nsa.gov X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: MIME-Version: 1.0 Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Virus-Scanned: ClamAV using ClamSMTP From: William Roberts To build the selinux host configuration, specify ANDROID_HOST=y on the Make command line. eg) make ANDROID_HOST=y Signed-off-by: William Roberts --- libselinux/Makefile | 8 +++++++- libselinux/src/Makefile | 50 +++++++++++++++++++++++++++++++++---------------- 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/libselinux/Makefile b/libselinux/Makefile index 5a8d42c..50ae009 100644 --- a/libselinux/Makefile +++ b/libselinux/Makefile @@ -10,6 +10,12 @@ ifeq ($(EMBEDDED),y) override DISABLE_RPM=y override DISABLE_BOOL=y endif +ifeq ($(ANDROID_HOST),y) + override DISABLE_SETRANS=y + EMFLAGS+= -DDISABLE_RPM -DNO_MEDIA_BACKEND -DNO_DB_BACKEND -DNO_X_BACKEND \ + -DBUILD_HOST + SUBDIRS = src +endif ifeq ($(DISABLE_AVC),y) EMFLAGS+= -DDISABLE_AVC endif @@ -22,7 +28,7 @@ endif ifeq ($(DISABLE_SETRANS),y) EMFLAGS+= -DDISABLE_SETRANS endif -export DISABLE_AVC DISABLE_SETRANS DISABLE_RPM DISABLE_BOOL EMFLAGS +export DISABLE_AVC DISABLE_SETRANS DISABLE_RPM DISABLE_BOOL EMFLAGS ANDROID_HOST USE_PCRE2 ?= n ifeq ($(USE_PCRE2),y) diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile index 36e42b8..d841ef7 100644 --- a/libselinux/src/Makefile +++ b/libselinux/src/Makefile @@ -47,9 +47,17 @@ endif ifeq ($(DISABLE_BOOL),y) UNUSED_SRCS+=booleans.c endif +ifeq ($(ANDROID_HOST),y) + SRCS=callbacks.c freecon.c label.c label_file.c \ + label_android_property.c regex.c label_support.c \ + matchpathcon.c setrans_client.c sha1.c + override CFLAGS += -DNO_MEDIA_BACKEND -DNO_DB_BACKEND -DNO_X_BACKEND \ + -DBUILD_HOST +else + SRCS= $(filter-out $(UNUSED_SRCS) $(GENERATED) audit2why.c, $(sort $(wildcard *.c))) +endif GENERATED=$(SWIGCOUT) $(SWIGRUBYCOUT) selinuxswig_python_exception.i -SRCS= $(filter-out $(UNUSED_SRCS) $(GENERATED) audit2why.c, $(sort $(wildcard *.c))) MAX_STACK_SIZE=32768 @@ -92,6 +100,28 @@ SWIG = swig -Wall -python -o $(SWIGCOUT) -outdir ./ $(EMFLAGS) SWIGRUBY = swig -Wall -ruby -o $(SWIGRUBYCOUT) -outdir ./ $(EMFLAGS) +$(LIBA): $(OBJS) + $(AR) rcs $@ $^ + $(RANLIB) $@ + +$(LIBSO): $(LOBJS) + $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS) -L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs,-z,relro + ln -sf $@ $(TARGET) + +%.o: %.c policy.h + $(CC) $(CFLAGS) $(TLSFLAGS) -c -o $@ $< + +%.lo: %.c policy.h + $(CC) $(CFLAGS) -fPIC -DSHARED -c -o $@ $< + +# ANDROID_HOST Build option only builds the shared and static versions of +# libselinux. +ifeq ($(ANDROID_HOST),y) + +all: $(LIBA) $(LIBSO) + +else + all: $(LIBA) $(LIBSO) $(LIBPC) pywrap: all $(SWIGFILES) $(AUDIT2WHYSO) @@ -110,14 +140,6 @@ $(SWIGSO): $(SWIGLOBJ) $(SWIGRUBYSO): $(SWIGRUBYLOBJ) $(CC) $(CFLAGS) -shared -o $@ $^ -L. -lselinux $(LDFLAGS) -L$(LIBDIR) -$(LIBA): $(OBJS) - $(AR) rcs $@ $^ - $(RANLIB) $@ - -$(LIBSO): $(LOBJS) - $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS) -L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs,-z,relro - ln -sf $@ $(TARGET) - $(LIBPC): $(LIBPC).in ../VERSION sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBBASE):; s:@includedir@:$(INCLUDEDIR):' < $< > $@ @@ -130,12 +152,6 @@ $(AUDIT2WHYLOBJ): audit2why.c $(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(CC) $(CFLAGS) -shared -o $@ $^ -L. $(LDFLAGS) -lselinux $(LIBDIR)/libsepol.a -L$(LIBDIR) -%.o: %.c policy.h - $(CC) $(CFLAGS) $(TLSFLAGS) -c -o $@ $< - -%.lo: %.c policy.h - $(CC) $(CFLAGS) -fPIC -DSHARED -c -o $@ $< - $(SWIGCOUT): $(SWIGIF) $(SWIG) $< @@ -178,4 +194,6 @@ distclean: clean indent: ../../scripts/Lindent $(filter-out $(GENERATED),$(wildcard *.[ch])) -.PHONY: all clean pywrap rubywrap swigify install install-pywrap install-rubywrap distclean +.PHONY: clean pywrap rubywrap swigify install install-pywrap install-rubywrap distclean +endif +.PHONY: all