mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
remote: convert methods using virIdentityPtr to auto free macros
Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
7c9a1dcba8
commit
b74a95d6a2
@ -826,7 +826,7 @@ handleSystemMessageFunc(DBusConnection *connection ATTRIBUTE_UNUSED,
|
|||||||
static void daemonRunStateInit(void *opaque)
|
static void daemonRunStateInit(void *opaque)
|
||||||
{
|
{
|
||||||
virNetDaemonPtr dmn = opaque;
|
virNetDaemonPtr dmn = opaque;
|
||||||
virIdentityPtr sysident = virIdentityGetSystem();
|
g_autoptr(virIdentity) sysident = virIdentityGetSystem();
|
||||||
#ifdef MODULE_NAME
|
#ifdef MODULE_NAME
|
||||||
bool mandatory = true;
|
bool mandatory = true;
|
||||||
#else /* ! MODULE_NAME */
|
#else /* ! MODULE_NAME */
|
||||||
@ -879,7 +879,6 @@ static void daemonRunStateInit(void *opaque)
|
|||||||
cleanup:
|
cleanup:
|
||||||
daemonInhibitCallback(false, dmn);
|
daemonInhibitCallback(false, dmn);
|
||||||
virObjectUnref(dmn);
|
virObjectUnref(dmn);
|
||||||
virObjectUnref(sysident);
|
|
||||||
virIdentitySetCurrent(NULL);
|
virIdentitySetCurrent(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ remoteRelayDomainEventCheckACL(virNetServerClientPtr client,
|
|||||||
virConnectPtr conn, virDomainPtr dom)
|
virConnectPtr conn, virDomainPtr dom)
|
||||||
{
|
{
|
||||||
virDomainDef def;
|
virDomainDef def;
|
||||||
virIdentityPtr identity = NULL;
|
g_autoptr(virIdentity) identity = NULL;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
/* For now, we just create a virDomainDef with enough contents to
|
/* For now, we just create a virDomainDef with enough contents to
|
||||||
@ -177,7 +177,6 @@ remoteRelayDomainEventCheckACL(virNetServerClientPtr client,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
ignore_value(virIdentitySetCurrent(NULL));
|
ignore_value(virIdentitySetCurrent(NULL));
|
||||||
virObjectUnref(identity);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +186,7 @@ remoteRelayNetworkEventCheckACL(virNetServerClientPtr client,
|
|||||||
virConnectPtr conn, virNetworkPtr net)
|
virConnectPtr conn, virNetworkPtr net)
|
||||||
{
|
{
|
||||||
virNetworkDef def;
|
virNetworkDef def;
|
||||||
virIdentityPtr 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
|
||||||
@ -204,7 +203,6 @@ remoteRelayNetworkEventCheckACL(virNetServerClientPtr client,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
ignore_value(virIdentitySetCurrent(NULL));
|
ignore_value(virIdentitySetCurrent(NULL));
|
||||||
virObjectUnref(identity);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +212,7 @@ remoteRelayStoragePoolEventCheckACL(virNetServerClientPtr client,
|
|||||||
virStoragePoolPtr pool)
|
virStoragePoolPtr pool)
|
||||||
{
|
{
|
||||||
virStoragePoolDef def;
|
virStoragePoolDef def;
|
||||||
virIdentityPtr 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
|
||||||
@ -231,7 +229,6 @@ remoteRelayStoragePoolEventCheckACL(virNetServerClientPtr client,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
ignore_value(virIdentitySetCurrent(NULL));
|
ignore_value(virIdentitySetCurrent(NULL));
|
||||||
virObjectUnref(identity);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +238,7 @@ remoteRelayNodeDeviceEventCheckACL(virNetServerClientPtr client,
|
|||||||
virNodeDevicePtr dev)
|
virNodeDevicePtr dev)
|
||||||
{
|
{
|
||||||
virNodeDeviceDef def;
|
virNodeDeviceDef def;
|
||||||
virIdentityPtr 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
|
||||||
@ -257,7 +254,6 @@ remoteRelayNodeDeviceEventCheckACL(virNetServerClientPtr client,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
ignore_value(virIdentitySetCurrent(NULL));
|
ignore_value(virIdentitySetCurrent(NULL));
|
||||||
virObjectUnref(identity);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +263,7 @@ remoteRelaySecretEventCheckACL(virNetServerClientPtr client,
|
|||||||
virSecretPtr secret)
|
virSecretPtr secret)
|
||||||
{
|
{
|
||||||
virSecretDef def;
|
virSecretDef def;
|
||||||
virIdentityPtr 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
|
||||||
@ -285,7 +281,6 @@ remoteRelaySecretEventCheckACL(virNetServerClientPtr client,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
ignore_value(virIdentitySetCurrent(NULL));
|
ignore_value(virIdentitySetCurrent(NULL));
|
||||||
virObjectUnref(identity);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,7 +289,7 @@ remoteRelayDomainQemuMonitorEventCheckACL(virNetServerClientPtr client,
|
|||||||
virConnectPtr conn, virDomainPtr dom)
|
virConnectPtr conn, virDomainPtr dom)
|
||||||
{
|
{
|
||||||
virDomainDef def;
|
virDomainDef def;
|
||||||
virIdentityPtr identity = NULL;
|
g_autoptr(virIdentity) identity = NULL;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
/* For now, we just create a virDomainDef with enough contents to
|
/* For now, we just create a virDomainDef with enough contents to
|
||||||
@ -311,7 +306,6 @@ remoteRelayDomainQemuMonitorEventCheckACL(virNetServerClientPtr client,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
ignore_value(virIdentitySetCurrent(NULL));
|
ignore_value(virIdentitySetCurrent(NULL));
|
||||||
virObjectUnref(identity);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1869,7 +1863,7 @@ void remoteRelayConnectionClosedEvent(virConnectPtr conn ATTRIBUTE_UNUSED, int r
|
|||||||
static void
|
static void
|
||||||
remoteClientFreePrivateCallbacks(struct daemonClientPrivate *priv)
|
remoteClientFreePrivateCallbacks(struct daemonClientPrivate *priv)
|
||||||
{
|
{
|
||||||
virIdentityPtr sysident = virIdentityGetSystem();
|
g_autoptr(virIdentity) sysident = virIdentityGetSystem();
|
||||||
virIdentitySetCurrent(sysident);
|
virIdentitySetCurrent(sysident);
|
||||||
|
|
||||||
DEREG_CB(priv->conn, priv->domainEventCallbacks,
|
DEREG_CB(priv->conn, priv->domainEventCallbacks,
|
||||||
@ -1898,7 +1892,6 @@ remoteClientFreePrivateCallbacks(struct daemonClientPrivate *priv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
virIdentitySetCurrent(NULL);
|
virIdentitySetCurrent(NULL);
|
||||||
virObjectUnref(sysident);
|
|
||||||
}
|
}
|
||||||
#undef DEREG_CB
|
#undef DEREG_CB
|
||||||
|
|
||||||
@ -1965,7 +1958,7 @@ remoteOpenConn(const char *uri,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (preserveIdentity) {
|
if (preserveIdentity) {
|
||||||
VIR_AUTOUNREF(virIdentityPtr) ident = NULL;
|
g_autoptr(virIdentity) ident = NULL;
|
||||||
|
|
||||||
if (!(ident = virIdentityGetCurrent()))
|
if (!(ident = virIdentityGetCurrent()))
|
||||||
return -1;
|
return -1;
|
||||||
@ -2436,7 +2429,7 @@ remoteDispatchConnectSetIdentity(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|||||||
int nparams = 0;
|
int nparams = 0;
|
||||||
int rv = -1;
|
int rv = -1;
|
||||||
virConnectPtr conn = remoteGetHypervisorConn(client);
|
virConnectPtr conn = remoteGetHypervisorConn(client);
|
||||||
VIR_AUTOUNREF(virIdentityPtr) ident = NULL;
|
g_autoptr(virIdentity) ident = NULL;
|
||||||
if (!conn)
|
if (!conn)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -3982,7 +3975,7 @@ static int
|
|||||||
remoteSASLFinish(virNetServerPtr server,
|
remoteSASLFinish(virNetServerPtr server,
|
||||||
virNetServerClientPtr client)
|
virNetServerClientPtr client)
|
||||||
{
|
{
|
||||||
virIdentityPtr clnt_identity = NULL;
|
g_autoptr(virIdentity) clnt_identity = NULL;
|
||||||
const char *identity;
|
const char *identity;
|
||||||
struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
|
struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
|
||||||
int ssf;
|
int ssf;
|
||||||
@ -3990,7 +3983,7 @@ remoteSASLFinish(virNetServerPtr server,
|
|||||||
/* TLS or UNIX domain sockets trivially OK */
|
/* TLS or UNIX domain sockets trivially OK */
|
||||||
if (!virNetServerClientIsSecure(client)) {
|
if (!virNetServerClientIsSecure(client)) {
|
||||||
if ((ssf = virNetSASLSessionGetKeySize(priv->sasl)) < 0)
|
if ((ssf = virNetSASLSessionGetKeySize(priv->sasl)) < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
VIR_DEBUG("negotiated an SSF of %d", ssf);
|
VIR_DEBUG("negotiated an SSF of %d", ssf);
|
||||||
if (ssf < 56) { /* 56 is good for Kerberos */
|
if (ssf < 56) { /* 56 is good for Kerberos */
|
||||||
@ -4006,7 +3999,7 @@ remoteSASLFinish(virNetServerPtr server,
|
|||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
if (!(clnt_identity = virNetServerClientGetIdentity(client)))
|
if (!(clnt_identity = virNetServerClientGetIdentity(client)))
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
virNetServerSetClientAuthenticated(server, client);
|
virNetServerSetClientAuthenticated(server, client);
|
||||||
virNetServerClientSetSASLSession(client, priv->sasl);
|
virNetServerClientSetSASLSession(client, priv->sasl);
|
||||||
@ -4018,14 +4011,10 @@ remoteSASLFinish(virNetServerPtr server,
|
|||||||
"client=%p auth=%d identity=%s",
|
"client=%p auth=%d identity=%s",
|
||||||
client, REMOTE_AUTH_SASL, identity);
|
client, REMOTE_AUTH_SASL, identity);
|
||||||
|
|
||||||
virObjectUnref(clnt_identity);
|
|
||||||
virObjectUnref(priv->sasl);
|
virObjectUnref(priv->sasl);
|
||||||
priv->sasl = NULL;
|
priv->sasl = NULL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user