From patchwork Tue May 3 08:23:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 12835266 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1305FC433EF for ; Tue, 3 May 2022 08:23:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232739AbiECI1G (ORCPT ); Tue, 3 May 2022 04:27:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231240AbiECI1F (ORCPT ); Tue, 3 May 2022 04:27:05 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1F64529800 for ; Tue, 3 May 2022 01:23:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651566213; 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=JkB2byG/+RiO8UzmhxFyDyj62m+Q0hOEl8imykBOP0Q=; b=XNhWZfUHskU0IiezHvNIeByuWTofrt3AtoOsC/ap78pzdXGTFJZINbjbPpEclo0ueC5guY yLsj16b5hRYrWKb8GtUpM+cZbt6jVDQwSFAcHLzuHvZnRsxkKbMLMnyO8lzAQ6SXEM8oFB rtQ8n9MoqBPIvQPlvykczycrbq6mNxY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-640-JaEnwrD9OfS4ZpXvumhxcw-1; Tue, 03 May 2022 04:23:32 -0400 X-MC-Unique: JaEnwrD9OfS4ZpXvumhxcw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E66D0833965 for ; Tue, 3 May 2022 08:23:31 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (unknown [10.39.192.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id F058A40CFD29; Tue, 3 May 2022 08:23:30 +0000 (UTC) From: Laszlo Ersek To: SELinux List , Laszlo Ersek Cc: "Richard W.M. Jones" , Petr Lautrbach Subject: [PATCH v2 3/5] setfiles: remove useless "iamrestorecon" checks in option parsing Date: Tue, 3 May 2022 10:23:24 +0200 Message-Id: <20220503082326.11621-4-lersek@redhat.com> In-Reply-To: <20220503082326.11621-1-lersek@redhat.com> References: <20220503082326.11621-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Commit 219eea83cea9 ("policycoreutils: setfiles/restorecon: fix -r/-R option", 2015-04-16) split the option strings between "setfiles" and "restorecon". Since that commit, an "iamrestorecon" check has only been necessary for an option that is (a) accepted by both "setfiles" and "restorecon", but (b) behaves differently between "setfiles" and "restorecon". Currently, the only such options are "-r" and "-R". Remove the "iamrestorecon" checks from the "setfiles"-only "-c" and "-d" options, and from the "restorecon"-only "-x" option. Cc: "Richard W.M. Jones" Cc: Petr Lautrbach Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1794518 Signed-off-by: Laszlo Ersek Reviewed-By: Daniel Burgener --- Notes: v2: - pick up Daniel Burgener's R-b policycoreutils/setfiles/setfiles.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/policycoreutils/setfiles/setfiles.c b/policycoreutils/setfiles/setfiles.c index cf504618d38f..aeec1fdcc2ab 100644 --- a/policycoreutils/setfiles/setfiles.c +++ b/policycoreutils/setfiles/setfiles.c @@ -227,9 +227,6 @@ int main(int argc, char **argv) { FILE *policystream; - if (iamrestorecon) - usage(argv[0]); - policyfile = optarg; policystream = fopen(policyfile, "r"); @@ -267,8 +264,6 @@ int main(int argc, char **argv) input_filename = optarg; break; case 'd': - if (iamrestorecon) - usage(argv[0]); r_opts.debug = 1; r_opts.log_matches = SELINUX_RESTORECON_LOG_MATCHES; @@ -367,11 +362,7 @@ int main(int argc, char **argv) null_terminated = 1; break; case 'x': - if (iamrestorecon) { - r_opts.xdev = SELINUX_RESTORECON_XDEV; - } else { - usage(argv[0]); - } + r_opts.xdev = SELINUX_RESTORECON_XDEV; break; case 'T': nthreads = strtoull(optarg, &endptr, 10);