From patchwork Tue Feb 4 10:09:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Duskett X-Patchwork-Id: 1233238 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=PfMKYVET; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48BgRs1Qk0z9sWd for ; Tue, 4 Feb 2020 21:10:17 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 3E0E78410C; Tue, 4 Feb 2020 10:10:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fyj5a44PE1AN; Tue, 4 Feb 2020 10:10:10 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id C8A3183BE0; Tue, 4 Feb 2020 10:10:10 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id F1F871BF841 for ; Tue, 4 Feb 2020 10:10:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id E805C8506B for ; Tue, 4 Feb 2020 10:10:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TrjpbAmxV4ZF for ; Tue, 4 Feb 2020 10:10:07 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 5086A83336 for ; Tue, 4 Feb 2020 10:09:46 +0000 (UTC) Received: by mail-wr1-f46.google.com with SMTP id t3so2247267wru.7 for ; Tue, 04 Feb 2020 02:09:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AS0F/67+5UNhKSvrCb8mkfJjORc6j11Jzh5mWnXZ4eM=; b=PfMKYVETawVWHhBNgPP8jr52LCxUj+NdzPy4Lu3ovmd67gQFwi9+Z0prHoZh9khBRi CQ5bI7KHL6mPklTBuNiAB0vWAECwBT4bPYhkEnhJSfoWblPPNV2ZwXwY9cGG1BG5Rkdg TuWDqjA4FW6+k2aRwzBjtKJbdaU+sSIhkURv9jDx4fmUGKE4bvKi0QxjJ1w5FNFWK/J1 rW7BZoMEhNu9ehbJIoVFn3wDnvCf5rGIZJ1wnVtfY2KNSEx9Ibb3M2HBpsGQJx5oaGx2 Qa4BuhGPnwOsKCvjNveW09Z6Z7Xpzt81wn6qI8DJ0eQtan/M6+sAWeG+JC4fgyeI8nr3 uGlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AS0F/67+5UNhKSvrCb8mkfJjORc6j11Jzh5mWnXZ4eM=; b=Xn6IXqxYPESo8KiFJMTvywcfT6wqho1hG5cmEKDWXEPM5J4/u720mE0OQBpFOAW6+w QFEvLOd8ZWsAgAUkdVdvLxkDaKb2V+Pk5yNNJaB34ptS5wKHvTvvnCJ9EU/o1c1iLH0C f1LynoRqa1uiYBfQd+qhQV+qaLb75KLnxLRgBSzvitkixTipvEtmwiFGfGkQx1jmdH25 h6aoq15651gs+wC5d8ciVAyIySG7naSxL7mGkYffFZ1rny4kT19VFLnYMCXOC2e4pl8d g13yFtdE0QKCDjKbgFzGTsucHVtWh8tsE5UvyFIscfMUjasih9XtA9CK/kQ67hIwzx+G fbGg== X-Gm-Message-State: APjAAAXFK/DjCDB14A4HK0v8BIghFV6Cn/cgzHJ4RbP+20MZpWxyjqOK TKsnHzr0A+a7Rxg+rMUwGge/uWGrEekgCA== X-Google-Smtp-Source: APXvYqxgFhwvgipuWWT4+h2jbLXrRmqxEKACuuhz5trbPMSl2IyCWMDQ8F9PNXIRteW+wazaLjexVA== X-Received: by 2002:adf:ee0b:: with SMTP id y11mr20942346wrn.62.1580810984959; Tue, 04 Feb 2020 02:09:44 -0800 (PST) Received: from localhost.localdomain ([2620:0:1055:fd00:66f4:6a26:7bb5:b9ee]) by smtp.gmail.com with ESMTPSA id q3sm2944701wmj.38.2020.02.04.02.09.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 02:09:44 -0800 (PST) From: Adam Duskett To: buildroot@buildroot.org Date: Tue, 4 Feb 2020 02:09:42 -0800 Message-Id: <20200204100942.421804-1-aduskett@gmail.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Subject: [Buildroot] [PATCH 1/1] package/restorecond: Fix restorecond init script. X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Adam Duskett Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" The current restorecond init script has several issues which prevent it from starting: - Busybox ash will error at "test $EUID = 0 || exit 4" with the error "sh: 0: unknown operand" - start-stop-daemon is not used - Failures happen silently. Add our own S20restorecond to the package file and use that instead. Signed-off-by: Adam Duskett --- package/restorecond/S20restorecond | 45 ++++++++++++++++++++++++++++++ package/restorecond/restorecond.mk | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 package/restorecond/S20restorecond diff --git a/package/restorecond/S20restorecond b/package/restorecond/S20restorecond new file mode 100644 index 0000000000..1abf678177 --- /dev/null +++ b/package/restorecond/S20restorecond @@ -0,0 +1,45 @@ +#!/bin/sh +RESTORECOND=/usr/sbin/restorecond +PIDFILE=/run/restorecond.pid +if [ -x /usr/sbin/selinuxenabled ]; then + if ! /usr/sbin/selinuxenabled; then + echo "Selinux is not enabled!" + exit 7 + fi +fi + +# Check that we are root ... so non-root users stop here +if [ $EUID != 0 ]; then + echo "Restorecond must be ran as root!" + exit 4 +fi + +test -x /usr/sbin/restorecond || exit 5 +test -f /etc/selinux/restorecond.conf || exit 6 + +case "$1" in + start) + echo "Starting restorecond..." + unset HOME MAIL USER USERNAME + start-stop-daemon -S -x "${RESTORECOND}" -p "${PIDFILE}" + ;; + stop) + echo "Stopping restorecond..." + start-stop-daemon -K -x "${RESTORECOND}" -p "${PIDFILE}" -o + ;; + reload|force-reload) + echo "Reloading restorecond..." + restart + ;; + restart) + stop + start + ;; + condrestart) + [ -e /var/lock/subsys/restorecond ] && restart + ;; + *) + echo "Usage: $0 {start|stop|restart|reload|force-reload|condrestart}" + exit 3 + ;; +esac diff --git a/package/restorecond/restorecond.mk b/package/restorecond/restorecond.mk index c519b5de2b..cb4859c2d0 100644 --- a/package/restorecond/restorecond.mk +++ b/package/restorecond/restorecond.mk @@ -27,7 +27,7 @@ define RESTORECOND_BUILD_CMDS endef define RESTORECOND_INSTALL_INIT_SYSV - $(INSTALL) -m 0755 -D $(@D)/restorecond.init \ + $(INSTALL) -m 0755 -D $(RESTORECOND_PKGDIR)/S20restorecond \ $(TARGET_DIR)/etc/init.d/S20restorecond endef