From nobody Sun Feb 8 17:27:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 172605552444170.63027412560109; Wed, 11 Sep 2024 04:52:04 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 516D6541; Wed, 11 Sep 2024 07:52:03 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 77F2E16F0; Wed, 11 Sep 2024 07:51:45 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 81104157F; Wed, 11 Sep 2024 07:51:43 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id B972A1573 for ; Wed, 11 Sep 2024 07:51:42 -0400 (EDT) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-513-XBhifp6lMJab_qGg3MV0lA-1; Wed, 11 Sep 2024 07:51:41 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-42cb857fc7dso25193655e9.0 for ; Wed, 11 Sep 2024 04:51:41 -0700 (PDT) Received: from jpalacky-thinkpadt14sgen2i.tpb.csb (nat-pool-brq-u.redhat.com. [213.175.37.12]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42caeb32639sm140171595e9.13.2024.09.11.04.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 04:51:38 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726055502; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FpqfLSgbmsVW5kIFD30QpCz5ssnQMZ63kFlWNKMnOHQ=; b=PjvK0N8SwRK7z8tfeGLQMBEY9+q8qyDxmy1+WcxO/crBVoT9EuwzlOqvS7P0EEwpNjZHcd UX1AUncXbkoqgR+UUz3uUhUbruem6vYhTSsxkRey3O/3ux6AJbdBOdwbGXN92i7mvih8Lz qvf7HllJjLLNFpnFCAB1gt5pWi7WhAY= X-MC-Unique: XBhifp6lMJab_qGg3MV0lA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726055499; x=1726660299; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FpqfLSgbmsVW5kIFD30QpCz5ssnQMZ63kFlWNKMnOHQ=; b=fS3FY/8V50KpJXfJlkpCpk/bbRbVTHgNnQAwdsgbR4t1a9zVbQ9PtN7CupFcBz5Vru db6Zr9ezdysAcgb+pkFmRUtR9mE9bNrzjItWE+X3cgSNtI+t0zUP2yFlbJVkqwThnJQK CqEjp7SHmTvZuVj+tPlGVpqH/1fYgefQVg6GYEo5o2jBefweoqL9TxbxogO7B0SiJeJq vpiNY9qoWSMX+FDQ4zhrmFDhzGQIYDZ/QVQkWqDivc1uhOtCU0ETD7MFrG5Lnog6Asjt JyiBbCV+KRqLYfcmFA0jxdFhPpWmIUSALhbZ7n/3KkRw237RKT98lrRrAef1eboS/mBd w5nQ== X-Gm-Message-State: AOJu0YwLtDjIfgC6kvpV9YoKTuysPCxt7q+8WQZpICd4RmFVpqRXzguk 3nrgfvIYzJixbvmAzpKjzp9eYiCkWddLvdCKJKW3wBf3jho4TyPsxYuejrKzXBqvT1qvtqzY7qq 6YizE9Mts2XOyqk71qOZuLXx/X8ZKQY2k4QYxLYSNsVNP3KGEP1t7PT3TyPAE2WTQR5KP6hVa7r kkwvVuRPw6XEgYxPfMSmQxzSwb3ktXoLjUe+BCJ+o= X-Received: by 2002:a05:600c:34d1:b0:42c:b995:20b6 with SMTP id 5b1f17b1804b1-42cb99524b1mr69668855e9.2.1726055499470; Wed, 11 Sep 2024 04:51:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGA+GGTSxOMlVlTU+OG6HqCLWNk+BrO04YKI1QIStnY0lgkVi7/LkCDkHLXKJJ9p7kH2rYPmA== X-Received: by 2002:a05:600c:34d1:b0:42c:b995:20b6 with SMTP id 5b1f17b1804b1-42cb99524b1mr69668365e9.2.1726055498315; Wed, 11 Sep 2024 04:51:38 -0700 (PDT) From: Jakub Palacky To: devel@lists.libvirt.org Subject: [PATCH] util/virutil: Use readpassphrase when libbsd is available Date: Wed, 11 Sep 2024 13:51:29 +0200 Message-ID: <20240911115129.361486-1-jpalacky@redhat.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: UL42MHR7EZNCS7TARHEDJFPV6GMQWNT4 X-Message-ID-Hash: UL42MHR7EZNCS7TARHEDJFPV6GMQWNT4 X-MailFrom: jpalacky@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Jakub Palacky X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1726055526782116600 Content-Type: text/plain; charset="utf-8"; x-default="true" When libbsd is available, use the preferred readpassphrase() function isnte= ad of getpass() as the getpass() function has been marked as obsolete and shouldnt be used Signed-off-by: Jakub Palacky --- meson.build | 6 ++++++ src/meson.build | 1 + src/util/virutil.c | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/meson.build b/meson.build index 297fbfae48..699a65c7e8 100644 --- a/meson.build +++ b/meson.build @@ -954,6 +954,11 @@ if blkid_dep.found() conf.set('WITH_BLKID', 1) endif =20 +bsd_dep =3D dependency('libbsd', required: false) +if bsd_dep.found() + conf.set('WITH_LIBBSD', 1) +endif + capng_dep =3D dependency('libcap-ng', required: get_option('capng')) if capng_dep.found() conf.set('WITH_CAPNG', 1) @@ -2335,6 +2340,7 @@ libs_summary =3D { 'dlopen': dlopen_dep.found(), 'fuse': fuse_dep.found(), 'glusterfs': glusterfs_dep.found(), + 'libbsd': bsd_dep.found(), 'libiscsi': libiscsi_dep.found(), 'libkvm': libkvm_dep.found(), 'libnbd': libnbd_dep.found(), diff --git a/src/meson.build b/src/meson.build index 8cce42c7ad..30ae34646e 100644 --- a/src/meson.build +++ b/src/meson.build @@ -9,6 +9,7 @@ src_dep =3D declare_dependency( dependencies: [ glib_dep, libxml_dep, + bsd_dep, ], include_directories: [ libvirt_inc, diff --git a/src/util/virutil.c b/src/util/virutil.c index 6c89a48e51..2e07372198 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -31,6 +31,10 @@ # include #endif /* WIN32 */ =20 +#ifdef WITH_LIBBSD +# include +#endif + #ifdef __linux__ # include #endif @@ -1773,6 +1777,8 @@ char *virGetPassword(void) } =20 return g_string_free(pw, FALSE); +#elif WITH_LIBBSD /* !WIN32 */ + return readpassphrase("", g_new0(char, 1024), 1024, 0); #else /* !WIN32 */ return g_strdup(getpass("")); #endif /* ! WIN32 */ --=20 2.46.0