From patchwork Thu Apr 19 19:54:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 10351495 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 B488A60231 for ; Thu, 19 Apr 2018 19:55:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A75B2284C9 for ; Thu, 19 Apr 2018 19:55:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C40728517; Thu, 19 Apr 2018 19:55:30 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 52DCA284C9 for ; Thu, 19 Apr 2018 19:55:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753491AbeDSTz3 (ORCPT ); Thu, 19 Apr 2018 15:55:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:38421 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753484AbeDSTz2 (ORCPT ); Thu, 19 Apr 2018 15:55:28 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id F2E99AEF8; Thu, 19 Apr 2018 19:55:26 +0000 (UTC) From: Petr Vorel To: ltp@lists.linux.it Cc: Petr Vorel , Mimi Zohar , linux-integrity@vger.kernel.org Subject: [RFC PATCH v3 04/10] ima/ima_policy.sh: Load whole policy with cat Date: Thu, 19 Apr 2018 21:54:57 +0200 Message-Id: <20180419195503.7194-5-pvorel@suse.cz> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180419195503.7194-1-pvorel@suse.cz> References: <20180419195503.7194-1-pvorel@suse.cz> Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Originally writing the policy was done one rule at a time, but that's not required since kernel 2.6.35 (6ccd04563005 "ima: handle multiple rules per write") Signed-off-by: Petr Vorel Suggested-by: Mimi Zohar --- testcases/kernel/security/integrity/ima/tests/ima_policy.sh | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/testcases/kernel/security/integrity/ima/tests/ima_policy.sh b/testcases/kernel/security/integrity/ima/tests/ima_policy.sh index 35eb4055b..1c4a0b922 100755 --- a/testcases/kernel/security/integrity/ima/tests/ima_policy.sh +++ b/testcases/kernel/security/integrity/ima/tests/ima_policy.sh @@ -53,17 +53,9 @@ load_policy() exec 2>/dev/null 4>$IMA_POLICY [ $? -eq 0 ] || exit 1 - cat $1 | - while read line; do - if [ "${line#\#}" = "${line}" ]; then - echo "$line" >&4 2> /dev/null - if [ $? -ne 0 ]; then - exec 4>&- - return 1 - fi - fi - done + cat $1 >&4 2> /dev/null ret=$? + exec 4>&- [ $ret -eq 0 ] && \ tst_res TINFO "IMA policy updated, please reboot after testing to restore settings"