From patchwork Tue Dec 6 08:09:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryu Guan X-Patchwork-Id: 9462141 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 CE0DB60586 for ; Tue, 6 Dec 2016 08:20:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB678281C3 for ; Tue, 6 Dec 2016 08:20:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFEDD2832B; Tue, 6 Dec 2016 08:20:23 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 86C23281C3 for ; Tue, 6 Dec 2016 08:20:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752118AbcLFIUQ (ORCPT ); Tue, 6 Dec 2016 03:20:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49766 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752135AbcLFIUP (ORCPT ); Tue, 6 Dec 2016 03:20:15 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6236A7F7C8 for ; Tue, 6 Dec 2016 08:09:46 +0000 (UTC) Received: from localhost (dhcp-13-108.nay.redhat.com [10.66.13.108]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uB689jsO021320; Tue, 6 Dec 2016 03:09:45 -0500 From: Eryu Guan To: fstests@vger.kernel.org Cc: Eryu Guan Subject: [PATCH] generic/35[67]: update selinux context for mkswap Date: Tue, 6 Dec 2016 16:09:27 +0800 Message-Id: <20161206080927.22379-1-eguan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 06 Dec 2016 08:09:46 +0000 (UTC) Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With selinux enabled & the default selinux context in fstests, mkswap is denied, generic/35[67] fail as: +mkswap: unable to relabel /mnt/testarea/scratch/test-357/file1 to system_u:object_r:swapfile_t:s0: Operation not supported So mount SCRATCH_DEV with swapfile selinux context if selinux is enabled (SELINUX_MOUNT_OPTIONS not empty). Signed-off-by: Eryu Guan --- tests/generic/356 | 4 ++++ tests/generic/357 | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tests/generic/356 b/tests/generic/356 index 6bb90c0..8bebad2 100755 --- a/tests/generic/356 +++ b/tests/generic/356 @@ -49,6 +49,10 @@ _require_cp_reflink echo "Format and mount" _scratch_mkfs > $seqres.full 2>&1 +# the default selinux context won't allow mkswap +if [ "$SELINUX_MOUNT_OPTIONS" != "" ]; then + export SELINUX_MOUNT_OPTIONS="-o context=system_u:object_r:swapfile_t:s0" +fi _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq diff --git a/tests/generic/357 b/tests/generic/357 index 439b314..8941927 100755 --- a/tests/generic/357 +++ b/tests/generic/357 @@ -49,6 +49,10 @@ _require_cp_reflink echo "Format and mount" _scratch_mkfs > $seqres.full 2>&1 +# the default selinux context won't allow mkswap +if [ "$SELINUX_MOUNT_OPTIONS" != "" ]; then + export SELINUX_MOUNT_OPTIONS="-o context=system_u:object_r:swapfile_t:s0" +fi _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq