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 90E331396D0 for ; Mon, 18 Sep 2017 18:07:41 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F3DE21FC0C1; Mon, 18 Sep 2017 18:07:40 +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 D2C781FC0BA for ; Mon, 18 Sep 2017 18:07: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 19D8033FE49 for ; Mon, 18 Sep 2017 18:07:40 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id B1A0F9084 for ; Mon, 18 Sep 2017 18:07:38 +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: <1505666407.b1c3422f453921e838d419640fe39144dbf8d13d.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master 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: b1c3422f453921e838d419640fe39144dbf8d13d X-VCS-Branch: master Date: Mon, 18 Sep 2017 18:07:38 +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: acc2d8b9-2a62-46fa-bc97-54a8b4c855aa X-Archives-Hash: f65ce4075894dccef01bc218b2a5452b commit: b1c3422f453921e838d419640fe39144dbf8d13d Author: Jason Zaman perfinion com> AuthorDate: Sun Sep 17 13:15:13 2017 +0000 Commit: William Hubbs gentoo org> CommitDate: Sun Sep 17 16:40:07 2017 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b1c3422f 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);