From patchwork Mon Nov 2 08:35:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Mosnacek X-Patchwork-Id: 11873181 X-Patchwork-Delegate: omosnacek@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D44781130 for ; Mon, 2 Nov 2020 08:35:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC2CD20756 for ; Mon, 2 Nov 2020 08:35:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="M4zL3ete" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727960AbgKBIfZ (ORCPT ); Mon, 2 Nov 2020 03:35:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21935 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727806AbgKBIfZ (ORCPT ); Mon, 2 Nov 2020 03:35:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604306123; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vYrQJbkdrg54Gc+N/qM71BZB5xoYJ/RWA9WY/UFLS/g=; b=M4zL3eteNlyPD5a8NxRkNEdrz98NkIJ5O/JfEmykgZqzk+zJC0hDSXkVj/36hvqukB3Ces zD8CWqzijQlHxCkSoOXnOwBCp1u9MUmi1O90oQOSw69UTEIgjv5pJNiuHS/SMfjkhDwdM2 OO6e+/dwB+VyGH4C4lvOc4zhLLHqLts= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-491-_CEdTo-jO8yStH9rh0It2g-1; Mon, 02 Nov 2020 03:35:22 -0500 X-MC-Unique: _CEdTo-jO8yStH9rh0It2g-1 Received: by mail-ed1-f69.google.com with SMTP id bs10so5823010edb.22 for ; Mon, 02 Nov 2020 00:35:21 -0800 (PST) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=vYrQJbkdrg54Gc+N/qM71BZB5xoYJ/RWA9WY/UFLS/g=; b=fbTMEJyUdZGbGgOwlgVaO5F/6mtEYrQQuQkS3DvJjHI3kv5Qr3PRuxaCBa0CBL0QJ8 BEE2deWPkSunWh65p33lgilMzh8ZqDowRQyUeGYjP9Une+TuWKBKu7XpMa82MimpchYL n9KRFtA12/pMYo+6ajeGs5W+ZxqFYlwF5Z759fNijww5CJONGc1MN6mPyJzCVrG9/6Mp yuROM5b99HK4wB0NKFMRc1PurEppF+JN0jgzoBO1WBlFs9CyaBi+JGFBqkQ79nqOdFYr nX/vnKP6GqklT1Z2zs5OrDENGSwDUDP7mkq9yJ5PqaEMm101WwmLAzTAw9DnsBRrUSWe PtJQ== X-Gm-Message-State: AOAM530maM0RhW4Un9t6lNs7It3OwT1lpgkXOBkSaxpeKUV6PqXiVtdC gGP+tX4Lq3k/tCqTSoYdub2hFEUNCMEVW7nco6P68qpvUSkXMnkhZNkw9BFHoGO6U5FuvtjBvC4 VAg74j/cGfO4hkpQasQ== X-Received: by 2002:a17:906:824a:: with SMTP id f10mr15292753ejx.167.1604306120363; Mon, 02 Nov 2020 00:35:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+LlzxrudqYDK2dHM6dlK5nwXR/NZo4EGsstF3ypyQliqV2dhUevxTwISwjAFo2qUj+VbwcA== X-Received: by 2002:a17:906:824a:: with SMTP id f10mr15292744ejx.167.1604306120218; Mon, 02 Nov 2020 00:35:20 -0800 (PST) Received: from omos.redhat.com ([2a02:8308:b103:4000:9293:f330:b535:b530]) by smtp.gmail.com with ESMTPSA id bk13sm9293716ejb.58.2020.11.02.00.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 00:35:19 -0800 (PST) From: Ondrej Mosnacek To: selinux@vger.kernel.org Cc: Richard Haines , Paul Moore Subject: [PATCH testsuite v2 1/4] README,travis: add e2fsprogs, jfsutils, and dosfstools to deps Date: Mon, 2 Nov 2020 09:35:13 +0100 Message-Id: <20201102083516.477149-2-omosnace@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201102083516.477149-1-omosnace@redhat.com> References: <20201102083516.477149-1-omosnace@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org They are needed for ext4, jfs, and vfat tests, which will become executed by default in an upcoming patch. Signed-off-by: Ondrej Mosnacek --- README.md | 6 ++++++ travis-ci/run-testsuite.sh | 3 +++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 838a082..1149f30 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,9 @@ similar dependencies): * keyutils-libs-devel _(tools used by the keys tests)_ * kernel-devel _(used by the kernel module tests)_ * quota, xfsprogs-devel and libuuid-devel _(used by the filesystem tests)_ +* e2fsprogs _(used by the ext4 filesystem tests)_ +* jfsutils _(used by the jfs filesystem tests)_ +* dosfstools _(used by the vfat filesystem tests)_ * nftables _(used by inet_socket and sctp tests if ver >= 9.3 for secmark testing )_ On a modern Fedora system you can install these dependencies with the @@ -81,6 +84,9 @@ following command (NOTE: On Fedora 32 and below you need to remove quota \ xfsprogs-devel \ libuuid-devel \ + e2fsprogs \ + jfsutils \ + dosfstools \ nftables \ kernel-devel-$(uname -r) \ kernel-modules-$(uname -r) diff --git a/travis-ci/run-testsuite.sh b/travis-ci/run-testsuite.sh index 051f9d8..bd9073c 100755 --- a/travis-ci/run-testsuite.sh +++ b/travis-ci/run-testsuite.sh @@ -38,6 +38,9 @@ dnf install -y \ quota \ xfsprogs-devel \ libuuid-devel \ + e2fsprogs \ + jfsutils \ + dosfstools \ kernel-devel-"$(uname -r)" \ kernel-modules-"$(uname -r)" From patchwork Mon Nov 2 08:35:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Mosnacek X-Patchwork-Id: 11873183 X-Patchwork-Delegate: omosnacek@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7519914B4 for ; Mon, 2 Nov 2020 08:35:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5292C20756 for ; Mon, 2 Nov 2020 08:35:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QxVu0Szd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727806AbgKBIf0 (ORCPT ); Mon, 2 Nov 2020 03:35:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60508 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727902AbgKBIfZ (ORCPT ); Mon, 2 Nov 2020 03:35:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604306124; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EEdhfquk6SyWWkHPzszNFtJfFb9gTGHgZXx6x23uqg0=; b=QxVu0SzdoH/RsFfxlaa+FuWs6XIsXK4B+POA9mUSvNVx2FBd5rdHjKhL1XFLDkxtnVkksW FdF5bxcYCKYenvfY2oSAN+3vLMHxN1tJw2xiEfci+3BDIBHIi2e6V2qCSNM77omKA9K7HU HhkmX9i6prcgliKXxBGerS0ObCaAdso= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-23-6KwYg4svPgKdH5LoBdFbsg-1; Mon, 02 Nov 2020 03:35:23 -0500 X-MC-Unique: 6KwYg4svPgKdH5LoBdFbsg-1 Received: by mail-ej1-f71.google.com with SMTP id z25so4037113ejd.2 for ; Mon, 02 Nov 2020 00:35:22 -0800 (PST) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=EEdhfquk6SyWWkHPzszNFtJfFb9gTGHgZXx6x23uqg0=; b=EkI9vvKGK1ufz5sNfHSjKywfYpo6TbBcT++tQh4Nu65sbbSqRJg82CvCbJpGLYkSsz 1X8eX24uXcFV5OOlWRXiPD2ThfEdavSmpF3E3aPiPABPWVHG1qSTf1lCyqkpxutBdWuI ZjInajSu83HV8PEc9ceWLzroEr6BMIJxmt8Yn2I1GBh5/smmY5N14GhCtUsAiQK8LTNb DlY47kqs7daXMF70CBQYNbCZOGFTqXA8OwOWioOOKCh5vpETMbfkQ4OyfwYx2k2FwSMl G2tmlah9HiHiBkU4hQcYteVKOELS1NgsK9fRYIlNbYUoudSznmYzQWZ5uRMVYxFyDFy+ JA3Q== X-Gm-Message-State: AOAM531QYlxhekM70Y8yXVT5t4MeZcAtMqvpP3579AlB1bLS/CXKsKIz mcFtyKrAO4AObArzBewv9UYp2/qMQxGwGrqRE0akVXUp5Bb2Rbv/Mm7au7X2EAXH2LPoalji0s0 1lI1yBAxOfiyDhcd7RQ== X-Received: by 2002:a17:906:f752:: with SMTP id jp18mr12401762ejb.331.1604306121593; Mon, 02 Nov 2020 00:35:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPDxWlepDS3vSJD8asPC+8T0F8QgFMTqKzwm2kbgaKOxzX0ZesCC6BqQYOQt50XfDfVhFqDw== X-Received: by 2002:a17:906:f752:: with SMTP id jp18mr12401752ejb.331.1604306121409; Mon, 02 Nov 2020 00:35:21 -0800 (PST) Received: from omos.redhat.com ([2a02:8308:b103:4000:9293:f330:b535:b530]) by smtp.gmail.com with ESMTPSA id bk13sm9293716ejb.58.2020.11.02.00.35.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 00:35:20 -0800 (PST) From: Ondrej Mosnacek To: selinux@vger.kernel.org Cc: Richard Haines , Paul Moore Subject: [PATCH testsuite v2 2/4] tests/filesystem: pipe "yes" to mkfs.* to fix jfs test Date: Mon, 2 Nov 2020 09:35:14 +0100 Message-Id: <20201102083516.477149-3-omosnace@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201102083516.477149-1-omosnace@redhat.com> References: <20201102083516.477149-1-omosnace@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org mkfs.jfs is reluctant to overwrite the device without the user's consent, so shout a stream of y's on it to avoid the test getting stuck. We can't universally pass -q to mkfs.*, because not all mkfs.* tools support it. Signed-off-by: Ondrej Mosnacek --- tests/filesystem/Filesystem.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/filesystem/Filesystem.pm b/tests/filesystem/Filesystem.pm index 2365ce8..c14e760 100644 --- a/tests/filesystem/Filesystem.pm +++ b/tests/filesystem/Filesystem.pm @@ -133,7 +133,7 @@ sub make_fs { attach_dev( $mk_dev, $mk_dir ); print "Make $mk_type filesystem on $mk_dev\n"; - $result = system("mkfs.$mk_type $mk_dev >& /dev/null"); + $result = system("yes | mkfs.$mk_type $mk_dev >& /dev/null"); if ( $result != 0 ) { system("losetup -d $mk_dev 2>/dev/null"); print "mkfs.$mk_type failed to create filesystem on $mk_dev\n"; From patchwork Mon Nov 2 08:35:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Mosnacek X-Patchwork-Id: 11873185 X-Patchwork-Delegate: omosnacek@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 84ADB1130 for ; Mon, 2 Nov 2020 08:35:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6319620756 for ; Mon, 2 Nov 2020 08:35:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="a7pNDcnc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728005AbgKBIf2 (ORCPT ); Mon, 2 Nov 2020 03:35:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:21170 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727902AbgKBIf1 (ORCPT ); Mon, 2 Nov 2020 03:35:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604306126; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+jP7noH1PbgFSru/7lAAsyzSfcqdeniDkdv6M0r9Zj0=; b=a7pNDcncm8WaakYJka8QJO5qz405VZlKI/bWPV+RmhntvPh0F76FI6j6W7viFox0ARBSVD ikVTCFX0U7ZnPM9cu1tUVCHU4AIFMJOqYoK2gidgdZymwpIKNmSL84qtZTQVesI6N/sqFM j2EuQs1XpdelBZ7XZNb5tiVOLjreK6E= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-4-5g-HdquOOsS7shpxA8yKbg-1; Mon, 02 Nov 2020 03:35:24 -0500 X-MC-Unique: 5g-HdquOOsS7shpxA8yKbg-1 Received: by mail-ej1-f71.google.com with SMTP id b17so4008221ejb.20 for ; Mon, 02 Nov 2020 00:35:24 -0800 (PST) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=+jP7noH1PbgFSru/7lAAsyzSfcqdeniDkdv6M0r9Zj0=; b=R9j4UTyef2OyIvnksVdtpHLxv67Hy0dXpXgpZd+jU3wqRJ3KRSzaMOIHO/q/2p/S4y T63H6aKs8d5k9A7zmq/LkIhGFqCv5fLQjAHo64AAUkfgdr4o7aQG044kGhdsYUz54Tee yHwzzbfzauaYiPTBOdqVtTr4N8ymkwkSnFJaOYA+6RZfUS4U/UnBeZh4TF46RhGeJmLv pBPYTSdsgEM5xdA5Uf4KlkeIY8DV+XNRyDRGMRjhvLfpm+A9nr3kdVjDDpRVJ7U3gfE/ TSbgwYAmHrvCvGYNt96+n8/ZXNr9bkiYRA80NCNH5KC6KG/p53vvSaSUNFLyOYxzup9L kOPw== X-Gm-Message-State: AOAM53374tLhlB2DzSwcF1A9iZEvIn3Hrz/iYyBQg9094oa8ie2/ydE0 pvkQ97yHGHsAOA7c/m8WWMPzliWrM2kuONUGhRsRs9gtPkHMW5qDw7dcD3GIXmXVcQvi6GwAcl/ fsf/gipUsu2xJUobE5g== X-Received: by 2002:a17:906:4753:: with SMTP id j19mr13089107ejs.65.1604306122689; Mon, 02 Nov 2020 00:35:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnFGePp/VQNizs5E3l2VLwHYup/DFGjAV80Lzb/1DSO2+C4yOWt29WoMe1wpiKRCIaOhdlAw== X-Received: by 2002:a17:906:4753:: with SMTP id j19mr13089098ejs.65.1604306122527; Mon, 02 Nov 2020 00:35:22 -0800 (PST) Received: from omos.redhat.com ([2a02:8308:b103:4000:9293:f330:b535:b530]) by smtp.gmail.com with ESMTPSA id bk13sm9293716ejb.58.2020.11.02.00.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 00:35:21 -0800 (PST) From: Ondrej Mosnacek To: selinux@vger.kernel.org Cc: Richard Haines , Paul Moore Subject: [PATCH testsuite v2 3/4] tests/[fs_]filesystem: fix unwanted error output when testing vfat Date: Mon, 2 Nov 2020 09:35:15 +0100 Message-Id: <20201102083516.477149-4-omosnace@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201102083516.477149-1-omosnace@redhat.com> References: <20201102083516.477149-1-omosnace@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org The tests currently output "fsetfilecon(3) Failed: Operation not supported" during a clean run. Since testing that fsetfilecon(3) returns -EOPNOTSUPP on vfat is not all that useful, rather than conditionally silencing the error output, just skip the fsetfilecon(3) tests for vfat. Signed-off-by: Ondrej Mosnacek --- tests/filesystem/test | 30 +++++++++++++++--------------- tests/fs_filesystem/test | 30 +++++++++++++++--------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/tests/filesystem/test b/tests/filesystem/test index 7d4654d..5a9f0f6 100755 --- a/tests/filesystem/test +++ b/tests/filesystem/test @@ -104,6 +104,9 @@ BEGIN { } elsif ($vfat_enabled) { + # For setfilecon tests as not supported + $test_count -= 2; + # For hooks.c may_create() FILESYSTEM__ASSOCIATE as not supported $test_count -= 3; @@ -243,15 +246,12 @@ if ($test_type_trans) { ok( $result eq 0 ); } -print "Creating 'test_file' and changing its context via setfilecon(3)\n"; -$result = - system( +if ( not $vfat_enabled ) { + print "Creating 'test_file' and changing its context via setfilecon(3)\n"; + $result = + system( "runcon -t test_filesystem_t $basedir/create_file_change_context -t test_filesystem_filecon_t -f $private_path/mp1/test_file $v" - ); -if ($vfat_enabled) { - ok( $result >> 8 eq 95 ); # EOPNOTSUPP -} -else { + ); ok( $result eq 0 ); } @@ -981,16 +981,16 @@ if ( not $nfs_enabled ) { ok( $result eq 0 ); # Create file with 'test_filesystem_filecon_t' context - print "Creating test file $basedir/mntpoint/mp1/test_file\n"; - $result = - system( + if ( not $vfat_enabled ) { + print "Creating test file $basedir/mntpoint/mp1/test_file\n"; + $result = + system( "runcon -t test_filesystem_context_t $basedir/create_file_change_context -t test_filesystem_filecon_t -f $private_path/mp1/test_file $v" - ); - if ($vfat_enabled) { - ok( $result >> 8 eq 95 ); # EOPNOTSUPP + ); + ok( $result eq 0 ); } else { - ok( $result eq 0 ); + system("touch $private_path/mp1/test_file"); } print "Unmount filesystem from $basedir/mntpoint/mp1\n"; diff --git a/tests/fs_filesystem/test b/tests/fs_filesystem/test index 5dedf83..4462438 100755 --- a/tests/fs_filesystem/test +++ b/tests/fs_filesystem/test @@ -112,6 +112,9 @@ BEGIN { } elsif ($vfat_enabled) { + # For setfilecon tests as not supported + $test_count -= 2; + # For hooks.c may_create() FILESYSTEM__ASSOCIATE as not supported $test_count -= 3; @@ -243,15 +246,12 @@ if ($test_type_trans) { ok( $result eq 0 ); } -print "Creating 'test_file' and changing its context via setfilecon(3)\n"; -$result = - system( +if ( not $vfat_enabled ) { + print "Creating 'test_file' and changing its context via setfilecon(3)\n"; + $result = + system( "runcon -t test_filesystem_t $filesystem_dir/create_file_change_context -t test_filesystem_filecon_t -f $private_path/mp1/test_file $v" - ); -if ($vfat_enabled) { - ok( $result >> 8 eq 95 ); # EOPNOTSUPP -} -else { + ); ok( $result eq 0 ); } @@ -1010,16 +1010,16 @@ if ( not $nfs_enabled ) { ok( $result eq 0 ); # Create file with 'test_filesystem_filecon_t' context - print "Creating test file $basedir/mntpoint/mp1/test_file\n"; - $result = - system( + if ( not $vfat_enabled ) { + print "Creating test file $basedir/mntpoint/mp1/test_file\n"; + $result = + system( "runcon -t test_filesystem_context_t $filesystem_dir/create_file_change_context -t test_filesystem_filecon_t -f $private_path/mp1/test_file $v" - ); - if ($vfat_enabled) { - ok( $result >> 8 eq 95 ); # EOPNOTSUPP + ); + ok( $result eq 0 ); } else { - ok( $result eq 0 ); + system("touch $private_path/mp1/test_file"); } print "Unmount filesystem from $basedir/mntpoint/mp1\n"; From patchwork Mon Nov 2 08:35:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Mosnacek X-Patchwork-Id: 11873187 X-Patchwork-Delegate: omosnacek@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BCC371130 for ; Mon, 2 Nov 2020 08:35:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 947E1206DC for ; Mon, 2 Nov 2020 08:35:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OVpUs0GS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727902AbgKBIf3 (ORCPT ); Mon, 2 Nov 2020 03:35:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46650 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727972AbgKBIf3 (ORCPT ); Mon, 2 Nov 2020 03:35:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604306127; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YylDKXGj+yoMBkJBYwGvlONXX4fbuQwuC7OTKd//2GU=; b=OVpUs0GSEn1V65BfDw6jnfTv5Scsgt49SM1i7sfazCWUndvbjgGcSp97IJn63afAK8ReWx hCpOEdA8n2mYMw5XvtikR0oye2gr/u+2jHa7nu/nbASnQv6252o3XJ5kWnLbGbhG3/bOVO dUOZf9i4EBAuWHAvYEdyPXqma710p3A= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-109-BFWlMUGZOwuBszfbMJKn3A-1; Mon, 02 Nov 2020 03:35:25 -0500 X-MC-Unique: BFWlMUGZOwuBszfbMJKn3A-1 Received: by mail-ej1-f71.google.com with SMTP id 27so316942ejy.8 for ; Mon, 02 Nov 2020 00:35:25 -0800 (PST) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=YylDKXGj+yoMBkJBYwGvlONXX4fbuQwuC7OTKd//2GU=; b=ZFmi90HKAukNZIKEBKhKFujkDnKz2KtSTLpZerTvTnx7F6b4m4DJJXpu7rRZ50yWqY fHSvBYIvrIREZE1xabR5w2IjsyTfw5/a54BCGGQYyUnsuSgNamobDYjBJnBwdrl+7gl0 4rHYqxKKW2EX0D0JcJk2ghPL/v1A2htNmQw/SauskUMjQCvlIzk8LOiQTCu/ljFCq34l l525TSRS/IYI4y3tzpVPso8H5isN+6mpB4bMid2loZLIX6qH4jeM8sJUxi+nk4+8ciDW nXqoSJrY1AErIG3amZTGnneb0fbK4S03LDcnmE/K+pg3RC03zx30g7kcZHdNDvld1uGD 9ZIg== X-Gm-Message-State: AOAM5331f2sbHTb2Z8urvj0JWK6dMXxDVZzgS9K+aRG5H7VP6mOhLlrb 8h4PiNQGdfYH2lv0xcbzI8u3oeKSWLSNI+1a+DYaEVA4YSFB3ZCqqti+QqPdtDFFUhpENaMaY32 Rv5LtEVIUySWvfh5Qxg== X-Received: by 2002:a17:906:16d6:: with SMTP id t22mr2157022ejd.376.1604306124019; Mon, 02 Nov 2020 00:35:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzRoFWQyPq9zqnlpcphNJVDbsPIkK7WkswVgGtWzgeK3M9ps9imetoCMxbMxtJyAe+2xMTdJA== X-Received: by 2002:a17:906:16d6:: with SMTP id t22mr2157012ejd.376.1604306123698; Mon, 02 Nov 2020 00:35:23 -0800 (PST) Received: from omos.redhat.com ([2a02:8308:b103:4000:9293:f330:b535:b530]) by smtp.gmail.com with ESMTPSA id bk13sm9293716ejb.58.2020.11.02.00.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 00:35:22 -0800 (PST) From: Ondrej Mosnacek To: selinux@vger.kernel.org Cc: Richard Haines , Paul Moore Subject: [PATCH testsuite v2 4/4] tests/[fs_]filesystem: test all filesystems Date: Mon, 2 Nov 2020 09:35:16 +0100 Message-Id: <20201102083516.477149-5-omosnace@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201102083516.477149-1-omosnace@redhat.com> References: <20201102083516.477149-1-omosnace@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Run [fs_]filesystem tests always for all common filesystems (xfs, ext4, jfs, vfat). Use symlinks to achieve this without changing much code while still allowing to run the test script directly (optionally specifying the filesystem type). Signed-off-by: Ondrej Mosnacek --- tests/Makefile | 8 ++++++-- tests/filesystem/ext4 | 1 + tests/filesystem/jfs | 1 + tests/filesystem/test | 28 +++++++++++++--------------- tests/filesystem/vfat | 1 + tests/filesystem/xfs | 1 + tests/fs_filesystem/ext4 | 1 + tests/fs_filesystem/jfs | 1 + tests/fs_filesystem/test | 34 ++++++++++++++++------------------ tests/fs_filesystem/vfat | 1 + tests/fs_filesystem/xfs | 1 + 11 files changed, 43 insertions(+), 35 deletions(-) create mode 120000 tests/filesystem/ext4 create mode 120000 tests/filesystem/jfs create mode 120000 tests/filesystem/vfat create mode 120000 tests/filesystem/xfs create mode 120000 tests/fs_filesystem/ext4 create mode 120000 tests/fs_filesystem/jfs create mode 120000 tests/fs_filesystem/vfat create mode 120000 tests/fs_filesystem/xfs diff --git a/tests/Makefile b/tests/Makefile index 001639b..b441031 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -4,6 +4,7 @@ SBINDIR ?= $(PREFIX)/sbin POLDEV ?= $(PREFIX)/share/selinux/devel INCLUDEDIR ?= $(PREFIX)/include SELINUXFS ?= /sys/fs/selinux +FILESYSTEMS ?= ext4 xfs jfs vfat export CFLAGS+=-g -O0 -Wall -D_GNU_SOURCE @@ -17,6 +18,9 @@ MOD_POL_VERS := $(shell $(CHECKMODULE) -V |cut -f 2 -d '-') MAX_KERNEL_POLICY := $(shell cat $(SELINUXFS)/policyvers) POL_TYPE := $(shell ./pol_detect $(SELINUXFS)) +# Filter out unavailable filesystems +FILESYSTEMS := $(foreach fs,$(FILESYSTEMS),$(shell modprobe $(fs) && echo $(fs))) + SUBDIRS:= domain_trans entrypoint execshare exectrace execute_no_trans \ fdreceive inherit link mkdir msg open ptrace readlink relabel rename \ rxdir sem setattr setnice shm sigkill stat sysctl task_create \ @@ -111,7 +115,7 @@ SUBDIRS += lockdown endif ifeq ($(shell grep -q filesystem $(POLDEV)/include/support/all_perms.spt && echo true),true) -SUBDIRS += filesystem +SUBDIRS += $(addprefix filesystem/,$(FILESYSTEMS)) ifeq ($(shell grep -q all_filesystem_perms.*watch $(POLDEV)/include/support/all_perms.spt && echo true),true) export CFLAGS += -DHAVE_FS_WATCH_PERM endif @@ -119,7 +123,7 @@ endif ifeq ($(shell grep -q filesystem $(POLDEV)/include/support/all_perms.spt && echo true),true) ifneq ($(shell ./kvercmp $$(uname -r) 5.2),-1) -SUBDIRS += fs_filesystem +SUBDIRS += $(addprefix fs_filesystem/,$(FILESYSTEMS)) endif endif diff --git a/tests/filesystem/ext4 b/tests/filesystem/ext4 new file mode 120000 index 0000000..945c9b4 --- /dev/null +++ b/tests/filesystem/ext4 @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/tests/filesystem/jfs b/tests/filesystem/jfs new file mode 120000 index 0000000..945c9b4 --- /dev/null +++ b/tests/filesystem/jfs @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/tests/filesystem/test b/tests/filesystem/test index 5a9f0f6..c94deda 100755 --- a/tests/filesystem/test +++ b/tests/filesystem/test @@ -2,15 +2,22 @@ use Test::More; # Load common subroutines. -use File::Basename qw(dirname); +use File::Basename qw(dirname basename); use Cwd qw(abs_path); -use lib dirname( abs_path $0); + +BEGIN { + $basedir = dirname($0); + $basedir = `cd $basedir && pwd`; + chomp($basedir); +} +use lib $basedir; use Filesystem qw(check_config udisks2_stop udisks2_restart get_loop_dev attach_dev make_fs mk_mntpoint_1 mk_mntpoint_2 cleanup cleanup1 reaper nfs_gen_opts); BEGIN { - $basedir = $0; - $basedir =~ s|(.*)/[^/]*|$1|; + # extract fs_type + $test_name = basename($basedir); + $fs_type = $test_name ne "filesystem" ? $test_name : " "; # Options: -v Verbose, -e enable udisks(8) daemon, -f filesystem type $v = " "; @@ -20,8 +27,7 @@ BEGIN { $nfs_enabled = 0; $vfat_enabled = 0; - $i = 0; - $fs_type = " "; + $i = 0; foreach $arg (@ARGV) { if ( $arg eq "-v" ) { $v = $arg; @@ -131,15 +137,7 @@ print "Testing filesystem fs_type: $fs_type\n"; # mount(2) MS_BIND | MS_PRIVATE requires an absolute path to a private mount # point before MS_MOVE -$cwd = `pwd 2>/dev/null`; -chomp($cwd); -$private_path = "$cwd"; -if ( $basedir eq "." ) { - $private_path = "$cwd/mntpoint"; -} -else { - $private_path = "$cwd/$basedir/mntpoint"; -} +$private_path = abs_path($basedir) . "/mntpoint"; # Keep a list of devices used for removal at end of test. $device_count = 0; diff --git a/tests/filesystem/vfat b/tests/filesystem/vfat new file mode 120000 index 0000000..945c9b4 --- /dev/null +++ b/tests/filesystem/vfat @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/tests/filesystem/xfs b/tests/filesystem/xfs new file mode 120000 index 0000000..945c9b4 --- /dev/null +++ b/tests/filesystem/xfs @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/tests/fs_filesystem/ext4 b/tests/fs_filesystem/ext4 new file mode 120000 index 0000000..945c9b4 --- /dev/null +++ b/tests/fs_filesystem/ext4 @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/tests/fs_filesystem/jfs b/tests/fs_filesystem/jfs new file mode 120000 index 0000000..945c9b4 --- /dev/null +++ b/tests/fs_filesystem/jfs @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/tests/fs_filesystem/test b/tests/fs_filesystem/test index 4462438..e706e42 100755 --- a/tests/fs_filesystem/test +++ b/tests/fs_filesystem/test @@ -2,18 +2,25 @@ use Test::More; # Load common subroutines. -use File::Basename qw(dirname); +use File::Basename qw(dirname basename); use Cwd qw(abs_path); -use lib dirname( abs_path $0) . '/../filesystem'; -use Filesystem - qw(check_config udisks2_stop udisks2_restart get_loop_dev attach_dev make_fs mk_mntpoint_1 mk_mntpoint_2 cleanup cleanup1 reaper nfs_gen_opts); BEGIN { - $basedir = $0; - $basedir =~ s|(.*)/[^/]*|$1|; + $basedir = dirname($0); + $basedir = `cd $basedir && pwd`; + chomp($basedir); # Some code in tests/filesystem is reused - $filesystem_dir = "$basedir/../filesystem"; + $filesystem_dir = abs_path($basedir) . "/../filesystem"; +} +use lib $filesystem_dir; +use Filesystem + qw(check_config udisks2_stop udisks2_restart get_loop_dev attach_dev make_fs mk_mntpoint_1 mk_mntpoint_2 cleanup cleanup1 reaper nfs_gen_opts); + +BEGIN { + # extract fs_type + $test_name = basename($basedir); + $fs_type = $test_name ne "fs_filesystem" ? $test_name : " "; # Options: -v = Verbose, -e enable udisks(8) daemon, -f filesystem type $v = " "; @@ -23,8 +30,7 @@ BEGIN { $nfs_enabled = 0; $vfat_enabled = 0; - $i = 0; - $fs_type = " "; + $i = 0; foreach $arg (@ARGV) { if ( $arg eq "-v" ) { $v = $arg; @@ -133,15 +139,7 @@ BEGIN { print "Testing filesystem fs_type: $fs_type\n"; # Generate an absolute path to a private mount -$cwd = `pwd 2>/dev/null`; -chomp($cwd); -$private_path = "$cwd"; -if ( $basedir eq "." ) { - $private_path = "$cwd/mntpoint"; -} -else { - $private_path = "$cwd/$basedir/mntpoint"; -} +$private_path = abs_path($basedir) . "/mntpoint"; # Keep a list of devices used for removal at end of test. $device_count = 0; diff --git a/tests/fs_filesystem/vfat b/tests/fs_filesystem/vfat new file mode 120000 index 0000000..945c9b4 --- /dev/null +++ b/tests/fs_filesystem/vfat @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/tests/fs_filesystem/xfs b/tests/fs_filesystem/xfs new file mode 120000 index 0000000..945c9b4 --- /dev/null +++ b/tests/fs_filesystem/xfs @@ -0,0 +1 @@ +. \ No newline at end of file