From nobody Tue Feb 10 00:25:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1666807166; cv=none; d=zohomail.com; s=zohoarc; b=CxIqXcK5YyYfmTo12OW6YcbbleiNejtVMv4DN6u9VERH6rrKSds1b09LZZW7z6RfhU5DCPIOLoPDuBgvpbeB9Hb3UTB2YBoMpNNVNctJ0FlPxcF9KjPVY8/fMoVHoTJsxxQXsTNxcE0t1d6Bk2IT8E37kbRYoA7NgvYROAvAL1w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666807166; 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=Ejm/cEzdb3Hv0kLNQBLSKUcI2nJyG5881heACUYA0ts=; b=SSqiTCozVgvVt/SD/R8qY49u6urvw8nqxq3q94OgAy+8K9DTATdr65yw/cTZzXcUaKftqjSPLYrDQSutaQmVFCiDl75eEa16IurP0HRxVcriNrNHsl1p2bkPdfgdavgSV62fgL0b4+KSXxUMeifhv9KxXXPdUrPGuBMtmOGIzws= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16668071661241021.4719747001831; Wed, 26 Oct 2022 10:59:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onkcw-00004u-LQ; Wed, 26 Oct 2022 13:55:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1onkcu-0008VN-GS for qemu-devel@nongnu.org; Wed, 26 Oct 2022 13:55:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1onkcs-0005fO-VP for qemu-devel@nongnu.org; Wed, 26 Oct 2022 13:55:40 -0400 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-547-xs4r5TqENDqhzU495Hy1RA-1; Wed, 26 Oct 2022 13:55:35 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A7E69857D15; Wed, 26 Oct 2022 17:55:34 +0000 (UTC) Received: from kostyanf14nb.redhat.com (ovpn-192-17.brq.redhat.com [10.40.192.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A7A6F2166B39; Wed, 26 Oct 2022 17:55:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666806938; h=from:from: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; bh=Ejm/cEzdb3Hv0kLNQBLSKUcI2nJyG5881heACUYA0ts=; b=ByrqbtZ4cuAXatGhR5r7nsqlqGc02Hgfs4KAdLtF4ZLfmFDrJMFoMwRKqUMRNgvMGReIoA MxoZnTRu0uBzX0T2LNE4pRGD/tZXaDC6/D8J+FrEUDd78yUogzX2zAsrCUGkgR46tS2QSS repXJLpF8TFx9KeASLpEXWoznBYtaJU= X-MC-Unique: xs4r5TqENDqhzU495Hy1RA-1 From: Konstantin Kostiuk To: qemu-devel@nongnu.org, Peter Maydell , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PULL 5/8] qga: Add support for user password setting in FreeBSD Date: Wed, 26 Oct 2022 20:55:15 +0300 Message-Id: <20221026175518.2636846-6-kkostiuk@redhat.com> In-Reply-To: <20221026175518.2636846-1-kkostiuk@redhat.com> References: <20221026175518.2636846-1-kkostiuk@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kkostiuk@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.515, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666807167914100001 From: Alexander Ivanov Move qmp_guest_set_user_password() from __linux__ condition to (__linux__ || __FreeBSD__) condition. Add command and arguments for password setting in FreeBSD. Reviewed-by: Konstantin Kostiuk Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Alexander Ivanov Signed-off-by: Konstantin Kostiuk --- qga/commands-posix.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index b0b467ebdb..e0ee0bea00 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -2122,7 +2122,9 @@ int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList= *vcpus, Error **errp) =20 return processed; } +#endif /* __linux__ */ =20 +#if defined(__linux__) || defined(__FreeBSD__) void qmp_guest_set_user_password(const char *username, const char *password, bool crypted, @@ -2156,10 +2158,15 @@ void qmp_guest_set_user_password(const char *userna= me, goto out; } =20 +#ifdef __FreeBSD__ + chpasswddata =3D g_strdup(rawpasswddata); + passwd_path =3D g_find_program_in_path("pw"); +#else chpasswddata =3D g_strdup_printf("%s:%s\n", username, rawpasswddata); - chpasswdlen =3D strlen(chpasswddata); - passwd_path =3D g_find_program_in_path("chpasswd"); +#endif + + chpasswdlen =3D strlen(chpasswddata); =20 if (!passwd_path) { error_setg(errp, "cannot find 'passwd' program in PATH"); @@ -2180,11 +2187,17 @@ void qmp_guest_set_user_password(const char *userna= me, reopen_fd_to_null(1); reopen_fd_to_null(2); =20 +#ifdef __FreeBSD__ + const char *h_arg; + h_arg =3D (crypted) ? "-H" : "-h"; + execl(passwd_path, "pw", "usermod", "-n", username, h_arg, "0", NU= LL); +#else if (crypted) { execl(passwd_path, "chpasswd", "-e", NULL); } else { execl(passwd_path, "chpasswd", NULL); } +#endif _exit(EXIT_FAILURE); } else if (pid < 0) { error_setg_errno(errp, errno, "failed to create child process"); @@ -2227,7 +2240,17 @@ out: close(datafd[1]); } } +#else /* __linux__ || __FreeBSD__ */ +void qmp_guest_set_user_password(const char *username, + const char *password, + bool crypted, + Error **errp) +{ + error_setg(errp, QERR_UNSUPPORTED); +} +#endif /* __linux__ || __FreeBSD__ */ =20 +#ifdef __linux__ static void ga_read_sysfs_file(int dirfd, const char *pathname, char *buf, int size, Error **errp) { @@ -2764,14 +2787,6 @@ int64_t qmp_guest_set_vcpus(GuestLogicalProcessorLis= t *vcpus, Error **errp) return -1; } =20 -void qmp_guest_set_user_password(const char *username, - const char *password, - bool crypted, - Error **errp) -{ - error_setg(errp, QERR_UNSUPPORTED); -} - GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp) { error_setg(errp, QERR_UNSUPPORTED); --=20 2.25.1