From patchwork Thu Apr 28 06:53:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 12830054 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 87CEFC43217 for ; Thu, 28 Apr 2022 06:54:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244609AbiD1G5X (ORCPT ); Thu, 28 Apr 2022 02:57:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239616AbiD1G5W (ORCPT ); Thu, 28 Apr 2022 02:57:22 -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 EA83F986D3 for ; Wed, 27 Apr 2022 23:54:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651128847; 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=j5P3QQCBVFmvpvzvvmEtb7v9iZ+7+hORPzXOO8l8ZjM=; b=gDFOXSaxA7MyIe311GCPJfHS1/OC+Nuo9TRLWZ9qr4dvmwwA0qWgf6U3GCMqVhejHdULex 1mBDSg+CzOZe42RWvTxyoGWc0twZUDmda5hpzkUWjmkIoyN4qp6VfhmAhdBwJDfJMuES8N ZOFRiWnHbmzImVOwjHAAVhVvRAbrEhA= 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-416-385sfyk_Pe6KeBsSdjaVGw-1; Thu, 28 Apr 2022 02:54:06 -0400 X-MC-Unique: 385sfyk_Pe6KeBsSdjaVGw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C482E811E90 for ; Thu, 28 Apr 2022 06:54:05 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (unknown [10.39.192.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE1E1416384; Thu, 28 Apr 2022 06:54:04 +0000 (UTC) From: Laszlo Ersek To: SELinux List , Laszlo Ersek Cc: "Richard W.M. Jones" , Petr Lautrbach Subject: [PATCH for-3.5 3/5] setfiles: remove useless "iamrestorecon" checks in option parsing Date: Thu, 28 Apr 2022 08:53:52 +0200 Message-Id: <20220428065354.27605-4-lersek@redhat.com> In-Reply-To: <20220428065354.27605-1-lersek@redhat.com> References: <20220428065354.27605-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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 --- 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);