mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Convert all files in src/rpc/ to use virReportError()
This rmoves all the per-file error reporting macros from the code in src/rpc/ Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
f6d4405e3c
commit
7c45ad4ba2
@ -33,9 +33,6 @@
|
|||||||
#include "virkeepalive.h"
|
#include "virkeepalive.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_RPC
|
#define VIR_FROM_THIS VIR_FROM_RPC
|
||||||
#define virNetError(code, ...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
|
||||||
|
|
||||||
struct _virKeepAlive {
|
struct _virKeepAlive {
|
||||||
int refs;
|
int refs;
|
||||||
@ -287,7 +284,7 @@ virKeepAliveStart(virKeepAlivePtr ka,
|
|||||||
|
|
||||||
if (interval > 0) {
|
if (interval > 0) {
|
||||||
if (ka->interval > 0) {
|
if (ka->interval > 0) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("keepalive interval already set"));
|
_("keepalive interval already set"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -38,9 +38,6 @@
|
|||||||
#include "virterror_internal.h"
|
#include "virterror_internal.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_RPC
|
#define VIR_FROM_THIS VIR_FROM_RPC
|
||||||
#define virNetError(code, ...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
|
||||||
|
|
||||||
typedef struct _virNetClientCall virNetClientCall;
|
typedef struct _virNetClientCall virNetClientCall;
|
||||||
typedef virNetClientCall *virNetClientCallPtr;
|
typedef virNetClientCall *virNetClientCallPtr;
|
||||||
@ -651,7 +648,7 @@ int virNetClientSetTLSSession(virNetClientPtr client,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (len != 1 || buf[0] != '\1') {
|
if (len != 1 || buf[0] != '\1') {
|
||||||
virNetError(VIR_ERR_RPC, "%s",
|
virReportError(VIR_ERR_RPC, "%s",
|
||||||
_("server verification (of our certificate or IP "
|
_("server verification (of our certificate or IP "
|
||||||
"address) failed"));
|
"address) failed"));
|
||||||
goto error;
|
goto error;
|
||||||
@ -802,7 +799,7 @@ virNetClientCallDispatchReply(virNetClientPtr client)
|
|||||||
thecall = thecall->next;
|
thecall = thecall->next;
|
||||||
|
|
||||||
if (!thecall) {
|
if (!thecall) {
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
_("no call waiting for reply with prog %d vers %d serial %d"),
|
_("no call waiting for reply with prog %d vers %d serial %d"),
|
||||||
client->msg.header.prog, client->msg.header.vers, client->msg.header.serial);
|
client->msg.header.prog, client->msg.header.vers, client->msg.header.serial);
|
||||||
return -1;
|
return -1;
|
||||||
@ -968,7 +965,7 @@ virNetClientCallDispatch(virNetClientPtr client)
|
|||||||
return virNetClientCallDispatchStream(client);
|
return virNetClientCallDispatchStream(client);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
_("got unexpected RPC call prog %d vers %d proc %d type %d"),
|
_("got unexpected RPC call prog %d vers %d proc %d type %d"),
|
||||||
client->msg.header.prog, client->msg.header.vers,
|
client->msg.header.prog, client->msg.header.vers,
|
||||||
client->msg.header.proc, client->msg.header.type);
|
client->msg.header.proc, client->msg.header.type);
|
||||||
@ -1413,7 +1410,7 @@ static int virNetClientIOEventLoop(virNetClientPtr client,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fds[0].revents & (POLLHUP | POLLERR)) {
|
if (fds[0].revents & (POLLHUP | POLLERR)) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("received hangup / error event on socket"));
|
_("received hangup / error event on socket"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -1554,7 +1551,7 @@ static int virNetClientIO(virNetClientPtr client,
|
|||||||
/* Go to sleep while other thread is working... */
|
/* Go to sleep while other thread is working... */
|
||||||
if (virCondWait(&thiscall->cond, &client->lock) < 0) {
|
if (virCondWait(&thiscall->cond, &client->lock) < 0) {
|
||||||
virNetClientCallRemove(&client->waitDispatch, thiscall);
|
virNetClientCallRemove(&client->waitDispatch, thiscall);
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("failed to wait on condition"));
|
_("failed to wait on condition"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1673,14 +1670,14 @@ virNetClientCallNew(virNetMessagePtr msg,
|
|||||||
if (expectReply &&
|
if (expectReply &&
|
||||||
(msg->bufferLength != 0) &&
|
(msg->bufferLength != 0) &&
|
||||||
(msg->header.status == VIR_NET_CONTINUE)) {
|
(msg->header.status == VIR_NET_CONTINUE)) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Attempt to send an asynchronous message with"
|
_("Attempt to send an asynchronous message with"
|
||||||
" a synchronous reply"));
|
" a synchronous reply"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expectReply && nonBlock) {
|
if (expectReply && nonBlock) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Attempt to send a non-blocking message with"
|
_("Attempt to send a non-blocking message with"
|
||||||
" a synchronous reply"));
|
" a synchronous reply"));
|
||||||
goto error;
|
goto error;
|
||||||
@ -1692,7 +1689,7 @@ virNetClientCallNew(virNetMessagePtr msg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virCondInit(&call->cond) < 0) {
|
if (virCondInit(&call->cond) < 0) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("cannot initialize condition variable"));
|
_("cannot initialize condition variable"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -1757,7 +1754,7 @@ static int virNetClientSendInternal(virNetClientPtr client,
|
|||||||
msg->header.type, msg->header.status, msg->header.serial);
|
msg->header.type, msg->header.status, msg->header.serial);
|
||||||
|
|
||||||
if (!client->sock || client->wantClose) {
|
if (!client->sock || client->wantClose) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("client socket is closed"));
|
_("client socket is closed"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,6 @@
|
|||||||
#include "virfile.h"
|
#include "virfile.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_RPC
|
#define VIR_FROM_THIS VIR_FROM_RPC
|
||||||
#define virNetError(code, ...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
|
||||||
|
|
||||||
struct _virNetClientProgram {
|
struct _virNetClientProgram {
|
||||||
int refs;
|
int refs;
|
||||||
@ -336,18 +333,18 @@ int virNetClientProgramCall(virNetClientProgramPtr prog,
|
|||||||
*/
|
*/
|
||||||
if (msg->header.type != VIR_NET_REPLY &&
|
if (msg->header.type != VIR_NET_REPLY &&
|
||||||
msg->header.type != VIR_NET_REPLY_WITH_FDS) {
|
msg->header.type != VIR_NET_REPLY_WITH_FDS) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unexpected message type %d"), msg->header.type);
|
_("Unexpected message type %d"), msg->header.type);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (msg->header.proc != proc) {
|
if (msg->header.proc != proc) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unexpected message proc %d != %d"),
|
_("Unexpected message proc %d != %d"),
|
||||||
msg->header.proc, proc);
|
msg->header.proc, proc);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (msg->header.serial != serial) {
|
if (msg->header.serial != serial) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unexpected message serial %d != %d"),
|
_("Unexpected message serial %d != %d"),
|
||||||
msg->header.serial, serial);
|
msg->header.serial, serial);
|
||||||
goto error;
|
goto error;
|
||||||
@ -388,7 +385,7 @@ int virNetClientProgramCall(virNetClientProgramPtr prog,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
_("Unexpected message status %d"), msg->header.status);
|
_("Unexpected message status %d"), msg->header.status);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,6 @@
|
|||||||
#include "threads.h"
|
#include "threads.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_RPC
|
#define VIR_FROM_THIS VIR_FROM_RPC
|
||||||
#define virNetError(code, ...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
|
||||||
|
|
||||||
struct _virNetClientStream {
|
struct _virNetClientStream {
|
||||||
virMutex lock;
|
virMutex lock;
|
||||||
@ -147,7 +144,7 @@ virNetClientStreamPtr virNetClientStreamNew(virNetClientProgramPtr prog,
|
|||||||
st->serial = serial;
|
st->serial = serial;
|
||||||
|
|
||||||
if (virMutexInit(&st->lock) < 0) {
|
if (virMutexInit(&st->lock) < 0) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("cannot initialize mutex"));
|
_("cannot initialize mutex"));
|
||||||
VIR_FREE(st);
|
VIR_FREE(st);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -452,7 +449,7 @@ int virNetClientStreamEventAddCallback(virNetClientStreamPtr st,
|
|||||||
|
|
||||||
virMutexLock(&st->lock);
|
virMutexLock(&st->lock);
|
||||||
if (st->cb) {
|
if (st->cb) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("multiple stream callbacks not supported"));
|
"%s", _("multiple stream callbacks not supported"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -488,7 +485,7 @@ int virNetClientStreamEventUpdateCallback(virNetClientStreamPtr st,
|
|||||||
|
|
||||||
virMutexLock(&st->lock);
|
virMutexLock(&st->lock);
|
||||||
if (!st->cb) {
|
if (!st->cb) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("no stream callback registered"));
|
"%s", _("no stream callback registered"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -510,7 +507,7 @@ int virNetClientStreamEventRemoveCallback(virNetClientStreamPtr st)
|
|||||||
|
|
||||||
virMutexLock(&st->lock);
|
virMutexLock(&st->lock);
|
||||||
if (!st->cb) {
|
if (!st->cb) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("no stream callback registered"));
|
"%s", _("no stream callback registered"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,6 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_RPC
|
#define VIR_FROM_THIS VIR_FROM_RPC
|
||||||
#define virNetError(code, ...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
|
||||||
|
|
||||||
virNetMessagePtr virNetMessageNew(bool tracked)
|
virNetMessagePtr virNetMessageNew(bool tracked)
|
||||||
{
|
{
|
||||||
@ -121,13 +118,13 @@ int virNetMessageDecodeLength(virNetMessagePtr msg)
|
|||||||
xdrmem_create(&xdr, msg->buffer,
|
xdrmem_create(&xdr, msg->buffer,
|
||||||
msg->bufferLength, XDR_DECODE);
|
msg->bufferLength, XDR_DECODE);
|
||||||
if (!xdr_u_int(&xdr, &len)) {
|
if (!xdr_u_int(&xdr, &len)) {
|
||||||
virNetError(VIR_ERR_RPC, "%s", _("Unable to decode message length"));
|
virReportError(VIR_ERR_RPC, "%s", _("Unable to decode message length"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
msg->bufferOffset = xdr_getpos(&xdr);
|
msg->bufferOffset = xdr_getpos(&xdr);
|
||||||
|
|
||||||
if (len < VIR_NET_MESSAGE_LEN_MAX) {
|
if (len < VIR_NET_MESSAGE_LEN_MAX) {
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
_("packet %d bytes received from server too small, want %d"),
|
_("packet %d bytes received from server too small, want %d"),
|
||||||
len, VIR_NET_MESSAGE_LEN_MAX);
|
len, VIR_NET_MESSAGE_LEN_MAX);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -137,7 +134,7 @@ int virNetMessageDecodeLength(virNetMessagePtr msg)
|
|||||||
len -= VIR_NET_MESSAGE_LEN_MAX;
|
len -= VIR_NET_MESSAGE_LEN_MAX;
|
||||||
|
|
||||||
if (len > VIR_NET_MESSAGE_MAX) {
|
if (len > VIR_NET_MESSAGE_MAX) {
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
_("packet %d bytes received from server too large, want %d"),
|
_("packet %d bytes received from server too large, want %d"),
|
||||||
len, VIR_NET_MESSAGE_MAX);
|
len, VIR_NET_MESSAGE_MAX);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -187,7 +184,7 @@ int virNetMessageDecodeHeader(virNetMessagePtr msg)
|
|||||||
XDR_DECODE);
|
XDR_DECODE);
|
||||||
|
|
||||||
if (!xdr_virNetMessageHeader(&xdr, &msg->header)) {
|
if (!xdr_virNetMessageHeader(&xdr, &msg->header)) {
|
||||||
virNetError(VIR_ERR_RPC, "%s", _("Unable to decode message header"));
|
virReportError(VIR_ERR_RPC, "%s", _("Unable to decode message header"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,12 +230,12 @@ int virNetMessageEncodeHeader(virNetMessagePtr msg)
|
|||||||
|
|
||||||
/* The real value is filled in shortly */
|
/* The real value is filled in shortly */
|
||||||
if (!xdr_u_int(&xdr, &len)) {
|
if (!xdr_u_int(&xdr, &len)) {
|
||||||
virNetError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
|
virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xdr_virNetMessageHeader(&xdr, &msg->header)) {
|
if (!xdr_virNetMessageHeader(&xdr, &msg->header)) {
|
||||||
virNetError(VIR_ERR_RPC, "%s", _("Unable to encode message header"));
|
virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message header"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +246,7 @@ int virNetMessageEncodeHeader(virNetMessagePtr msg)
|
|||||||
* if a payload is added
|
* if a payload is added
|
||||||
*/
|
*/
|
||||||
if (!xdr_u_int(&xdr, &len)) {
|
if (!xdr_u_int(&xdr, &len)) {
|
||||||
virNetError(VIR_ERR_RPC, "%s", _("Unable to re-encode message length"));
|
virReportError(VIR_ERR_RPC, "%s", _("Unable to re-encode message length"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,14 +270,14 @@ int virNetMessageEncodeNumFDs(virNetMessagePtr msg)
|
|||||||
msg->bufferLength - msg->bufferOffset, XDR_ENCODE);
|
msg->bufferLength - msg->bufferOffset, XDR_ENCODE);
|
||||||
|
|
||||||
if (numFDs > VIR_NET_MESSAGE_NUM_FDS_MAX) {
|
if (numFDs > VIR_NET_MESSAGE_NUM_FDS_MAX) {
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
_("Too many FDs to send %d, expected %d maximum"),
|
_("Too many FDs to send %d, expected %d maximum"),
|
||||||
numFDs, VIR_NET_MESSAGE_NUM_FDS_MAX);
|
numFDs, VIR_NET_MESSAGE_NUM_FDS_MAX);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xdr_u_int(&xdr, &numFDs)) {
|
if (!xdr_u_int(&xdr, &numFDs)) {
|
||||||
virNetError(VIR_ERR_RPC, "%s", _("Unable to encode number of FDs"));
|
virReportError(VIR_ERR_RPC, "%s", _("Unable to encode number of FDs"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
msg->bufferOffset += xdr_getpos(&xdr);
|
msg->bufferOffset += xdr_getpos(&xdr);
|
||||||
@ -305,13 +302,13 @@ int virNetMessageDecodeNumFDs(virNetMessagePtr msg)
|
|||||||
xdrmem_create(&xdr, msg->buffer + msg->bufferOffset,
|
xdrmem_create(&xdr, msg->buffer + msg->bufferOffset,
|
||||||
msg->bufferLength - msg->bufferOffset, XDR_DECODE);
|
msg->bufferLength - msg->bufferOffset, XDR_DECODE);
|
||||||
if (!xdr_u_int(&xdr, &numFDs)) {
|
if (!xdr_u_int(&xdr, &numFDs)) {
|
||||||
virNetError(VIR_ERR_RPC, "%s", _("Unable to decode number of FDs"));
|
virReportError(VIR_ERR_RPC, "%s", _("Unable to decode number of FDs"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
msg->bufferOffset += xdr_getpos(&xdr);
|
msg->bufferOffset += xdr_getpos(&xdr);
|
||||||
|
|
||||||
if (numFDs > VIR_NET_MESSAGE_NUM_FDS_MAX) {
|
if (numFDs > VIR_NET_MESSAGE_NUM_FDS_MAX) {
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
_("Received too many FDs %d, expected %d maximum"),
|
_("Received too many FDs %d, expected %d maximum"),
|
||||||
numFDs, VIR_NET_MESSAGE_NUM_FDS_MAX);
|
numFDs, VIR_NET_MESSAGE_NUM_FDS_MAX);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -349,7 +346,7 @@ int virNetMessageEncodePayload(virNetMessagePtr msg,
|
|||||||
msg->bufferLength - msg->bufferOffset, XDR_ENCODE);
|
msg->bufferLength - msg->bufferOffset, XDR_ENCODE);
|
||||||
|
|
||||||
if (!(*filter)(&xdr, data)) {
|
if (!(*filter)(&xdr, data)) {
|
||||||
virNetError(VIR_ERR_RPC, "%s", _("Unable to encode message payload"));
|
virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message payload"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,7 +359,7 @@ int virNetMessageEncodePayload(virNetMessagePtr msg,
|
|||||||
xdrmem_create(&xdr, msg->buffer, VIR_NET_MESSAGE_HEADER_XDR_LEN, XDR_ENCODE);
|
xdrmem_create(&xdr, msg->buffer, VIR_NET_MESSAGE_HEADER_XDR_LEN, XDR_ENCODE);
|
||||||
msglen = msg->bufferOffset;
|
msglen = msg->bufferOffset;
|
||||||
if (!xdr_u_int(&xdr, &msglen)) {
|
if (!xdr_u_int(&xdr, &msglen)) {
|
||||||
virNetError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
|
virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
xdr_destroy(&xdr);
|
xdr_destroy(&xdr);
|
||||||
@ -390,7 +387,7 @@ int virNetMessageDecodePayload(virNetMessagePtr msg,
|
|||||||
msg->bufferLength - msg->bufferOffset, XDR_DECODE);
|
msg->bufferLength - msg->bufferOffset, XDR_DECODE);
|
||||||
|
|
||||||
if (!(*filter)(&xdr, data)) {
|
if (!(*filter)(&xdr, data)) {
|
||||||
virNetError(VIR_ERR_RPC, "%s", _("Unable to decode message payload"));
|
virReportError(VIR_ERR_RPC, "%s", _("Unable to decode message payload"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +410,7 @@ int virNetMessageEncodePayloadRaw(virNetMessagePtr msg,
|
|||||||
unsigned int msglen;
|
unsigned int msglen;
|
||||||
|
|
||||||
if ((msg->bufferLength - msg->bufferOffset) < len) {
|
if ((msg->bufferLength - msg->bufferOffset) < len) {
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
_("Stream data too long to send (%zu bytes needed, %zu bytes available)"),
|
_("Stream data too long to send (%zu bytes needed, %zu bytes available)"),
|
||||||
len, (msg->bufferLength - msg->bufferOffset));
|
len, (msg->bufferLength - msg->bufferOffset));
|
||||||
return -1;
|
return -1;
|
||||||
@ -427,7 +424,7 @@ int virNetMessageEncodePayloadRaw(virNetMessagePtr msg,
|
|||||||
xdrmem_create(&xdr, msg->buffer, VIR_NET_MESSAGE_HEADER_XDR_LEN, XDR_ENCODE);
|
xdrmem_create(&xdr, msg->buffer, VIR_NET_MESSAGE_HEADER_XDR_LEN, XDR_ENCODE);
|
||||||
msglen = msg->bufferOffset;
|
msglen = msg->bufferOffset;
|
||||||
if (!xdr_u_int(&xdr, &msglen)) {
|
if (!xdr_u_int(&xdr, &msglen)) {
|
||||||
virNetError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
|
virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
xdr_destroy(&xdr);
|
xdr_destroy(&xdr);
|
||||||
@ -452,7 +449,7 @@ int virNetMessageEncodePayloadEmpty(virNetMessagePtr msg)
|
|||||||
xdrmem_create(&xdr, msg->buffer, VIR_NET_MESSAGE_HEADER_XDR_LEN, XDR_ENCODE);
|
xdrmem_create(&xdr, msg->buffer, VIR_NET_MESSAGE_HEADER_XDR_LEN, XDR_ENCODE);
|
||||||
msglen = msg->bufferOffset;
|
msglen = msg->bufferOffset;
|
||||||
if (!xdr_u_int(&xdr, &msglen)) {
|
if (!xdr_u_int(&xdr, &msglen)) {
|
||||||
virNetError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
|
virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
xdr_destroy(&xdr);
|
xdr_destroy(&xdr);
|
||||||
@ -508,7 +505,7 @@ int virNetMessageDupFD(virNetMessagePtr msg,
|
|||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if (slot >= msg->nfds) {
|
if (slot >= msg->nfds) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("No FD available at slot %zu"), slot);
|
_("No FD available at slot %zu"), slot);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,6 @@
|
|||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_RPC
|
#define VIR_FROM_THIS VIR_FROM_RPC
|
||||||
#define virNetError(code, ...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
|
||||||
|
|
||||||
|
|
||||||
struct _virNetSASLContext {
|
struct _virNetSASLContext {
|
||||||
virMutex lock;
|
virMutex lock;
|
||||||
@ -57,7 +53,7 @@ virNetSASLContextPtr virNetSASLContextNewClient(void)
|
|||||||
|
|
||||||
err = sasl_client_init(NULL);
|
err = sasl_client_init(NULL);
|
||||||
if (err != SASL_OK) {
|
if (err != SASL_OK) {
|
||||||
virNetError(VIR_ERR_AUTH_FAILED,
|
virReportError(VIR_ERR_AUTH_FAILED,
|
||||||
_("failed to initialize SASL library: %d (%s)"),
|
_("failed to initialize SASL library: %d (%s)"),
|
||||||
err, sasl_errstring(err, NULL, NULL));
|
err, sasl_errstring(err, NULL, NULL));
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -69,7 +65,7 @@ virNetSASLContextPtr virNetSASLContextNewClient(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virMutexInit(&ctxt->lock) < 0) {
|
if (virMutexInit(&ctxt->lock) < 0) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Failed to initialized mutex"));
|
_("Failed to initialized mutex"));
|
||||||
VIR_FREE(ctxt);
|
VIR_FREE(ctxt);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -87,7 +83,7 @@ virNetSASLContextPtr virNetSASLContextNewServer(const char *const*usernameWhitel
|
|||||||
|
|
||||||
err = sasl_server_init(NULL, "libvirt");
|
err = sasl_server_init(NULL, "libvirt");
|
||||||
if (err != SASL_OK) {
|
if (err != SASL_OK) {
|
||||||
virNetError(VIR_ERR_AUTH_FAILED,
|
virReportError(VIR_ERR_AUTH_FAILED,
|
||||||
_("failed to initialize SASL library: %d (%s)"),
|
_("failed to initialize SASL library: %d (%s)"),
|
||||||
err, sasl_errstring(err, NULL, NULL));
|
err, sasl_errstring(err, NULL, NULL));
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -99,7 +95,7 @@ virNetSASLContextPtr virNetSASLContextNewServer(const char *const*usernameWhitel
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virMutexInit(&ctxt->lock) < 0) {
|
if (virMutexInit(&ctxt->lock) < 0) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Failed to initialized mutex"));
|
_("Failed to initialized mutex"));
|
||||||
VIR_FREE(ctxt);
|
VIR_FREE(ctxt);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -133,7 +129,7 @@ int virNetSASLContextCheckIdentity(virNetSASLContextPtr ctxt,
|
|||||||
goto cleanup; /* Succesful match */
|
goto cleanup; /* Succesful match */
|
||||||
}
|
}
|
||||||
if (rv != FNM_NOMATCH) {
|
if (rv != FNM_NOMATCH) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Malformed TLS whitelist regular expression '%s'"),
|
_("Malformed TLS whitelist regular expression '%s'"),
|
||||||
*wildcards);
|
*wildcards);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -146,7 +142,7 @@ int virNetSASLContextCheckIdentity(virNetSASLContextPtr ctxt,
|
|||||||
VIR_ERROR(_("SASL client %s not allowed in whitelist"), identity);
|
VIR_ERROR(_("SASL client %s not allowed in whitelist"), identity);
|
||||||
|
|
||||||
/* This is the most common error: make it informative. */
|
/* This is the most common error: make it informative. */
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
|
virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
|
||||||
_("Client's username is not on the list of allowed clients"));
|
_("Client's username is not on the list of allowed clients"));
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
@ -196,7 +192,7 @@ virNetSASLSessionPtr virNetSASLSessionNewClient(virNetSASLContextPtr ctxt ATTRIB
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virMutexInit(&sasl->lock) < 0) {
|
if (virMutexInit(&sasl->lock) < 0) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Failed to initialized mutex"));
|
_("Failed to initialized mutex"));
|
||||||
VIR_FREE(sasl);
|
VIR_FREE(sasl);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -214,7 +210,7 @@ virNetSASLSessionPtr virNetSASLSessionNewClient(virNetSASLContextPtr ctxt ATTRIB
|
|||||||
SASL_SUCCESS_DATA,
|
SASL_SUCCESS_DATA,
|
||||||
&sasl->conn);
|
&sasl->conn);
|
||||||
if (err != SASL_OK) {
|
if (err != SASL_OK) {
|
||||||
virNetError(VIR_ERR_AUTH_FAILED,
|
virReportError(VIR_ERR_AUTH_FAILED,
|
||||||
_("Failed to create SASL client context: %d (%s)"),
|
_("Failed to create SASL client context: %d (%s)"),
|
||||||
err, sasl_errstring(err, NULL, NULL));
|
err, sasl_errstring(err, NULL, NULL));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -241,7 +237,7 @@ virNetSASLSessionPtr virNetSASLSessionNewServer(virNetSASLContextPtr ctxt ATTRIB
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virMutexInit(&sasl->lock) < 0) {
|
if (virMutexInit(&sasl->lock) < 0) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Failed to initialized mutex"));
|
_("Failed to initialized mutex"));
|
||||||
VIR_FREE(sasl);
|
VIR_FREE(sasl);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -260,7 +256,7 @@ virNetSASLSessionPtr virNetSASLSessionNewServer(virNetSASLContextPtr ctxt ATTRIB
|
|||||||
SASL_SUCCESS_DATA,
|
SASL_SUCCESS_DATA,
|
||||||
&sasl->conn);
|
&sasl->conn);
|
||||||
if (err != SASL_OK) {
|
if (err != SASL_OK) {
|
||||||
virNetError(VIR_ERR_AUTH_FAILED,
|
virReportError(VIR_ERR_AUTH_FAILED,
|
||||||
_("Failed to create SASL client context: %d (%s)"),
|
_("Failed to create SASL client context: %d (%s)"),
|
||||||
err, sasl_errstring(err, NULL, NULL));
|
err, sasl_errstring(err, NULL, NULL));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -289,7 +285,7 @@ int virNetSASLSessionExtKeySize(virNetSASLSessionPtr sasl,
|
|||||||
|
|
||||||
err = sasl_setprop(sasl->conn, SASL_SSF_EXTERNAL, &ssf);
|
err = sasl_setprop(sasl->conn, SASL_SSF_EXTERNAL, &ssf);
|
||||||
if (err != SASL_OK) {
|
if (err != SASL_OK) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("cannot set external SSF %d (%s)"),
|
_("cannot set external SSF %d (%s)"),
|
||||||
err, sasl_errstring(err, NULL, NULL));
|
err, sasl_errstring(err, NULL, NULL));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -310,14 +306,14 @@ const char *virNetSASLSessionGetIdentity(virNetSASLSessionPtr sasl)
|
|||||||
|
|
||||||
err = sasl_getprop(sasl->conn, SASL_USERNAME, &val);
|
err = sasl_getprop(sasl->conn, SASL_USERNAME, &val);
|
||||||
if (err != SASL_OK) {
|
if (err != SASL_OK) {
|
||||||
virNetError(VIR_ERR_AUTH_FAILED,
|
virReportError(VIR_ERR_AUTH_FAILED,
|
||||||
_("cannot query SASL username on connection %d (%s)"),
|
_("cannot query SASL username on connection %d (%s)"),
|
||||||
err, sasl_errstring(err, NULL, NULL));
|
err, sasl_errstring(err, NULL, NULL));
|
||||||
val = NULL;
|
val = NULL;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (val == NULL) {
|
if (val == NULL) {
|
||||||
virNetError(VIR_ERR_AUTH_FAILED,
|
virReportError(VIR_ERR_AUTH_FAILED,
|
||||||
_("no client username was found"));
|
_("no client username was found"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -338,7 +334,7 @@ int virNetSASLSessionGetKeySize(virNetSASLSessionPtr sasl)
|
|||||||
virMutexLock(&sasl->lock);
|
virMutexLock(&sasl->lock);
|
||||||
err = sasl_getprop(sasl->conn, SASL_SSF, &val);
|
err = sasl_getprop(sasl->conn, SASL_SSF, &val);
|
||||||
if (err != SASL_OK) {
|
if (err != SASL_OK) {
|
||||||
virNetError(VIR_ERR_AUTH_FAILED,
|
virReportError(VIR_ERR_AUTH_FAILED,
|
||||||
_("cannot query SASL ssf on connection %d (%s)"),
|
_("cannot query SASL ssf on connection %d (%s)"),
|
||||||
err, sasl_errstring(err, NULL, NULL));
|
err, sasl_errstring(err, NULL, NULL));
|
||||||
ssf = -1;
|
ssf = -1;
|
||||||
@ -374,7 +370,7 @@ int virNetSASLSessionSecProps(virNetSASLSessionPtr sasl,
|
|||||||
|
|
||||||
err = sasl_setprop(sasl->conn, SASL_SEC_PROPS, &secprops);
|
err = sasl_setprop(sasl->conn, SASL_SEC_PROPS, &secprops);
|
||||||
if (err != SASL_OK) {
|
if (err != SASL_OK) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("cannot set security props %d (%s)"),
|
_("cannot set security props %d (%s)"),
|
||||||
err, sasl_errstring(err, NULL, NULL));
|
err, sasl_errstring(err, NULL, NULL));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -398,7 +394,7 @@ static int virNetSASLSessionUpdateBufSize(virNetSASLSessionPtr sasl)
|
|||||||
|
|
||||||
err = sasl_getprop(sasl->conn, SASL_MAXOUTBUF, &u.ptr);
|
err = sasl_getprop(sasl->conn, SASL_MAXOUTBUF, &u.ptr);
|
||||||
if (err != SASL_OK) {
|
if (err != SASL_OK) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("cannot get security props %d (%s)"),
|
_("cannot get security props %d (%s)"),
|
||||||
err, sasl_errstring(err, NULL, NULL));
|
err, sasl_errstring(err, NULL, NULL));
|
||||||
return -1;
|
return -1;
|
||||||
@ -426,7 +422,7 @@ char *virNetSASLSessionListMechanisms(virNetSASLSessionPtr sasl)
|
|||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
if (err != SASL_OK) {
|
if (err != SASL_OK) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("cannot list SASL mechanisms %d (%s)"),
|
_("cannot list SASL mechanisms %d (%s)"),
|
||||||
err, sasl_errdetail(sasl->conn));
|
err, sasl_errdetail(sasl->conn));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -479,7 +475,7 @@ int virNetSASLSessionClientStart(virNetSASLSessionPtr sasl,
|
|||||||
ret = VIR_NET_SASL_INTERACT;
|
ret = VIR_NET_SASL_INTERACT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
virNetError(VIR_ERR_AUTH_FAILED,
|
virReportError(VIR_ERR_AUTH_FAILED,
|
||||||
_("Failed to start SASL negotiation: %d (%s)"),
|
_("Failed to start SASL negotiation: %d (%s)"),
|
||||||
err, sasl_errdetail(sasl->conn));
|
err, sasl_errdetail(sasl->conn));
|
||||||
break;
|
break;
|
||||||
@ -528,7 +524,7 @@ int virNetSASLSessionClientStep(virNetSASLSessionPtr sasl,
|
|||||||
ret = VIR_NET_SASL_INTERACT;
|
ret = VIR_NET_SASL_INTERACT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
virNetError(VIR_ERR_AUTH_FAILED,
|
virReportError(VIR_ERR_AUTH_FAILED,
|
||||||
_("Failed to step SASL negotiation: %d (%s)"),
|
_("Failed to step SASL negotiation: %d (%s)"),
|
||||||
err, sasl_errdetail(sasl->conn));
|
err, sasl_errdetail(sasl->conn));
|
||||||
break;
|
break;
|
||||||
@ -574,7 +570,7 @@ int virNetSASLSessionServerStart(virNetSASLSessionPtr sasl,
|
|||||||
ret = VIR_NET_SASL_INTERACT;
|
ret = VIR_NET_SASL_INTERACT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
virNetError(VIR_ERR_AUTH_FAILED,
|
virReportError(VIR_ERR_AUTH_FAILED,
|
||||||
_("Failed to start SASL negotiation: %d (%s)"),
|
_("Failed to start SASL negotiation: %d (%s)"),
|
||||||
err, sasl_errdetail(sasl->conn));
|
err, sasl_errdetail(sasl->conn));
|
||||||
break;
|
break;
|
||||||
@ -619,7 +615,7 @@ int virNetSASLSessionServerStep(virNetSASLSessionPtr sasl,
|
|||||||
ret = VIR_NET_SASL_INTERACT;
|
ret = VIR_NET_SASL_INTERACT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
virNetError(VIR_ERR_AUTH_FAILED,
|
virReportError(VIR_ERR_AUTH_FAILED,
|
||||||
_("Failed to start SASL negotiation: %d (%s)"),
|
_("Failed to start SASL negotiation: %d (%s)"),
|
||||||
err, sasl_errdetail(sasl->conn));
|
err, sasl_errdetail(sasl->conn));
|
||||||
break;
|
break;
|
||||||
@ -666,7 +662,7 @@ ssize_t virNetSASLSessionEncode(virNetSASLSessionPtr sasl,
|
|||||||
*outputlen = outlen;
|
*outputlen = outlen;
|
||||||
|
|
||||||
if (err != SASL_OK) {
|
if (err != SASL_OK) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("failed to encode SASL data: %d (%s)"),
|
_("failed to encode SASL data: %d (%s)"),
|
||||||
err, sasl_errstring(err, NULL, NULL));
|
err, sasl_errstring(err, NULL, NULL));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -704,7 +700,7 @@ ssize_t virNetSASLSessionDecode(virNetSASLSessionPtr sasl,
|
|||||||
&outlen);
|
&outlen);
|
||||||
*outputlen = outlen;
|
*outputlen = outlen;
|
||||||
if (err != SASL_OK) {
|
if (err != SASL_OK) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("failed to decode SASL data: %d (%s)"),
|
_("failed to decode SASL data: %d (%s)"),
|
||||||
err, sasl_errstring(err, NULL, NULL));
|
err, sasl_errstring(err, NULL, NULL));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -45,9 +45,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_RPC
|
#define VIR_FROM_THIS VIR_FROM_RPC
|
||||||
#define virNetError(code, ...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
|
||||||
|
|
||||||
typedef struct _virNetServerSignal virNetServerSignal;
|
typedef struct _virNetServerSignal virNetServerSignal;
|
||||||
typedef virNetServerSignal *virNetServerSignalPtr;
|
typedef virNetServerSignal *virNetServerSignalPtr;
|
||||||
@ -261,7 +258,7 @@ static int virNetServerDispatchNewClient(virNetServerServicePtr svc ATTRIBUTE_UN
|
|||||||
virNetServerLock(srv);
|
virNetServerLock(srv);
|
||||||
|
|
||||||
if (srv->nclients >= srv->nclients_max) {
|
if (srv->nclients >= srv->nclients_max) {
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
_("Too many active clients (%zu), dropping connection from %s"),
|
_("Too many active clients (%zu), dropping connection from %s"),
|
||||||
srv->nclients_max, virNetServerClientRemoteAddrString(client));
|
srv->nclients_max, virNetServerClientRemoteAddrString(client));
|
||||||
goto error;
|
goto error;
|
||||||
@ -378,7 +375,7 @@ virNetServerPtr virNetServerNew(size_t min_workers,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (virMutexInit(&srv->lock) < 0) {
|
if (virMutexInit(&srv->lock) < 0) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("cannot initialize mutex"));
|
_("cannot initialize mutex"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -507,7 +504,7 @@ virNetServerSignalEvent(int watch,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unexpected signal received: %d"), siginfo.si_signo);
|
_("Unexpected signal received: %d"), siginfo.si_signo);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -531,7 +528,7 @@ static int virNetServerSignalSetup(virNetServerPtr srv)
|
|||||||
VIR_EVENT_HANDLE_READABLE,
|
VIR_EVENT_HANDLE_READABLE,
|
||||||
virNetServerSignalEvent,
|
virNetServerSignalEvent,
|
||||||
srv, NULL)) < 0) {
|
srv, NULL)) < 0) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Failed to add signal handle watch"));
|
_("Failed to add signal handle watch"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -707,7 +704,7 @@ void virNetServerRun(virNetServerPtr srv)
|
|||||||
(timerid = virEventAddTimeout(-1,
|
(timerid = virEventAddTimeout(-1,
|
||||||
virNetServerAutoShutdownTimer,
|
virNetServerAutoShutdownTimer,
|
||||||
srv, NULL)) < 0) {
|
srv, NULL)) < 0) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Failed to register shutdown timeout"));
|
_("Failed to register shutdown timeout"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,6 @@
|
|||||||
#include "virkeepalive.h"
|
#include "virkeepalive.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_RPC
|
#define VIR_FROM_THIS VIR_FROM_RPC
|
||||||
#define virNetError(code, ...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
|
||||||
|
|
||||||
/* Allow for filtering of incoming messages to a custom
|
/* Allow for filtering of incoming messages to a custom
|
||||||
* dispatch processing queue, instead of the workers.
|
* dispatch processing queue, instead of the workers.
|
||||||
@ -775,7 +772,7 @@ static ssize_t virNetServerClientRead(virNetServerClientPtr client)
|
|||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
if (client->rx->bufferLength <= client->rx->bufferOffset) {
|
if (client->rx->bufferLength <= client->rx->bufferOffset) {
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
_("unexpected zero/negative length request %lld"),
|
_("unexpected zero/negative length request %lld"),
|
||||||
(long long int)(client->rx->bufferLength - client->rx->bufferOffset));
|
(long long int)(client->rx->bufferLength - client->rx->bufferOffset));
|
||||||
client->wantClose = true;
|
client->wantClose = true;
|
||||||
@ -953,7 +950,7 @@ static ssize_t virNetServerClientWrite(virNetServerClientPtr client)
|
|||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
if (client->tx->bufferLength < client->tx->bufferOffset) {
|
if (client->tx->bufferLength < client->tx->bufferOffset) {
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
_("unexpected zero/negative length request %lld"),
|
_("unexpected zero/negative length request %lld"),
|
||||||
(long long int)(client->tx->bufferLength - client->tx->bufferOffset));
|
(long long int)(client->tx->bufferLength - client->tx->bufferOffset));
|
||||||
client->wantClose = true;
|
client->wantClose = true;
|
||||||
|
@ -46,9 +46,6 @@
|
|||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_RPC
|
#define VIR_FROM_THIS VIR_FROM_RPC
|
||||||
#define virNetError(code, ...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
|
||||||
|
|
||||||
struct _virNetServerMDNSEntry {
|
struct _virNetServerMDNSEntry {
|
||||||
char *type;
|
char *type;
|
||||||
@ -285,7 +282,7 @@ static AvahiWatch *virNetServerMDNSWatchNew(const AvahiPoll *api ATTRIBUTE_UNUSE
|
|||||||
virNetServerMDNSWatchDispatch,
|
virNetServerMDNSWatchDispatch,
|
||||||
w,
|
w,
|
||||||
virNetServerMDNSWatchDofree)) < 0) {
|
virNetServerMDNSWatchDofree)) < 0) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Failed to add watch for fd %d events %d"), fd, hEvents);
|
_("Failed to add watch for fd %d events %d"), fd, hEvents);
|
||||||
VIR_FREE(w);
|
VIR_FREE(w);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -367,7 +364,7 @@ static AvahiTimeout *virNetServerMDNSTimeoutNew(const AvahiPoll *api ATTRIBUTE_U
|
|||||||
t->userdata = userdata;
|
t->userdata = userdata;
|
||||||
|
|
||||||
if (t->timer < 0) {
|
if (t->timer < 0) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Failed to add timer with timeout %lld"), timeout);
|
_("Failed to add timer with timeout %lld"), timeout);
|
||||||
VIR_FREE(t);
|
VIR_FREE(t);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -455,7 +452,7 @@ int virNetServerMDNSStart(virNetServerMDNS *mdns)
|
|||||||
mdns, &error);
|
mdns, &error);
|
||||||
|
|
||||||
if (!mdns->client) {
|
if (!mdns->client) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Failed to create mDNS client: %s"),
|
_("Failed to create mDNS client: %s"),
|
||||||
avahi_strerror(error));
|
avahi_strerror(error));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -32,9 +32,6 @@
|
|||||||
#include "virfile.h"
|
#include "virfile.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_RPC
|
#define VIR_FROM_THIS VIR_FROM_RPC
|
||||||
#define virNetError(code, ...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
|
||||||
|
|
||||||
struct _virNetServerProgram {
|
struct _virNetServerProgram {
|
||||||
int refs;
|
int refs;
|
||||||
@ -218,7 +215,7 @@ int virNetServerProgramUnknownError(virNetServerClientPtr client,
|
|||||||
{
|
{
|
||||||
virNetMessageError rerr;
|
virNetMessageError rerr;
|
||||||
|
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
_("Cannot find program %d version %d"), req->prog, req->vers);
|
_("Cannot find program %d version %d"), req->prog, req->vers);
|
||||||
|
|
||||||
memset(&rerr, 0, sizeof(rerr));
|
memset(&rerr, 0, sizeof(rerr));
|
||||||
@ -270,14 +267,14 @@ int virNetServerProgramDispatch(virNetServerProgramPtr prog,
|
|||||||
|
|
||||||
/* Check version, etc. */
|
/* Check version, etc. */
|
||||||
if (msg->header.prog != prog->program) {
|
if (msg->header.prog != prog->program) {
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
_("program mismatch (actual %x, expected %x)"),
|
_("program mismatch (actual %x, expected %x)"),
|
||||||
msg->header.prog, prog->program);
|
msg->header.prog, prog->program);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg->header.vers != prog->version) {
|
if (msg->header.vers != prog->version) {
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
_("version mismatch (actual %x, expected %x)"),
|
_("version mismatch (actual %x, expected %x)"),
|
||||||
msg->header.vers, prog->version);
|
msg->header.vers, prog->version);
|
||||||
goto error;
|
goto error;
|
||||||
@ -307,7 +304,7 @@ int virNetServerProgramDispatch(virNetServerProgramPtr prog,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
_("Unexpected message type %u"),
|
_("Unexpected message type %u"),
|
||||||
msg->header.type);
|
msg->header.type);
|
||||||
goto error;
|
goto error;
|
||||||
@ -363,7 +360,7 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
|
|||||||
memset(&rerr, 0, sizeof(rerr));
|
memset(&rerr, 0, sizeof(rerr));
|
||||||
|
|
||||||
if (msg->header.status != VIR_NET_OK) {
|
if (msg->header.status != VIR_NET_OK) {
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
_("Unexpected message status %u"),
|
_("Unexpected message status %u"),
|
||||||
msg->header.status);
|
msg->header.status);
|
||||||
goto error;
|
goto error;
|
||||||
@ -372,7 +369,7 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
|
|||||||
dispatcher = virNetServerProgramGetProc(prog, msg->header.proc);
|
dispatcher = virNetServerProgramGetProc(prog, msg->header.proc);
|
||||||
|
|
||||||
if (!dispatcher) {
|
if (!dispatcher) {
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
_("unknown procedure: %d"),
|
_("unknown procedure: %d"),
|
||||||
msg->header.proc);
|
msg->header.proc);
|
||||||
goto error;
|
goto error;
|
||||||
@ -386,7 +383,7 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
|
|||||||
/* Explicitly *NOT* calling remoteDispatchAuthError() because
|
/* Explicitly *NOT* calling remoteDispatchAuthError() because
|
||||||
we want back-compatibility with libvirt clients which don't
|
we want back-compatibility with libvirt clients which don't
|
||||||
support the VIR_ERR_AUTH_FAILED error code */
|
support the VIR_ERR_AUTH_FAILED error code */
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
"%s", _("authentication required"));
|
"%s", _("authentication required"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -48,10 +48,6 @@
|
|||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_RPC
|
#define VIR_FROM_THIS VIR_FROM_RPC
|
||||||
|
|
||||||
#define virNetError(code, ...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
|
||||||
|
|
||||||
|
|
||||||
struct _virNetSocket {
|
struct _virNetSocket {
|
||||||
virMutex lock;
|
virMutex lock;
|
||||||
@ -212,7 +208,7 @@ int virNetSocketNewListenTCP(const char *nodename,
|
|||||||
|
|
||||||
int e = getaddrinfo(nodename, service, &hints, &ai);
|
int e = getaddrinfo(nodename, service, &hints, &ai);
|
||||||
if (e != 0) {
|
if (e != 0) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Unable to resolve address '%s' service '%s': %s"),
|
_("Unable to resolve address '%s' service '%s': %s"),
|
||||||
nodename, service, gai_strerror(e));
|
nodename, service, gai_strerror(e));
|
||||||
return -1;
|
return -1;
|
||||||
@ -409,7 +405,7 @@ int virNetSocketNewConnectTCP(const char *nodename,
|
|||||||
|
|
||||||
int e = getaddrinfo(nodename, service, &hints, &ai);
|
int e = getaddrinfo(nodename, service, &hints, &ai);
|
||||||
if (e != 0) {
|
if (e != 0) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Unable to resolve address '%s' service '%s': %s"),
|
_("Unable to resolve address '%s' service '%s': %s"),
|
||||||
nodename, service, gai_strerror (e));
|
nodename, service, gai_strerror (e));
|
||||||
return -1;
|
return -1;
|
||||||
@ -485,7 +481,7 @@ int virNetSocketNewConnectUNIX(const char *path,
|
|||||||
remoteAddr.len = sizeof(remoteAddr.data.un);
|
remoteAddr.len = sizeof(remoteAddr.data.un);
|
||||||
|
|
||||||
if (spawnDaemon && !binary) {
|
if (spawnDaemon && !binary) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Auto-spawn of daemon requested, but no binary specified"));
|
_("Auto-spawn of daemon requested, but no binary specified"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1180,7 +1176,7 @@ int virNetSocketSendFD(virNetSocketPtr sock, int fd)
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
if (!virNetSocketHasPassFD(sock)) {
|
if (!virNetSocketHasPassFD(sock)) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Sending file descriptors is not supported on this socket"));
|
_("Sending file descriptors is not supported on this socket"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1214,7 +1210,7 @@ int virNetSocketRecvFD(virNetSocketPtr sock, int *fd)
|
|||||||
*fd = -1;
|
*fd = -1;
|
||||||
|
|
||||||
if (!virNetSocketHasPassFD(sock)) {
|
if (!virNetSocketHasPassFD(sock)) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Receiving file descriptors is not supported on this socket"));
|
_("Receiving file descriptors is not supported on this socket"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,6 @@
|
|||||||
#define LIBVIRT_SERVERCERT LIBVIRT_PKI_DIR "/libvirt/servercert.pem"
|
#define LIBVIRT_SERVERCERT LIBVIRT_PKI_DIR "/libvirt/servercert.pem"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_RPC
|
#define VIR_FROM_THIS VIR_FROM_RPC
|
||||||
#define virNetError(code, ...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
|
||||||
|
|
||||||
struct _virNetTLSContext {
|
struct _virNetTLSContext {
|
||||||
virMutex lock;
|
virMutex lock;
|
||||||
@ -116,7 +113,7 @@ static int virNetTLSContextCheckCertTimes(gnutls_x509_crt_t cert,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (gnutls_x509_crt_get_expiration_time(cert) < now) {
|
if (gnutls_x509_crt_get_expiration_time(cert) < now) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
(isCA ?
|
(isCA ?
|
||||||
_("The CA certificate %s has expired") :
|
_("The CA certificate %s has expired") :
|
||||||
(isServer ?
|
(isServer ?
|
||||||
@ -127,7 +124,7 @@ static int virNetTLSContextCheckCertTimes(gnutls_x509_crt_t cert,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (gnutls_x509_crt_get_activation_time(cert) > now) {
|
if (gnutls_x509_crt_get_activation_time(cert) > now) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
(isCA ?
|
(isCA ?
|
||||||
_("The CA certificate %s is not yet active") :
|
_("The CA certificate %s is not yet active") :
|
||||||
(isServer ?
|
(isServer ?
|
||||||
@ -161,7 +158,7 @@ static int virNetTLSContextCheckCertBasicConstraints(gnutls_x509_crt_t cert,
|
|||||||
|
|
||||||
if (status > 0) { /* It is a CA cert */
|
if (status > 0) { /* It is a CA cert */
|
||||||
if (!isCA) {
|
if (!isCA) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR, isServer ?
|
virReportError(VIR_ERR_SYSTEM_ERROR, isServer ?
|
||||||
_("The certificate %s basic constraints show a CA, but we need one for a server") :
|
_("The certificate %s basic constraints show a CA, but we need one for a server") :
|
||||||
_("The certificate %s basic constraints show a CA, but we need one for a client"),
|
_("The certificate %s basic constraints show a CA, but we need one for a client"),
|
||||||
certFile);
|
certFile);
|
||||||
@ -169,20 +166,20 @@ static int virNetTLSContextCheckCertBasicConstraints(gnutls_x509_crt_t cert,
|
|||||||
}
|
}
|
||||||
} else if (status == 0) { /* It is not a CA cert */
|
} else if (status == 0) { /* It is not a CA cert */
|
||||||
if (isCA) {
|
if (isCA) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("The certificate %s basic constraints do not show a CA"),
|
_("The certificate %s basic constraints do not show a CA"),
|
||||||
certFile);
|
certFile);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (status == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) { /* Missing basicConstraints */
|
} else if (status == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) { /* Missing basicConstraints */
|
||||||
if (isCA) {
|
if (isCA) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("The certificate %s is missing basic constraints for a CA"),
|
_("The certificate %s is missing basic constraints for a CA"),
|
||||||
certFile);
|
certFile);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else { /* General error */
|
} else { /* General error */
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Unable to query certificate %s basic constraints %s"),
|
_("Unable to query certificate %s basic constraints %s"),
|
||||||
certFile, gnutls_strerror(status));
|
certFile, gnutls_strerror(status));
|
||||||
return -1;
|
return -1;
|
||||||
@ -209,7 +206,7 @@ static int virNetTLSContextCheckCertKeyUsage(gnutls_x509_crt_t cert,
|
|||||||
usage = isCA ? GNUTLS_KEY_KEY_CERT_SIGN :
|
usage = isCA ? GNUTLS_KEY_KEY_CERT_SIGN :
|
||||||
GNUTLS_KEY_DIGITAL_SIGNATURE|GNUTLS_KEY_KEY_ENCIPHERMENT;
|
GNUTLS_KEY_DIGITAL_SIGNATURE|GNUTLS_KEY_KEY_ENCIPHERMENT;
|
||||||
} else {
|
} else {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Unable to query certificate %s key usage %s"),
|
_("Unable to query certificate %s key usage %s"),
|
||||||
certFile, gnutls_strerror(status));
|
certFile, gnutls_strerror(status));
|
||||||
return -1;
|
return -1;
|
||||||
@ -219,7 +216,7 @@ static int virNetTLSContextCheckCertKeyUsage(gnutls_x509_crt_t cert,
|
|||||||
if (isCA) {
|
if (isCA) {
|
||||||
if (!(usage & GNUTLS_KEY_KEY_CERT_SIGN)) {
|
if (!(usage & GNUTLS_KEY_KEY_CERT_SIGN)) {
|
||||||
if (critical) {
|
if (critical) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Certificate %s usage does not permit certificate signing"),
|
_("Certificate %s usage does not permit certificate signing"),
|
||||||
certFile);
|
certFile);
|
||||||
return -1;
|
return -1;
|
||||||
@ -231,7 +228,7 @@ static int virNetTLSContextCheckCertKeyUsage(gnutls_x509_crt_t cert,
|
|||||||
} else {
|
} else {
|
||||||
if (!(usage & GNUTLS_KEY_DIGITAL_SIGNATURE)) {
|
if (!(usage & GNUTLS_KEY_DIGITAL_SIGNATURE)) {
|
||||||
if (critical) {
|
if (critical) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Certificate %s usage does not permit digital signature"),
|
_("Certificate %s usage does not permit digital signature"),
|
||||||
certFile);
|
certFile);
|
||||||
return -1;
|
return -1;
|
||||||
@ -242,7 +239,7 @@ static int virNetTLSContextCheckCertKeyUsage(gnutls_x509_crt_t cert,
|
|||||||
}
|
}
|
||||||
if (!(usage & GNUTLS_KEY_KEY_ENCIPHERMENT)) {
|
if (!(usage & GNUTLS_KEY_KEY_ENCIPHERMENT)) {
|
||||||
if (critical) {
|
if (critical) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Certificate %s usage does not permit key encipherment"),
|
_("Certificate %s usage does not permit key encipherment"),
|
||||||
certFile);
|
certFile);
|
||||||
return -1;
|
return -1;
|
||||||
@ -283,7 +280,7 @@ static int virNetTLSContextCheckCertKeyPurpose(gnutls_x509_crt_t cert,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (status != GNUTLS_E_SHORT_MEMORY_BUFFER) {
|
if (status != GNUTLS_E_SHORT_MEMORY_BUFFER) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Unable to query certificate %s key purpose %s"),
|
_("Unable to query certificate %s key purpose %s"),
|
||||||
certFile, gnutls_strerror(status));
|
certFile, gnutls_strerror(status));
|
||||||
return -1;
|
return -1;
|
||||||
@ -297,7 +294,7 @@ static int virNetTLSContextCheckCertKeyPurpose(gnutls_x509_crt_t cert,
|
|||||||
status = gnutls_x509_crt_get_key_purpose_oid(cert, i, buffer, &size, &purposeCritical);
|
status = gnutls_x509_crt_get_key_purpose_oid(cert, i, buffer, &size, &purposeCritical);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
VIR_FREE(buffer);
|
VIR_FREE(buffer);
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Unable to query certificate %s key purpose %s"),
|
_("Unable to query certificate %s key purpose %s"),
|
||||||
certFile, gnutls_strerror(status));
|
certFile, gnutls_strerror(status));
|
||||||
return -1;
|
return -1;
|
||||||
@ -320,7 +317,7 @@ static int virNetTLSContextCheckCertKeyPurpose(gnutls_x509_crt_t cert,
|
|||||||
if (isServer) {
|
if (isServer) {
|
||||||
if (!allowServer) {
|
if (!allowServer) {
|
||||||
if (critical) {
|
if (critical) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Certificate %s purpose does not allow use for with a TLS server"),
|
_("Certificate %s purpose does not allow use for with a TLS server"),
|
||||||
certFile);
|
certFile);
|
||||||
return -1;
|
return -1;
|
||||||
@ -332,7 +329,7 @@ static int virNetTLSContextCheckCertKeyPurpose(gnutls_x509_crt_t cert,
|
|||||||
} else {
|
} else {
|
||||||
if (!allowClient) {
|
if (!allowClient) {
|
||||||
if (critical) {
|
if (critical) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Certificate %s purpose does not allow use for with a TLS client"),
|
_("Certificate %s purpose does not allow use for with a TLS client"),
|
||||||
certFile);
|
certFile);
|
||||||
return -1;
|
return -1;
|
||||||
@ -356,7 +353,7 @@ virNetTLSContextCheckCertDNWhitelist(const char *dname,
|
|||||||
if (ret == 0) /* Succesful match */
|
if (ret == 0) /* Succesful match */
|
||||||
return 1;
|
return 1;
|
||||||
if (ret != FNM_NOMATCH) {
|
if (ret != FNM_NOMATCH) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Malformed TLS whitelist regular expression '%s'"),
|
_("Malformed TLS whitelist regular expression '%s'"),
|
||||||
*wildcards);
|
*wildcards);
|
||||||
return -1;
|
return -1;
|
||||||
@ -369,7 +366,7 @@ virNetTLSContextCheckCertDNWhitelist(const char *dname,
|
|||||||
VIR_DEBUG("Failed whitelist check for client DN '%s'", dname);
|
VIR_DEBUG("Failed whitelist check for client DN '%s'", dname);
|
||||||
|
|
||||||
/* This is the most common error: make it informative. */
|
/* This is the most common error: make it informative. */
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
|
virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
|
||||||
_("Client's Distinguished Name is not on the list "
|
_("Client's Distinguished Name is not on the list "
|
||||||
"of allowed clients (tls_allowed_dn_list). Use "
|
"of allowed clients (tls_allowed_dn_list). Use "
|
||||||
"'certtool -i --infile clientcert.pem' to view the"
|
"'certtool -i --infile clientcert.pem' to view the"
|
||||||
@ -392,7 +389,7 @@ virNetTLSContextCheckCertDN(gnutls_x509_crt_t cert,
|
|||||||
|
|
||||||
if (hostname &&
|
if (hostname &&
|
||||||
!gnutls_x509_crt_check_hostname(cert, hostname)) {
|
!gnutls_x509_crt_check_hostname(cert, hostname)) {
|
||||||
virNetError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
_("Certificate %s owner does not match the hostname %s"),
|
_("Certificate %s owner does not match the hostname %s"),
|
||||||
certFile, hostname);
|
certFile, hostname);
|
||||||
return -1;
|
return -1;
|
||||||
@ -442,7 +439,7 @@ static int virNetTLSContextCheckCertPair(gnutls_x509_crt_t cert,
|
|||||||
&cacert, 1,
|
&cacert, 1,
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
0, &status) < 0) {
|
0, &status) < 0) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR, isServer ?
|
virReportError(VIR_ERR_SYSTEM_ERROR, isServer ?
|
||||||
_("Unable to verify server certificate %s against CA certificate %s") :
|
_("Unable to verify server certificate %s against CA certificate %s") :
|
||||||
_("Unable to verify client certificate %s against CA certificate %s"),
|
_("Unable to verify client certificate %s against CA certificate %s"),
|
||||||
certFile, cacertFile);
|
certFile, cacertFile);
|
||||||
@ -466,7 +463,7 @@ static int virNetTLSContextCheckCertPair(gnutls_x509_crt_t cert,
|
|||||||
reason = _("The certificate uses an insecure algorithm");
|
reason = _("The certificate uses an insecure algorithm");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Our own certificate %s failed validation against %s: %s"),
|
_("Our own certificate %s failed validation against %s: %s"),
|
||||||
certFile, cacertFile, reason);
|
certFile, cacertFile, reason);
|
||||||
return -1;
|
return -1;
|
||||||
@ -489,7 +486,7 @@ static gnutls_x509_crt_t virNetTLSContextLoadCertFromFile(const char *certFile,
|
|||||||
isServer, isCA, certFile);
|
isServer, isCA, certFile);
|
||||||
|
|
||||||
if (gnutls_x509_crt_init(&cert) < 0) {
|
if (gnutls_x509_crt_init(&cert) < 0) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
|
virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
|
||||||
_("Unable to initialize certificate"));
|
_("Unable to initialize certificate"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -501,7 +498,7 @@ static gnutls_x509_crt_t virNetTLSContextLoadCertFromFile(const char *certFile,
|
|||||||
data.size = strlen(buf);
|
data.size = strlen(buf);
|
||||||
|
|
||||||
if (gnutls_x509_crt_import(cert, &data, GNUTLS_X509_FMT_PEM) < 0) {
|
if (gnutls_x509_crt_import(cert, &data, GNUTLS_X509_FMT_PEM) < 0) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR, isServer ?
|
virReportError(VIR_ERR_SYSTEM_ERROR, isServer ?
|
||||||
_("Unable to import server certificate %s") :
|
_("Unable to import server certificate %s") :
|
||||||
_("Unable to import client certificate %s"),
|
_("Unable to import client certificate %s"),
|
||||||
certFile);
|
certFile);
|
||||||
@ -577,7 +574,7 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt,
|
|||||||
cacert,
|
cacert,
|
||||||
GNUTLS_X509_FMT_PEM);
|
GNUTLS_X509_FMT_PEM);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Unable to set x509 CA certificate: %s: %s"),
|
_("Unable to set x509 CA certificate: %s: %s"),
|
||||||
cacert, gnutls_strerror (err));
|
cacert, gnutls_strerror (err));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -595,7 +592,7 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt,
|
|||||||
cacrl,
|
cacrl,
|
||||||
GNUTLS_X509_FMT_PEM);
|
GNUTLS_X509_FMT_PEM);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Unable to set x509 certificate revocation list: %s: %s"),
|
_("Unable to set x509 certificate revocation list: %s: %s"),
|
||||||
cacrl, gnutls_strerror(err));
|
cacrl, gnutls_strerror(err));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -620,7 +617,7 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt,
|
|||||||
cert, key,
|
cert, key,
|
||||||
GNUTLS_X509_FMT_PEM);
|
GNUTLS_X509_FMT_PEM);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Unable to set x509 key and certificate: %s, %s: %s"),
|
_("Unable to set x509 key and certificate: %s, %s: %s"),
|
||||||
key, cert, gnutls_strerror(err));
|
key, cert, gnutls_strerror(err));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -656,7 +653,7 @@ static virNetTLSContextPtr virNetTLSContextNew(const char *cacert,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virMutexInit(&ctxt->lock) < 0) {
|
if (virMutexInit(&ctxt->lock) < 0) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Failed to initialized mutex"));
|
_("Failed to initialized mutex"));
|
||||||
VIR_FREE(ctxt);
|
VIR_FREE(ctxt);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -676,7 +673,7 @@ static virNetTLSContextPtr virNetTLSContextNew(const char *cacert,
|
|||||||
|
|
||||||
err = gnutls_certificate_allocate_credentials(&ctxt->x509cred);
|
err = gnutls_certificate_allocate_credentials(&ctxt->x509cred);
|
||||||
if (err) {
|
if (err) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Unable to allocate x509 credentials: %s"),
|
_("Unable to allocate x509 credentials: %s"),
|
||||||
gnutls_strerror(err));
|
gnutls_strerror(err));
|
||||||
goto error;
|
goto error;
|
||||||
@ -697,14 +694,14 @@ static virNetTLSContextPtr virNetTLSContextNew(const char *cacert,
|
|||||||
if (isServer) {
|
if (isServer) {
|
||||||
err = gnutls_dh_params_init(&ctxt->dhParams);
|
err = gnutls_dh_params_init(&ctxt->dhParams);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Unable to initialize diffie-hellman parameters: %s"),
|
_("Unable to initialize diffie-hellman parameters: %s"),
|
||||||
gnutls_strerror(err));
|
gnutls_strerror(err));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
err = gnutls_dh_params_generate2(ctxt->dhParams, DH_BITS);
|
err = gnutls_dh_params_generate2(ctxt->dhParams, DH_BITS);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Unable to generate diffie-hellman parameters: %s"),
|
_("Unable to generate diffie-hellman parameters: %s"),
|
||||||
gnutls_strerror(err));
|
gnutls_strerror(err));
|
||||||
goto error;
|
goto error;
|
||||||
@ -954,7 +951,7 @@ static int virNetTLSContextValidCertificate(virNetTLSContextPtr ctxt,
|
|||||||
memset(dname, 0, dnamesize);
|
memset(dname, 0, dnamesize);
|
||||||
|
|
||||||
if ((ret = gnutls_certificate_verify_peers2(sess->session, &status)) < 0){
|
if ((ret = gnutls_certificate_verify_peers2(sess->session, &status)) < 0){
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Unable to verify TLS peer: %s"),
|
_("Unable to verify TLS peer: %s"),
|
||||||
gnutls_strerror(ret));
|
gnutls_strerror(ret));
|
||||||
goto authdeny;
|
goto authdeny;
|
||||||
@ -977,20 +974,20 @@ static int virNetTLSContextValidCertificate(virNetTLSContextPtr ctxt,
|
|||||||
reason = _("The certificate uses an insecure algorithm");
|
reason = _("The certificate uses an insecure algorithm");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Certificate failed validation: %s"),
|
_("Certificate failed validation: %s"),
|
||||||
reason);
|
reason);
|
||||||
goto authdeny;
|
goto authdeny;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gnutls_certificate_type_get(sess->session) != GNUTLS_CRT_X509) {
|
if (gnutls_certificate_type_get(sess->session) != GNUTLS_CRT_X509) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
|
virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
|
||||||
_("Only x509 certificates are supported"));
|
_("Only x509 certificates are supported"));
|
||||||
goto authdeny;
|
goto authdeny;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(certs = gnutls_certificate_get_peers(sess->session, &nCerts))) {
|
if (!(certs = gnutls_certificate_get_peers(sess->session, &nCerts))) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
|
virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
|
||||||
_("The certificate has no peers"));
|
_("The certificate has no peers"));
|
||||||
goto authdeny;
|
goto authdeny;
|
||||||
}
|
}
|
||||||
@ -999,13 +996,13 @@ static int virNetTLSContextValidCertificate(virNetTLSContextPtr ctxt,
|
|||||||
gnutls_x509_crt_t cert;
|
gnutls_x509_crt_t cert;
|
||||||
|
|
||||||
if (gnutls_x509_crt_init(&cert) < 0) {
|
if (gnutls_x509_crt_init(&cert) < 0) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
|
virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
|
||||||
_("Unable to initialize certificate"));
|
_("Unable to initialize certificate"));
|
||||||
goto authfail;
|
goto authfail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gnutls_x509_crt_import(cert, &certs[i], GNUTLS_X509_FMT_DER) < 0) {
|
if (gnutls_x509_crt_import(cert, &certs[i], GNUTLS_X509_FMT_DER) < 0) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
|
virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
|
||||||
_("Unable to load certificate"));
|
_("Unable to load certificate"));
|
||||||
gnutls_x509_crt_deinit(cert);
|
gnutls_x509_crt_deinit(cert);
|
||||||
goto authfail;
|
goto authfail;
|
||||||
@ -1020,7 +1017,7 @@ static int virNetTLSContextValidCertificate(virNetTLSContextPtr ctxt,
|
|||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
ret = gnutls_x509_crt_get_dn(cert, dname, &dnamesize);
|
ret = gnutls_x509_crt_get_dn(cert, dname, &dnamesize);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Failed to get certificate %s distinguished name: %s"),
|
_("Failed to get certificate %s distinguished name: %s"),
|
||||||
"[session]", gnutls_strerror(ret));
|
"[session]", gnutls_strerror(ret));
|
||||||
goto authfail;
|
goto authfail;
|
||||||
@ -1092,7 +1089,7 @@ int virNetTLSContextCheckCertificate(virNetTLSContextPtr ctxt,
|
|||||||
virErrorPtr err = virGetLastError();
|
virErrorPtr err = virGetLastError();
|
||||||
VIR_WARN("Certificate check failed %s", err && err->message ? err->message : "<unknown>");
|
VIR_WARN("Certificate check failed %s", err && err->message ? err->message : "<unknown>");
|
||||||
if (ctxt->requireValidCert) {
|
if (ctxt->requireValidCert) {
|
||||||
virNetError(VIR_ERR_AUTH_FAILED, "%s",
|
virReportError(VIR_ERR_AUTH_FAILED, "%s",
|
||||||
_("Failed to verify peer's certificate"));
|
_("Failed to verify peer's certificate"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -1176,7 +1173,7 @@ virNetTLSSessionPtr virNetTLSSessionNew(virNetTLSContextPtr ctxt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virMutexInit(&sess->lock) < 0) {
|
if (virMutexInit(&sess->lock) < 0) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Failed to initialized mutex"));
|
_("Failed to initialized mutex"));
|
||||||
VIR_FREE(sess);
|
VIR_FREE(sess);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1191,7 +1188,7 @@ virNetTLSSessionPtr virNetTLSSessionNew(virNetTLSContextPtr ctxt,
|
|||||||
|
|
||||||
if ((err = gnutls_init(&sess->session,
|
if ((err = gnutls_init(&sess->session,
|
||||||
ctxt->isServer ? GNUTLS_SERVER : GNUTLS_CLIENT)) != 0) {
|
ctxt->isServer ? GNUTLS_SERVER : GNUTLS_CLIENT)) != 0) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Failed to initialize TLS session: %s"),
|
_("Failed to initialize TLS session: %s"),
|
||||||
gnutls_strerror(err));
|
gnutls_strerror(err));
|
||||||
goto error;
|
goto error;
|
||||||
@ -1201,7 +1198,7 @@ virNetTLSSessionPtr virNetTLSSessionNew(virNetTLSContextPtr ctxt,
|
|||||||
* are adequate.
|
* are adequate.
|
||||||
*/
|
*/
|
||||||
if ((err = gnutls_set_default_priority(sess->session)) != 0) {
|
if ((err = gnutls_set_default_priority(sess->session)) != 0) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Failed to set TLS session priority %s"),
|
_("Failed to set TLS session priority %s"),
|
||||||
gnutls_strerror(err));
|
gnutls_strerror(err));
|
||||||
goto error;
|
goto error;
|
||||||
@ -1210,7 +1207,7 @@ virNetTLSSessionPtr virNetTLSSessionNew(virNetTLSContextPtr ctxt,
|
|||||||
if ((err = gnutls_credentials_set(sess->session,
|
if ((err = gnutls_credentials_set(sess->session,
|
||||||
GNUTLS_CRD_CERTIFICATE,
|
GNUTLS_CRD_CERTIFICATE,
|
||||||
ctxt->x509cred)) != 0) {
|
ctxt->x509cred)) != 0) {
|
||||||
virNetError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Failed set TLS x509 credentials: %s"),
|
_("Failed set TLS x509 credentials: %s"),
|
||||||
gnutls_strerror(err));
|
gnutls_strerror(err));
|
||||||
goto error;
|
goto error;
|
||||||
@ -1352,7 +1349,7 @@ int virNetTLSSessionHandshake(virNetTLSSessionPtr sess)
|
|||||||
virNetServerClientGetFD(client));
|
virNetServerClientGetFD(client));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virNetError(VIR_ERR_AUTH_FAILED,
|
virReportError(VIR_ERR_AUTH_FAILED,
|
||||||
_("TLS handshake failed %s"),
|
_("TLS handshake failed %s"),
|
||||||
gnutls_strerror(ret));
|
gnutls_strerror(ret));
|
||||||
ret = -1;
|
ret = -1;
|
||||||
@ -1384,7 +1381,7 @@ int virNetTLSSessionGetKeySize(virNetTLSSessionPtr sess)
|
|||||||
virMutexLock(&sess->lock);
|
virMutexLock(&sess->lock);
|
||||||
cipher = gnutls_cipher_get(sess->session);
|
cipher = gnutls_cipher_get(sess->session);
|
||||||
if (!(ssf = gnutls_cipher_get_key_size(cipher))) {
|
if (!(ssf = gnutls_cipher_get_key_size(cipher))) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("invalid cipher size for TLS session"));
|
_("invalid cipher size for TLS session"));
|
||||||
ssf = -1;
|
ssf = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
Reference in New Issue
Block a user