From nobody Sat Feb 7 08:16:15 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1584724021; cv=none; d=zohomail.com; s=zohoarc; b=D0DfY5+oLMvyRSckOs+iqABNOzwejtOh+RlCVPAij8JzpvkCWGRtgO+dRZzHz1X1bQOxGQt29nRmYc1KUSsnFVaAtltzbJWSIV9FC197Vafa1v7dZwjEolajrD9MSdsx8sBAu4fXbyOlIcyQoGF1sMTvTGPaanSpRQuDdm5HVV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584724021; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=bP/hb6NdBkYwiX6z9zTmYdThnys9uYNn1N1NFrTMIA8=; b=ebF/6DSvyDGyAJesyuzdqJL+gKSshprITfmu5Ja8MQA7yjNwkwtIXM4wIb1x7JW0pIChZnSKB4qcC9ujrkBH1+vZX8VUtqnA9w0Hm0JF7b388k4anKGIrSOhZfVPfBAe5OF20MMaCxxr4GH99MwD6e1VNd/fR1ZvnN+FpdqbwWk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by mx.zohomail.com with SMTPS id 1584724021485727.7367644047139; Fri, 20 Mar 2020 10:07:01 -0700 (PDT) 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-246-i-bfx5grN8mH3JQWQcKvqg-1; Fri, 20 Mar 2020 13:06:57 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id ADDE5100550D; Fri, 20 Mar 2020 17:06:51 +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 218435C1A7; Fri, 20 Mar 2020 17:06:51 +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 7624E94286; Fri, 20 Mar 2020 17:06:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02KH6nhG028748 for ; Fri, 20 Mar 2020 13:06:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 46E03200AF7F; Fri, 20 Mar 2020 17:06:49 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 431372028CD5 for ; Fri, 20 Mar 2020 17:06:45 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A4116101A55D for ; Fri, 20 Mar 2020 17:06:45 +0000 (UTC) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-167-qBsshQ1SPluu1jHsnuivEg-1; Fri, 20 Mar 2020 13:06:42 -0400 Received: by mail-wm1-f68.google.com with SMTP id d1so7200188wmb.2 for ; Fri, 20 Mar 2020 10:06:42 -0700 (PDT) Received: from localhost.localdomain (public-gprs375156.centertel.pl. [37.47.96.181]) by smtp.gmail.com with ESMTPSA id l83sm8450177wmf.43.2020.03.20.10.06.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2020 10:06:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584724019; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bP/hb6NdBkYwiX6z9zTmYdThnys9uYNn1N1NFrTMIA8=; b=GnR1VhKEgw4ba2hTsWVu5VTWQyy/qu86AsvJ6RksizlNPn20thWsprrX4EFF9BzATi/2bm Yww/o9fUNZHL3iaDMq+W/fCj/cfx+iG0XBqx0HlukzQO9dWVdsEtDWyen5twk1s5LxtsMT w2uIWRvOsFBLmbafFT1N+gYofEX5hUk= X-MC-Unique: i-bfx5grN8mH3JQWQcKvqg-1 X-MC-Unique: qBsshQ1SPluu1jHsnuivEg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6NTxJNvwxPLlYFIXULfZiIWKfIxZ1VLhs884Yhb5zxw=; b=dub377G7RZwTnC/k1NllTqohgplhKdTXBHW0McoPHFhznVrPg6JLMpcWpE16pQB6PQ JubDhwHBn7QZD71XD/u2Kp/f6favoO1jO4+Rx46lfN6EfrinijsxjlnJXKnhRmp9OahL WP0ZzvxNl1GZOEHlqTmvgH1qzwU53hzRZK/duGvcqrAd4sN8G3mR5Ate9j1co1VcoGYt o4xnBL1dDvyCr9Z6XMTjAsGXw8n2dhswXEGrnFH8QbqLiI0boR4VDqozyaNuqNLQsJWF v+4e1gsGYfOVToQlLvli8GXOYkkK6M+y4tghDdVKfuq8LR7Ze/5rl2I6S8X1auNch1T6 uB6A== X-Gm-Message-State: ANhLgQ0BwipuWhehpWAbGjVzKxJK0LQXEu76JY2dAs8ocMrL2FbjzeOU brTXpZCc8I+WDW5lK0pmHdjfPtNbNc4= X-Google-Smtp-Source: ADFU+vvfyNTI48O2u8tQKNwV0d3qghT7pHFjGxDQ9jYiJjcjGL1C4Vg6q+rSCBcMjpz7IjtCo+e0Qg== X-Received: by 2002:a1c:9904:: with SMTP id b4mr11272124wme.34.1584724000936; Fri, 20 Mar 2020 10:06:40 -0700 (PDT) From: Rafael Fonseca To: libvir-list@redhat.com Subject: [PATCH] util: authconfig: use g_key_file_* Date: Fri, 20 Mar 2020 18:06:35 +0100 Message-Id: <20200320170635.259413-1-r4f4rfs@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 02KH6nhG028748 X-loop: libvir-list@redhat.com Cc: Rafael Fonseca 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.79 on 10.5.11.13 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" Replace libvirt's virKeyFile by glib's GKeyFile. Signed-off-by: Rafael Fonseca --- src/util/virauthconfig.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/util/virauthconfig.c b/src/util/virauthconfig.c index fd846ddd4b..473b4c76d6 100644 --- a/src/util/virauthconfig.c +++ b/src/util/virauthconfig.c @@ -29,7 +29,7 @@ #include "viralloc.h" =20 struct _virAuthConfig { - virKeyFilePtr keyfile; + GKeyFile *keyfile; char *path; }; =20 @@ -46,10 +46,10 @@ virAuthConfigPtr virAuthConfigNew(const char *path) =20 auth->path =3D g_strdup(path); =20 - if (!(auth->keyfile =3D virKeyFileNew())) + if (!(auth->keyfile =3D g_key_file_new())) goto error; =20 - if (virKeyFileLoadFile(auth->keyfile, path) < 0) + if (!g_key_file_load_from_file(auth->keyfile, path, 0, NULL)) goto error; =20 return auth; @@ -71,10 +71,10 @@ virAuthConfigPtr virAuthConfigNewData(const char *path, =20 auth->path =3D g_strdup(path); =20 - if (!(auth->keyfile =3D virKeyFileNew())) + if (!(auth->keyfile =3D g_key_file_new())) goto error; =20 - if (virKeyFileLoadData(auth->keyfile, path, data, len) < 0) + if (!g_key_file_load_from_data(auth->keyfile, data, len, 0, NULL)) goto error; =20 return auth; @@ -90,7 +90,7 @@ void virAuthConfigFree(virAuthConfigPtr auth) if (!auth) return; =20 - virKeyFileFree(auth->keyfile); + g_key_file_free(auth->keyfile); VIR_FREE(auth->path); VIR_FREE(auth); } @@ -115,15 +115,15 @@ int virAuthConfigLookup(virAuthConfigPtr auth, =20 authgroup =3D g_strdup_printf("auth-%s-%s", service, hostname); =20 - if (!virKeyFileHasGroup(auth->keyfile, authgroup)) { + if (!g_key_file_has_group(auth->keyfile, authgroup)) { VIR_FREE(authgroup); authgroup =3D g_strdup_printf("auth-%s-%s", service, "default"); } =20 - if (!virKeyFileHasGroup(auth->keyfile, authgroup)) + if (!g_key_file_has_group(auth->keyfile, authgroup)) return 0; =20 - if (!(authcred =3D virKeyFileGetValueString(auth->keyfile, authgroup, = "credentials"))) { + if (!(authcred =3D g_key_file_get_string(auth->keyfile, authgroup, "cr= edentials", NULL))) { virReportError(VIR_ERR_CONF_SYNTAX, _("Missing item 'credentials' in group '%s' in '%s'= "), authgroup, auth->path); @@ -132,17 +132,14 @@ int virAuthConfigLookup(virAuthConfigPtr auth, =20 credgroup =3D g_strdup_printf("credentials-%s", authcred); =20 - if (!virKeyFileHasGroup(auth->keyfile, credgroup)) { + if (!g_key_file_has_group(auth->keyfile, credgroup)) { virReportError(VIR_ERR_CONF_SYNTAX, _("Missing group 'credentials-%s' referenced from g= roup '%s' in '%s'"), authcred, authgroup, auth->path); return -1; } =20 - if (!virKeyFileHasValue(auth->keyfile, credgroup, credname)) - return 0; - - *value =3D virKeyFileGetValueString(auth->keyfile, credgroup, credname= ); + *value =3D g_key_file_get_string(auth->keyfile, credgroup, credname, N= ULL); =20 return 0; } --=20 2.25.1