From nobody Mon Feb 9 11:32:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1673972476; cv=none; d=zohomail.com; s=zohoarc; b=OZdvVhvotsW7VNotgjdG50Y+eiiq37ZaDEl7RykvVPeFL7jF1bqECRkG9/MVyc/mSEtxrnu9uZbTAZjwN6MQTfq0k0D9eQ1u1f6w9xGgBOohz2sfL8B/o3GfPCGiEro1+XxFU4krPHJmzh9Zmb+3Ze6mEKEE+q1ZGZwkNJ4MCk8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673972476; 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=lhCJIV+AowgfKjU3N4oB9EW9gRllL/41gF/ccMqrWu8=; b=P9L9gW6qGkLRhJUGJMiEhHSfCoSMvUzdeKkLFzBMRra/xb7O0qsMNQew0HXE6MKaEfeHdiVFncn2GwmRhEtK4/6ucr2WS2L4ruz9WZLJOb7/b68ewRU/0QNUvaFbnd6ZuDH2/8U+rH3NMbpTY928sK7/jIwOXV9UC0PnbRJ1krg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1673972476108740.3814602211032; Tue, 17 Jan 2023 08:21:16 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-412-cZw0_lynMMWOsQ9e0Hn6Kg-1; Tue, 17 Jan 2023 11:21:12 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B3D1629A9CB5; Tue, 17 Jan 2023 16:20:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FFA27AE5; Tue, 17 Jan 2023 16:20:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 64DE11946A77; Tue, 17 Jan 2023 16:20:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BA3DD19465A4 for ; Tue, 17 Jan 2023 16:20:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B05201121319; Tue, 17 Jan 2023 16:20:49 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-29.brq.redhat.com [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 025551121315 for ; Tue, 17 Jan 2023 16:20:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673972475; 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=lhCJIV+AowgfKjU3N4oB9EW9gRllL/41gF/ccMqrWu8=; b=JrR4ybzd7jR0hcKflaeuhBCfYahpyIm3Jaf6BZ1cHls2Qh8WvkTW9GSZwQGvRELYno1c/c JCzOZS5lYlPQOXGOb2K5WXBm/1f/9f3sCxceLcULvx/xvGv77QG4gouogsvf0FQ4K+mlPR 7ah7JnH7EWE3kNYJJw061tIKQ03HfKQ= X-MC-Unique: cZw0_lynMMWOsQ9e0Hn6Kg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/15] virNetSSHAuthMethod: Remove unused 'password' field Date: Tue, 17 Jan 2023 17:20:32 +0100 Message-Id: <4939efed217e69dd181dc7c89c2523d5ac62d4e2.1673972406.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673972476693100001 Content-Type: text/plain; charset="utf-8" None of the callers actually set it. Remove the field and corresponding logic. Signed-off-by: Peter Krempa --- src/rpc/virnetsshsession.c | 57 +++++++++++++++----------------------- 1 file changed, 22 insertions(+), 35 deletions(-) diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c index 9f2aa17131..0454deec16 100644 --- a/src/rpc/virnetsshsession.c +++ b/src/rpc/virnetsshsession.c @@ -71,7 +71,6 @@ typedef struct _virNetSSHAuthMethod virNetSSHAuthMethod; struct _virNetSSHAuthMethod { virNetSSHAuthMethods method; char *username; - char *password; char *filename; int tries; @@ -117,7 +116,6 @@ virNetSSHSessionAuthMethodsClear(virNetSSHSession *sess) for (i =3D 0; i < sess->nauths; i++) { VIR_FREE(sess->auths[i]->username); - VIR_FREE(sess->auths[i]->password); VIR_FREE(sess->auths[i]->filename); VIR_FREE(sess->auths[i]); } @@ -580,12 +578,11 @@ virNetSSHAuthenticatePrivkey(virNetSSHSession *sess, priv->username, NULL, priv->filename, - priv->password)) =3D=3D= 0) + NULL)) =3D=3D 0) return 0; /* success */ VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR - if (priv->password || - ret =3D=3D LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED || + if (ret =3D=3D LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED || ret =3D=3D LIBSSH2_ERROR_AUTHENTICATION_FAILED) { VIR_WARNINGS_RESET libssh2_session_last_error(sess->session, &errmsg, NULL, 0); @@ -681,44 +678,34 @@ virNetSSHAuthenticatePassword(virNetSSHSession *sess, VIR_DEBUG("sess=3D%p", sess); - if (priv->password) { + /* password authentication with interactive password request */ + if (!sess->cred || !sess->cred->cb) { + virReportError(VIR_ERR_SSH, "%s", + _("Can't perform authentication: " + "Authentication callback not provided")); + goto cleanup; + } + + /* Try the authenticating the set amount of times. The server breaks t= he + * connection if maximum number of bad auth tries is exceeded */ + while (true) { + if (!(password =3D virAuthGetPasswordPath(sess->authPath, sess->cr= ed, + "ssh", priv->username, + sess->hostname))) + goto cleanup; + /* tunnelled password authentication */ if ((rc =3D libssh2_userauth_password(sess->session, priv->username, - priv->password)) =3D=3D 0) { + password)) =3D=3D 0) { ret =3D 0; goto cleanup; } - } else { - /* password authentication with interactive password request */ - if (!sess->cred || !sess->cred->cb) { - virReportError(VIR_ERR_SSH, "%s", - _("Can't perform authentication: " - "Authentication callback not provided")); - goto cleanup; - } - /* Try the authenticating the set amount of times. The server brea= ks the - * connection if maximum number of bad auth tries is exceeded */ - while (true) { - if (!(password =3D virAuthGetPasswordPath(sess->authPath, sess= ->cred, - "ssh", priv->username, - sess->hostname))) - goto cleanup; - - /* tunnelled password authentication */ - if ((rc =3D libssh2_userauth_password(sess->session, - priv->username, - password)) =3D=3D 0) { - ret =3D 0; - goto cleanup; - } - - if (rc !=3D LIBSSH2_ERROR_AUTHENTICATION_FAILED) - break; + if (rc !=3D LIBSSH2_ERROR_AUTHENTICATION_FAILED) + break; - VIR_FREE(password); - } + VIR_FREE(password); } /* error path */ --=20 2.38.1