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 9E45D1396D0 for ; Mon, 18 Sep 2017 18:07:24 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id AF03A1FC009; Mon, 18 Sep 2017 18:07:22 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.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 8B7031FC009 for ; Mon, 18 Sep 2017 18:07:22 +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 8846F33FE7D for ; Mon, 18 Sep 2017 18:07:21 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id F2BF79080 for ; Mon, 18 Sep 2017 18:07:19 +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: <1505748522.fbab2affd2d5309ed4b5416e0e239902d77b4232.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:0.31.x commit in: src/rc/ X-VCS-Repository: proj/openrc X-VCS-Files: src/rc/rc-selinux.c X-VCS-Directories: src/rc/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: fbab2affd2d5309ed4b5416e0e239902d77b4232 X-VCS-Branch: 0.31.x Date: Mon, 18 Sep 2017 18:07:19 +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: a91f7404-aefa-4bb9-90ef-e135d1a457c2 X-Archives-Hash: 7fc9dc03aa2b1acf039eb58811aab815 commit: fbab2affd2d5309ed4b5416e0e239902d77b4232 Author: Jason Zaman perfinion com> AuthorDate: Sun Sep 17 13:15:13 2017 +0000 Commit: William Hubbs gentoo org> CommitDate: Mon Sep 18 15:28:42 2017 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=fbab2aff selinux: use openrc contexts path to get contexts The minimum requirement for libselinux is now >=2.6 The refpolicy and the gentoo policy contain the contexts since version 2.20170204-r4 src/rc/rc-selinux.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/rc/rc-selinux.c b/src/rc/rc-selinux.c index 2eb631a6..514ca5e5 100644 --- a/src/rc/rc-selinux.c +++ b/src/rc/rc-selinux.c @@ -39,7 +39,6 @@ #include "rc-selinux.h" /* the context files for selinux */ -#define RUN_INIT_FILE "run_init_type" #define INITRC_FILE "initrc_context" #ifdef HAVE_AUDIT @@ -299,6 +298,26 @@ static int read_context_file(const char *filename, char **context) return ret; } +static int read_run_init_context(char **context) +{ + int ret = -1; + RC_STRINGLIST *list; + char *value = NULL; + + list = rc_config_list(selinux_openrc_contexts_path()); + if (list == NULL) + return ret; + + value = rc_config_value(list, "run_init"); + if (value != NULL && strlen(value) > 0) { + *context = xstrdup(value); + ret = 0; + } + + rc_stringlist_free(list); + return ret; +} + void selinux_setup(char **argv) { char *new_context = NULL; @@ -312,7 +331,7 @@ void selinux_setup(char **argv) return; } - if (read_context_file(RUN_INIT_FILE, &run_init_t) != 0) { + if (read_run_init_context(&run_init_t) != 0) { /* assume a reasonable default, rather than bailing out */ run_init_t = xstrdup("run_init_t"); ewarn("Assuming SELinux run_init type is %s", run_init_t);