From patchwork Sat Mar 11 00:53:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 9618283 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 661996046A for ; Sat, 11 Mar 2017 00:53:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50B8E28763 for ; Sat, 11 Mar 2017 00:53:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44933287B4; Sat, 11 Mar 2017 00:53:39 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE85928763 for ; Sat, 11 Mar 2017 00:53:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933066AbdCKAxj (ORCPT ); Fri, 10 Mar 2017 19:53:39 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:34288 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932790AbdCKAxi (ORCPT ); Fri, 10 Mar 2017 19:53:38 -0500 Received: by mail-pf0-f193.google.com with SMTP id o126so12421929pfb.1 for ; Fri, 10 Mar 2017 16:53:37 -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; bh=lVWLt0scCCJsoUkXoC4rsXEPnLnBzUd4ldch/1JgAUQ=; b=Q7tpeu3Ir8qmZoRziO6bmZ5vB2d5stEEZFOrBIlK+ju0f4/YHO+i4Lt7DlYvQoPRU4 A/sOCdj6w06bn0lAhkC1DLTlVl8iArtx0aQCEYeNLh9fgyyalOY68NeCSKJwGLNJJSuP +fNooPpOcQU9qWvV9wZAPn4vennxWV372jynkvQjF5fZgM9+7sfa6agowumvpDjL/n52 Dv3qbhvJLVcdufjOZOQ9voLrLkSEkNA5wdO+wQq2vHwK9Wa3+P+3/vWi3yoYrzVr2kUP 3eon2TuwSGMu9doKci3pcS66ZgrwOSgEkN6awDg64FUMu5GjAPzh00Li3M74LOI4+cBx +8AQ== 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; bh=lVWLt0scCCJsoUkXoC4rsXEPnLnBzUd4ldch/1JgAUQ=; b=ouDKkNsl5+0nU7X7yLJT45c67EqE2n0Xns3rJfF886dwS2y4X5/93i+AKiV3HZAdUD Z1ADixTpZYju8R8nj59SColKOHj424bnDvl+3aFubUEpIq5qA+tQCsb3K5Yx87L/swQJ xryB2PRd5+jKPWT8cTbYRYOxJAnBGfwgJ02dWd/xgPMeAitnume6Aor95ay0d1a+D/jt gvYa1esrl+/1Ol3YXk6+gGrEm1WqBlonKW9MU0FP0/QB+eLzOGYUgjn8TXaBk3I3LtJo Wt4vQnDuNkB2cOqnzqXRaiyFg3N2Hd8ts/LItL8YLmxaYD7vFklvmePapRJqMepDlhLh ARoQ== X-Gm-Message-State: AMke39mjeicRXqKd7iwN7jLWvp594c3FgcaQoeMLMCFFBsYxCVkF7cKKWRoTr88m98/LXA== X-Received: by 10.98.6.133 with SMTP id 127mr24422441pfg.110.1489193617155; Fri, 10 Mar 2017 16:53:37 -0800 (PST) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.119.30.131]) by smtp.gmail.com with ESMTPSA id b77sm20766647pfl.2.2017.03.10.16.53.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Mar 2017 16:53:36 -0800 (PST) From: Eric Biggers To: Theodore Ts'o Cc: fstests@vger.kernel.org, Eric Biggers Subject: [PATCH] android-xfstests: allow detection of SELinux Date: Fri, 10 Mar 2017 16:53:06 -0800 Message-Id: <20170311005306.129624-1-ebiggers3@gmail.com> X-Mailer: git-send-email 2.12.0.246.ga2ecc84866-goog Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers xfstests is supposed to disable the creation of SELinux xattrs because this interferes with some tests (e.g. generic/062 and generic/377), but this was not working on Android. For the android-xfstests portion of the fix, make the following changes: 1. To stop the mount program from stripping the 'context' mount option, mount selinuxfs and create an empty /etc/selinux/config. This makes the is_selinux_enabled() function from libselinux return true. 2. To stop xfstests from thinking that SELinux is disabled, link /usr/sbin/selinuxenabled to /bin/true. (Note: getting the real version of selinuxenabled by adding selinux-utils to the chroot tarball would also work, though no other programs from it are needed yet, and some don't work in the chroot environment yet.) In combination with the xfstests patch to stop hard-coding SELinux contexts in xfstests, this fixes the failing tests. Signed-off-by: Eric Biggers --- kvm-xfstests/android-xfstests | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kvm-xfstests/android-xfstests b/kvm-xfstests/android-xfstests index 7e3eab3..e798c7e 100755 --- a/kvm-xfstests/android-xfstests +++ b/kvm-xfstests/android-xfstests @@ -81,6 +81,14 @@ chroot_prepare() ! mountpoint $CHROOT_DIR/proc > /dev/null && mount proc -t proc $CHROOT_DIR/proc ! mountpoint $CHROOT_DIR/dev > /dev/null && mount --bind /dev $CHROOT_DIR/dev +# Allow xfstests to detect that SELinux is in use. +! mountpoint $CHROOT_DIR/sys/fs/selinux > /dev/null && \ + mount selinuxfs -t selinuxfs $CHROOT_DIR/sys/fs/selinux +touch $CHROOT_DIR/etc/selinux/config +if [ ! -e $CHROOT_DIR/usr/sbin/selinuxenabled ]; then + ln $CHROOT_DIR/bin/true $CHROOT_DIR/usr/sbin/selinuxenabled +fi + # 'mountpoint' doesn't work with directory bind mounts; use /proc/mounts instead if ! cut -d' ' -f2 /proc/mounts 2>/dev/null | grep -q '^$CHROOT_DIR/results$'; then mkdir -p $RESULTS_DIR @@ -92,6 +100,7 @@ EOF chroot_wipe() { cat < /dev/null umount $CHROOT_DIR/sys &> /dev/null umount $CHROOT_DIR/proc &> /dev/null umount $CHROOT_DIR/dev &> /dev/null