From nobody Mon Feb 9 12:11:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612186777; cv=none; d=zohomail.com; s=zohoarc; b=kbJwh8lUIt4L1XIwDxMmlPAh76Yt6geidL5skCz0zcm6KVfhXXm4225GPc70CFuYM3rZDebWTEkLXAGaoUJksLjYhdhsODU0xwuBrOxuMXHXMWu6g7fXtRnJckj19sSftbTU0rFuM0+t/Kc/tYFyyV9YlJkV5dcESZ1aI7PNwNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612186777; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=R4rwiMdFXr7UYxZURDFo4AyF5SexOi7Kk9T8OmFFtTY=; b=ZaTfc8i97w9nc+sTuNjYeSStj1r1//c/LJ1HJR3A7xDMZqsKtKpeGdj7LRRg1VyDs6lMCXtfvzBr+ynOOW13+f+AAlAUUw01gLvMl7RtlQ40VrzweCkcsFk2B845R67+MFutzSm6zDbzKusty2huosQ0mdZysDGNkhNQKgfKkNc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1612186777355516.9539850454005; Mon, 1 Feb 2021 05:39:37 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-201-woBu_MhUPD2ITQY354cc8g-1; Mon, 01 Feb 2021 08:39:34 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1B98584A5F0; Mon, 1 Feb 2021 13:39:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E7913E145; Mon, 1 Feb 2021 13:39:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id ACEF81809CA5; Mon, 1 Feb 2021 13:39:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 111DdKok023425 for ; Mon, 1 Feb 2021 08:39:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9CD7860C68; Mon, 1 Feb 2021 13:39:20 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0A8460C66 for ; Mon, 1 Feb 2021 13:39:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612186776; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=R4rwiMdFXr7UYxZURDFo4AyF5SexOi7Kk9T8OmFFtTY=; b=BKeHYJSN6ZE7CxndODzeGjBItfADtdFVG+x+uN3MSmNzkOAWENALz3qxMCwP8p8fF3GLcS cUGB86ilKxDxb81z3BuYx6GIeFGPlpB1IkArDfrmqWgLseJR9XT1VtW2HRbf/oiAFjIJSa IVSjIpPvK2Sf1rNNta4XBxIMNQ3AS5g= X-MC-Unique: woBu_MhUPD2ITQY354cc8g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/14] cmdSecretSetValue: Make it obvious that --file, --base64 and --interactive are exlcusive Date: Mon, 1 Feb 2021 14:38:59 +0100 Message-Id: <8f7541fc90f224f407bfebf29c54b9494ba1f96b.1612186636.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Convert the conditions to else if so that it's obvious that only one of the cases will ever be used. Signed-off-by: Peter Krempa --- tools/virsh-secret.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index 16accc8ad2..5d656151e8 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -225,16 +225,10 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &filename) < 0) return false; - if (!base64 && !filename && !interactive) { - vshError(ctl, _("Input secret value is missing")); - return false; - } - - /* warn users that the --base64 option passed from command line is wro= ng */ - if (base64) + if (base64) { + /* warn users that the --base64 option passed from command line is= wrong */ vshError(ctl, _("Passing secret value as command-line argument is = insecure!")); - - if (filename) { + } else if (filename) { ssize_t read_ret; if ((read_ret =3D virFileReadAll(filename, 1024, &file_buf)) < 0) { vshSaveLibvirtError(); @@ -243,9 +237,7 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd) file_len =3D read_ret; base64 =3D file_buf; - } - - if (interactive) { + } else if (interactive) { vshPrint(ctl, "%s", _("Enter new value for secret:")); fflush(stdout); @@ -255,6 +247,9 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd) } file_len =3D strlen(file_buf); plain =3D true; + } else { + vshError(ctl, _("Input secret value is missing")); + return false; } if (plain) { --=20 2.29.2