From nobody Mon May 6 09:58:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1542663454176420.47897544415946; Mon, 19 Nov 2018 13:37:34 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C97275D5EA; Mon, 19 Nov 2018 21:37:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F8DE6090A; Mon, 19 Nov 2018 21:37:32 +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 E926C3F7D0; Mon, 19 Nov 2018 21:37:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAJLaX9g005823 for ; Mon, 19 Nov 2018 16:36:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0FB855D772; Mon, 19 Nov 2018 21:36:33 +0000 (UTC) Received: from wheatley (ovpn-204-97.brq.redhat.com [10.40.204.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BCAE35D760; Mon, 19 Nov 2018 21:36:29 +0000 (UTC) Received: from wheatley.lan (wheatley.usersys.redhat.com [127.0.0.1]) by wheatley (Postfix) with ESMTP id 332587E0037; Mon, 19 Nov 2018 22:36:28 +0100 (CET) From: Martin Kletzander To: libvir-list@redhat.com Date: Mon, 19 Nov 2018 22:35:56 +0100 Message-Id: <615106fb10f0f8df6fb2c361b1349bdb7dd5a942.1542663328.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: abologna@redhat.com Subject: [libvirt] [PATCH v3 1/2] qemu: Fix virDoes*Exist usage 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 19 Nov 2018 21:37:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The virGet*ID() functions should be called only if the user exists not when= it doesn't. Signed-off-by: Martin Kletzander Reviewed-by: Erik Skultety --- src/qemu/qemu_conf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 32da9a735184..a946b05d5d47 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -193,10 +193,10 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool pr= ivileged) if (virAsprintf(&cfg->swtpmStorageDir, "%s/lib/libvirt/swtpm", LOCALSTATEDIR) < 0) goto error; - if (virDoesUserExist("tss") !=3D 0 || + if (!virDoesUserExist("tss") || virGetUserID("tss", &cfg->swtpm_user) < 0) cfg->swtpm_user =3D 0; /* fall back to root */ - if (virDoesGroupExist("tss") !=3D 0 || + if (!virDoesGroupExist("tss") || virGetGroupID("tss", &cfg->swtpm_group) < 0) cfg->swtpm_group =3D 0; /* fall back to root */ } else { --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 09:58:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1542663460060223.69785837185202; Mon, 19 Nov 2018 13:37:40 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D7F42D2BFE; Mon, 19 Nov 2018 21:37:38 +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 56D151057062; Mon, 19 Nov 2018 21:37:38 +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 9C7BD18005B6; Mon, 19 Nov 2018 21:37:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAJLaXwi005822 for ; Mon, 19 Nov 2018 16:36:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0FAB25D76C; Mon, 19 Nov 2018 21:36:33 +0000 (UTC) Received: from wheatley (ovpn-204-97.brq.redhat.com [10.40.204.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BE5A85D763; Mon, 19 Nov 2018 21:36:29 +0000 (UTC) Received: from wheatley.lan (wheatley.usersys.redhat.com [127.0.0.1]) by wheatley (Postfix) with ESMTP id 3ED8A7E0038; Mon, 19 Nov 2018 22:36:28 +0100 (CET) From: Martin Kletzander To: libvir-list@redhat.com Date: Mon, 19 Nov 2018 22:35:57 +0100 Message-Id: <735e4f06422287143f9b09a629afe1e5c9d7177a.1542663328.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: abologna@redhat.com Subject: [libvirt] [PATCH v3 2/2] util: Fix virDoes*Exist return typ 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 19 Nov 2018 21:37:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Since the functions only return 0 or 1, they should return bool. I missed = the change when "refactoring" the first commit. Signed-off-by: Martin Kletzander Reviewed-by: Erik Skultety --- src/util/virutil.c | 12 ++++++------ src/util/virutil.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/util/virutil.c b/src/util/virutil.c index c0783ecb285b..974cffc2eeb7 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -1133,7 +1133,7 @@ virGetGroupID(const char *group, gid_t *gid) /* Silently checks if User @name exists. * Returns if the user exists and fallbacks to false on error. */ -int +bool virDoesUserExist(const char *name) { return virGetUserIDByName(name, NULL, true) =3D=3D 0; @@ -1142,7 +1142,7 @@ virDoesUserExist(const char *name) /* Silently checks if Group @name exists. * Returns if the group exists and fallbacks to false on error. */ -int +bool virDoesGroupExist(const char *name) { return virGetGroupIDByName(name, NULL, true) =3D=3D 0; @@ -1243,16 +1243,16 @@ virGetGroupList(uid_t uid ATTRIBUTE_UNUSED, gid_t g= id ATTRIBUTE_UNUSED, return 0; } =20 -int +bool virDoesUserExist(const char *name ATTRIBUTE_UNUSED) { - return 0; + return false; } =20 -int +bool virDoesGroupExist(const char *name ATTRIBUTE_UNUSED) { - return 0; + return false; } =20 # ifdef WIN32 diff --git a/src/util/virutil.h b/src/util/virutil.h index 2407f54efd47..e0ab0da0f2fc 100644 --- a/src/util/virutil.h +++ b/src/util/virutil.h @@ -152,8 +152,8 @@ int virGetUserID(const char *name, int virGetGroupID(const char *name, gid_t *gid) ATTRIBUTE_RETURN_CHECK; =20 -int virDoesUserExist(const char *name); -int virDoesGroupExist(const char *name); +bool virDoesUserExist(const char *name); +bool virDoesGroupExist(const char *name); =20 =20 bool virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1); --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list