From nobody Sat Feb 7 18:51:55 2026 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 ARC-Seal: i=1; a=rsa-sha256; t=1570704892; cv=none; d=zoho.com; s=zohoarc; b=JJ2TPhUzu4FZcGQSO7GuvMXyzZey/oo0uIu0xRl4/yDcn6KSWwv+AsXW0+VUDMOB6A7x+jz8woIqE5Xf5WCnMASO/15W2vELgzbtTQqMpuuXGhxYEUxvI/VYu7qQCmktR/Gm4f8mbQdWOFjVj31V9DTzOg6aCjFgc7rEZq4fMR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570704892; h=Content-Type:Content-Transfer-Encoding:Cc: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=FnHGLZKFTNOF65pZSV6vH2DX28jwzQ5XLbqx4xX5h9U=; b=UyPSveP2tZSXjWAh32JFHnfACXc8DZjpbcU0iu0C2LCdap2LPIPFnP8znelCu/aJDecOY7ndl8xJ3xspJgCoILhl/Yjv/lSDBNG7z+hxIOvCfOVAQ/EU0S4B9PGGK35+NIsyQnCB+hyu2NY7w64SC9b3Aka1ScKNC/3IgXXZa74= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570704892200703.7967314860102; Thu, 10 Oct 2019 03:54:52 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9406318C428C; Thu, 10 Oct 2019 10:54:50 +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 6AE32167A3; Thu, 10 Oct 2019 10:54:50 +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 2D63F180BAA5; Thu, 10 Oct 2019 10:54:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9AAsUQR010441 for ; Thu, 10 Oct 2019 06:54:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9DB635C231; Thu, 10 Oct 2019 10:54:30 +0000 (UTC) Received: from dhcp-16-231.lcy.redhat.com (unknown [10.42.16.231]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA2FC5C1B5; Thu, 10 Oct 2019 10:54:29 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 10 Oct 2019 11:54:05 +0100 Message-Id: <20191010105413.4091-12-berrange@redhat.com> In-Reply-To: <20191010105413.4091-1-berrange@redhat.com> References: <20191010105413.4091-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?J=C3=A1n=20Tomko?= Subject: [libvirt] [PATCH v3 11/19] access: convert polkit driver to auto free memory 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-Type: text/plain; charset="utf-8" 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Thu, 10 Oct 2019 10:54:51 +0000 (UTC) Reviewed-by: J=C3=A1n Tomko Signed-off-by: Daniel P. Berrang=C3=A9 --- src/access/viraccessdriverpolkit.c | 38 +++++++++++------------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/src/access/viraccessdriverpolkit.c b/src/access/viraccessdrive= rpolkit.c index e61ac6fa19..fbe7789ccd 100644 --- a/src/access/viraccessdriverpolkit.c +++ b/src/access/viraccessdriverpolkit.c @@ -78,8 +78,7 @@ virAccessDriverPolkitGetCaller(const char *actionid, unsigned long long *startTime, uid_t *uid) { - virIdentityPtr identity =3D virIdentityGetCurrent(); - int ret =3D -1; + g_autoptr(virIdentity) identity =3D virIdentityGetCurrent(); int rc; =20 if (!identity) { @@ -90,37 +89,33 @@ virAccessDriverPolkitGetCaller(const char *actionid, } =20 if ((rc =3D virIdentityGetProcessID(identity, pid)) < 0) - goto cleanup; + return -1; =20 if (rc =3D=3D 0) { virAccessError(VIR_ERR_INTERNAL_ERROR, "%s", _("No process ID available")); - goto cleanup; + return -1; } =20 if ((rc =3D virIdentityGetProcessTime(identity, startTime)) < 0) - goto cleanup; + return -1; =20 if (rc =3D=3D 0) { virAccessError(VIR_ERR_INTERNAL_ERROR, "%s", _("No process start time available")); - goto cleanup; + return -1; } =20 if ((rc =3D virIdentityGetUNIXUserID(identity, uid)) < 0) - goto cleanup; + return -1; =20 if (rc =3D=3D 0) { virAccessError(VIR_ERR_INTERNAL_ERROR, "%s", _("No UNIX caller UID available")); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - virObjectUnref(identity); - return ret; + return 0; } =20 =20 @@ -130,21 +125,20 @@ virAccessDriverPolkitCheck(virAccessManagerPtr manage= r ATTRIBUTE_UNUSED, const char *permname, const char **attrs) { - char *actionid =3D NULL; - int ret =3D -1; + g_autofree char *actionid =3D NULL; pid_t pid; uid_t uid; unsigned long long startTime; int rv; =20 if (!(actionid =3D virAccessDriverPolkitFormatAction(typename, permnam= e))) - goto cleanup; + return -1; =20 if (virAccessDriverPolkitGetCaller(actionid, &pid, &startTime, &uid) < 0) - goto cleanup; + return -1; =20 VIR_DEBUG("Check action '%s' for process '%lld' time %lld uid %d", actionid, (long long)pid, startTime, uid); @@ -157,18 +151,14 @@ virAccessDriverPolkitCheck(virAccessManagerPtr manage= r ATTRIBUTE_UNUSED, false); =20 if (rv =3D=3D 0) { - ret =3D 1; /* Allowed */ + return 1; /* Allowed */ } else { if (rv =3D=3D -2) { - ret =3D 0; /* Denied */ + return 0; /* Denied */ } else { - ret =3D -1; /* Error */ + return -1; /* Error */ } } - - cleanup: - VIR_FREE(actionid); - return ret; } =20 =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list