mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
remote: properly initialize objects in ACL helpers
Commit 2ecdf25929
was intended to
implement two things: reduce stack usage inside ACL helpers and
minimally initialize virDomainDef object to avoid passing garbage
inside validation framework. Though original commit has not
touched other ACL helpers.
This patch adds proper clauses to
remoteRelayNetworkEventCheckACL
remoteRelayStoragePoolEventCheckACL
remoteRelayNodeDeviceEventCheckACL
remoteRelaySecretEventCheckACL
Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
b902cfece0
commit
d37a4aa69c
@ -180,21 +180,21 @@ static bool
|
|||||||
remoteRelayNetworkEventCheckACL(virNetServerClient *client,
|
remoteRelayNetworkEventCheckACL(virNetServerClient *client,
|
||||||
virConnectPtr conn, virNetworkPtr net)
|
virConnectPtr conn, virNetworkPtr net)
|
||||||
{
|
{
|
||||||
virNetworkDef def;
|
g_autofree virNetworkDef *def = g_new0(virNetworkDef, 1);
|
||||||
g_autoptr(virIdentity) identity = NULL;
|
g_autoptr(virIdentity) identity = NULL;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
/* For now, we just create a virNetworkDef with enough contents to
|
/* For now, we just create a virNetworkDef with enough contents to
|
||||||
* satisfy what viraccessdriverpolkit.c references. This is a bit
|
* satisfy what viraccessdriverpolkit.c references. This is a bit
|
||||||
* fragile, but I don't know of anything better. */
|
* fragile, but I don't know of anything better. */
|
||||||
def.name = net->name;
|
def->name = net->name;
|
||||||
memcpy(def.uuid, net->uuid, VIR_UUID_BUFLEN);
|
memcpy(def->uuid, net->uuid, VIR_UUID_BUFLEN);
|
||||||
|
|
||||||
if (!(identity = virNetServerClientGetIdentity(client)))
|
if (!(identity = virNetServerClientGetIdentity(client)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (virIdentitySetCurrent(identity) < 0)
|
if (virIdentitySetCurrent(identity) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
ret = virConnectNetworkEventRegisterAnyCheckACL(conn, &def);
|
ret = virConnectNetworkEventRegisterAnyCheckACL(conn, def);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
ignore_value(virIdentitySetCurrent(NULL));
|
ignore_value(virIdentitySetCurrent(NULL));
|
||||||
@ -206,21 +206,21 @@ remoteRelayStoragePoolEventCheckACL(virNetServerClient *client,
|
|||||||
virConnectPtr conn,
|
virConnectPtr conn,
|
||||||
virStoragePoolPtr pool)
|
virStoragePoolPtr pool)
|
||||||
{
|
{
|
||||||
virStoragePoolDef def;
|
g_autofree virStoragePoolDef *def = g_new0(virStoragePoolDef, 1);
|
||||||
g_autoptr(virIdentity) identity = NULL;
|
g_autoptr(virIdentity) identity = NULL;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
/* For now, we just create a virStoragePoolDef with enough contents to
|
/* For now, we just create a virStoragePoolDef with enough contents to
|
||||||
* satisfy what viraccessdriverpolkit.c references. This is a bit
|
* satisfy what viraccessdriverpolkit.c references. This is a bit
|
||||||
* fragile, but I don't know of anything better. */
|
* fragile, but I don't know of anything better. */
|
||||||
def.name = pool->name;
|
def->name = pool->name;
|
||||||
memcpy(def.uuid, pool->uuid, VIR_UUID_BUFLEN);
|
memcpy(def->uuid, pool->uuid, VIR_UUID_BUFLEN);
|
||||||
|
|
||||||
if (!(identity = virNetServerClientGetIdentity(client)))
|
if (!(identity = virNetServerClientGetIdentity(client)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (virIdentitySetCurrent(identity) < 0)
|
if (virIdentitySetCurrent(identity) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
ret = virConnectStoragePoolEventRegisterAnyCheckACL(conn, &def);
|
ret = virConnectStoragePoolEventRegisterAnyCheckACL(conn, def);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
ignore_value(virIdentitySetCurrent(NULL));
|
ignore_value(virIdentitySetCurrent(NULL));
|
||||||
@ -232,20 +232,20 @@ remoteRelayNodeDeviceEventCheckACL(virNetServerClient *client,
|
|||||||
virConnectPtr conn,
|
virConnectPtr conn,
|
||||||
virNodeDevicePtr dev)
|
virNodeDevicePtr dev)
|
||||||
{
|
{
|
||||||
virNodeDeviceDef def;
|
g_autofree virNodeDeviceDef *def = g_new0(virNodeDeviceDef, 1);
|
||||||
g_autoptr(virIdentity) identity = NULL;
|
g_autoptr(virIdentity) identity = NULL;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
/* For now, we just create a virNodeDeviceDef with enough contents to
|
/* For now, we just create a virNodeDeviceDef with enough contents to
|
||||||
* satisfy what viraccessdriverpolkit.c references. This is a bit
|
* satisfy what viraccessdriverpolkit.c references. This is a bit
|
||||||
* fragile, but I don't know of anything better. */
|
* fragile, but I don't know of anything better. */
|
||||||
def.name = dev->name;
|
def->name = dev->name;
|
||||||
|
|
||||||
if (!(identity = virNetServerClientGetIdentity(client)))
|
if (!(identity = virNetServerClientGetIdentity(client)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (virIdentitySetCurrent(identity) < 0)
|
if (virIdentitySetCurrent(identity) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
ret = virConnectNodeDeviceEventRegisterAnyCheckACL(conn, &def);
|
ret = virConnectNodeDeviceEventRegisterAnyCheckACL(conn, def);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
ignore_value(virIdentitySetCurrent(NULL));
|
ignore_value(virIdentitySetCurrent(NULL));
|
||||||
@ -257,22 +257,22 @@ remoteRelaySecretEventCheckACL(virNetServerClient *client,
|
|||||||
virConnectPtr conn,
|
virConnectPtr conn,
|
||||||
virSecretPtr secret)
|
virSecretPtr secret)
|
||||||
{
|
{
|
||||||
virSecretDef def;
|
g_autofree virSecretDef *def = g_new0(virSecretDef, 1);
|
||||||
g_autoptr(virIdentity) identity = NULL;
|
g_autoptr(virIdentity) identity = NULL;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
/* For now, we just create a virSecretDef with enough contents to
|
/* For now, we just create a virSecretDef with enough contents to
|
||||||
* satisfy what viraccessdriverpolkit.c references. This is a bit
|
* satisfy what viraccessdriverpolkit.c references. This is a bit
|
||||||
* fragile, but I don't know of anything better. */
|
* fragile, but I don't know of anything better. */
|
||||||
memcpy(def.uuid, secret->uuid, VIR_UUID_BUFLEN);
|
memcpy(def->uuid, secret->uuid, VIR_UUID_BUFLEN);
|
||||||
def.usage_type = secret->usageType;
|
def->usage_type = secret->usageType;
|
||||||
def.usage_id = secret->usageID;
|
def->usage_id = secret->usageID;
|
||||||
|
|
||||||
if (!(identity = virNetServerClientGetIdentity(client)))
|
if (!(identity = virNetServerClientGetIdentity(client)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (virIdentitySetCurrent(identity) < 0)
|
if (virIdentitySetCurrent(identity) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
ret = virConnectSecretEventRegisterAnyCheckACL(conn, &def);
|
ret = virConnectSecretEventRegisterAnyCheckACL(conn, def);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
ignore_value(virIdentitySetCurrent(NULL));
|
ignore_value(virIdentitySetCurrent(NULL));
|
||||||
|
Loading…
Reference in New Issue
Block a user