From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 8E30E138334 for ; Fri, 2 Nov 2018 23:24:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6C88EE0937; Fri, 2 Nov 2018 23:24:42 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3EE5FE0937 for ; Fri, 2 Nov 2018 23:24:40 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 54EDB335C94 for ; Fri, 2 Nov 2018 23:24:38 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 42EB3455 for ; Fri, 2 Nov 2018 23:24:36 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <1541200931.ee3c4afdb75b98cd472b7ffbb46adc9d8a1e1b15.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: src/rc/ X-VCS-Repository: proj/openrc X-VCS-Files: src/rc/openrc-init.c X-VCS-Directories: src/rc/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: ee3c4afdb75b98cd472b7ffbb46adc9d8a1e1b15 X-VCS-Branch: master Date: Fri, 2 Nov 2018 23:24:36 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 4b85fd2a-7372-4ba0-8506-8f4d5e4a433e X-Archives-Hash: 57419370cef29b0d33fd24bd5e246ea3 commit: ee3c4afdb75b98cd472b7ffbb46adc9d8a1e1b15 Author: William Hubbs gmail com> AuthorDate: Fri Nov 2 23:22:11 2018 +0000 Commit: William Hubbs gentoo org> CommitDate: Fri Nov 2 23:22:11 2018 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=ee3c4afd openrc-init: add SELinux support This is for #173. src/rc/openrc-init.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/rc/openrc-init.c b/src/rc/openrc-init.c index e557c63d..c57a3b06 100644 --- a/src/rc/openrc-init.c +++ b/src/rc/openrc-init.c @@ -31,6 +31,10 @@ #include #include +#ifdef HAVE_SELINUX +# include +#endif + #include "helpers.h" #include "rc.h" #include "rc-wtmp.h" @@ -161,10 +165,36 @@ int main(int argc, char **argv) bool reexec = false; sigset_t signals; struct sigaction sa; +#ifdef HAVE_SELINUX + int enforce = 0; +#endif if (getpid() != 1) return 1; +#ifdef HAVE_SELINUX + if (getenv("SELINUX_INIT") == NULL) { + if (is_selinux_enabled() != 1) { + if (selinux_init_load_policy(&enforce) == 0) { + putenv("SELINUX_INIT=YES"); + execv(argv[0], argv); + } else { + if (enforce > 0) { + /* + * SELinux in enforcing mode but load_policy failed + * At this point, we probably can't open /dev/console, + * so log() won't work + */ + fprintf(stderr,"Unable to load SELinux Policy.\n"); + fprintf(stderr,"Machine is in enforcing mode.\n"); + fprintf(stderr,"Halting now.\n"); + exit(1); + } + } + } + } +#endif + printf("OpenRC init version %s starting\n", VERSION); if (argc > 1)