#include "virkeepalive.h"
#define VIR_FROM_THIS VIR_FROM_RPC
-#define virNetError(code, ...) \
- virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
- __FUNCTION__, __LINE__, __VA_ARGS__)
struct _virKeepAlive {
int refs;
if (interval > 0) {
if (ka->interval > 0) {
- virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("keepalive interval already set"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("keepalive interval already set"));
goto cleanup;
}
ka->interval = interval;
#include "virterror_internal.h"
#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 virNetClientCall *virNetClientCallPtr;
goto error;
}
if (len != 1 || buf[0] != '\1') {
- virNetError(VIR_ERR_RPC, "%s",
- _("server verification (of our certificate or IP "
- "address) failed"));
+ virReportError(VIR_ERR_RPC, "%s",
+ _("server verification (of our certificate or IP "
+ "address) failed"));
goto error;
}
thecall = thecall->next;
if (!thecall) {
- virNetError(VIR_ERR_RPC,
- _("no call waiting for reply with prog %d vers %d serial %d"),
- client->msg.header.prog, client->msg.header.vers, client->msg.header.serial);
+ virReportError(VIR_ERR_RPC,
+ _("no call waiting for reply with prog %d vers %d serial %d"),
+ client->msg.header.prog, client->msg.header.vers, client->msg.header.serial);
return -1;
}
return virNetClientCallDispatchStream(client);
default:
- virNetError(VIR_ERR_RPC,
- _("got unexpected RPC call prog %d vers %d proc %d type %d"),
- client->msg.header.prog, client->msg.header.vers,
- client->msg.header.proc, client->msg.header.type);
+ virReportError(VIR_ERR_RPC,
+ _("got unexpected RPC call prog %d vers %d proc %d type %d"),
+ client->msg.header.prog, client->msg.header.vers,
+ client->msg.header.proc, client->msg.header.type);
return -1;
}
}
}
if (fds[0].revents & (POLLHUP | POLLERR)) {
- virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("received hangup / error event on socket"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("received hangup / error event on socket"));
goto error;
}
}
/* Go to sleep while other thread is working... */
if (virCondWait(&thiscall->cond, &client->lock) < 0) {
virNetClientCallRemove(&client->waitDispatch, thiscall);
- virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("failed to wait on condition"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("failed to wait on condition"));
return -1;
}
if (expectReply &&
(msg->bufferLength != 0) &&
(msg->header.status == VIR_NET_CONTINUE)) {
- virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Attempt to send an asynchronous message with"
- " a synchronous reply"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Attempt to send an asynchronous message with"
+ " a synchronous reply"));
goto error;
}
if (expectReply && nonBlock) {
- virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Attempt to send a non-blocking message with"
- " a synchronous reply"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Attempt to send a non-blocking message with"
+ " a synchronous reply"));
goto error;
}
}
if (virCondInit(&call->cond) < 0) {
- virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("cannot initialize condition variable"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("cannot initialize condition variable"));
goto error;
}
msg->header.type, msg->header.status, msg->header.serial);
if (!client->sock || client->wantClose) {
- virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("client socket is closed"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("client socket is closed"));
return -1;
}
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_RPC
-#define virNetError(code, ...) \
- virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
- __FUNCTION__, __LINE__, __VA_ARGS__)
struct _virNetClientProgram {
int refs;
*/
if (msg->header.type != VIR_NET_REPLY &&
msg->header.type != VIR_NET_REPLY_WITH_FDS) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("Unexpected message type %d"), msg->header.type);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected message type %d"), msg->header.type);
goto error;
}
if (msg->header.proc != proc) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("Unexpected message proc %d != %d"),
- msg->header.proc, proc);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected message proc %d != %d"),
+ msg->header.proc, proc);
goto error;
}
if (msg->header.serial != serial) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("Unexpected message serial %d != %d"),
- msg->header.serial, serial);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected message serial %d != %d"),
+ msg->header.serial, serial);
goto error;
}
goto error;
default:
- virNetError(VIR_ERR_RPC,
- _("Unexpected message status %d"), msg->header.status);
+ virReportError(VIR_ERR_RPC,
+ _("Unexpected message status %d"), msg->header.status);
goto error;
}
#include "threads.h"
#define VIR_FROM_THIS VIR_FROM_RPC
-#define virNetError(code, ...) \
- virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
- __FUNCTION__, __LINE__, __VA_ARGS__)
struct _virNetClientStream {
virMutex lock;
st->serial = serial;
if (virMutexInit(&st->lock) < 0) {
- virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("cannot initialize mutex"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("cannot initialize mutex"));
VIR_FREE(st);
return NULL;
}
virMutexLock(&st->lock);
if (st->cb) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("multiple stream callbacks not supported"));
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("multiple stream callbacks not supported"));
goto cleanup;
}
virMutexLock(&st->lock);
if (!st->cb) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("no stream callback registered"));
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("no stream callback registered"));
goto cleanup;
}
virMutexLock(&st->lock);
if (!st->cb) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("no stream callback registered"));
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("no stream callback registered"));
goto cleanup;
}
#include "util.h"
#define VIR_FROM_THIS VIR_FROM_RPC
-#define virNetError(code, ...) \
- virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
- __FUNCTION__, __LINE__, __VA_ARGS__)
virNetMessagePtr virNetMessageNew(bool tracked)
{
xdrmem_create(&xdr, msg->buffer,
msg->bufferLength, XDR_DECODE);
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;
}
msg->bufferOffset = xdr_getpos(&xdr);
if (len < VIR_NET_MESSAGE_LEN_MAX) {
- virNetError(VIR_ERR_RPC,
- _("packet %d bytes received from server too small, want %d"),
- len, VIR_NET_MESSAGE_LEN_MAX);
+ virReportError(VIR_ERR_RPC,
+ _("packet %d bytes received from server too small, want %d"),
+ len, VIR_NET_MESSAGE_LEN_MAX);
goto cleanup;
}
len -= VIR_NET_MESSAGE_LEN_MAX;
if (len > VIR_NET_MESSAGE_MAX) {
- virNetError(VIR_ERR_RPC,
- _("packet %d bytes received from server too large, want %d"),
- len, VIR_NET_MESSAGE_MAX);
+ virReportError(VIR_ERR_RPC,
+ _("packet %d bytes received from server too large, want %d"),
+ len, VIR_NET_MESSAGE_MAX);
goto cleanup;
}
XDR_DECODE);
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;
}
/* The real value is filled in shortly */
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;
}
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;
}
* if a payload is added
*/
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;
}
msg->bufferLength - msg->bufferOffset, XDR_ENCODE);
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"),
numFDs, VIR_NET_MESSAGE_NUM_FDS_MAX);
goto cleanup;
}
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;
}
msg->bufferOffset += xdr_getpos(&xdr);
xdrmem_create(&xdr, msg->buffer + msg->bufferOffset,
msg->bufferLength - msg->bufferOffset, XDR_DECODE);
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;
}
msg->bufferOffset += xdr_getpos(&xdr);
if (numFDs > VIR_NET_MESSAGE_NUM_FDS_MAX) {
- virNetError(VIR_ERR_RPC,
+ virReportError(VIR_ERR_RPC,
_("Received too many FDs %d, expected %d maximum"),
numFDs, VIR_NET_MESSAGE_NUM_FDS_MAX);
goto cleanup;
msg->bufferLength - msg->bufferOffset, XDR_ENCODE);
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;
}
xdrmem_create(&xdr, msg->buffer, VIR_NET_MESSAGE_HEADER_XDR_LEN, XDR_ENCODE);
msglen = msg->bufferOffset;
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;
}
xdr_destroy(&xdr);
msg->bufferLength - msg->bufferOffset, XDR_DECODE);
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;
}
unsigned int msglen;
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)"),
len, (msg->bufferLength - msg->bufferOffset));
return -1;
xdrmem_create(&xdr, msg->buffer, VIR_NET_MESSAGE_HEADER_XDR_LEN, XDR_ENCODE);
msglen = msg->bufferOffset;
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;
}
xdr_destroy(&xdr);
xdrmem_create(&xdr, msg->buffer, VIR_NET_MESSAGE_HEADER_XDR_LEN, XDR_ENCODE);
msglen = msg->bufferOffset;
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;
}
xdr_destroy(&xdr);
int fd;
if (slot >= msg->nfds) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("No FD available at slot %zu"), slot);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("No FD available at slot %zu"), slot);
return -1;
}
#include "logging.h"
#define VIR_FROM_THIS VIR_FROM_RPC
-#define virNetError(code, ...) \
- virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
- __FUNCTION__, __LINE__, __VA_ARGS__)
-
struct _virNetSASLContext {
virMutex lock;
err = sasl_client_init(NULL);
if (err != SASL_OK) {
- virNetError(VIR_ERR_AUTH_FAILED,
- _("failed to initialize SASL library: %d (%s)"),
- err, sasl_errstring(err, NULL, NULL));
+ virReportError(VIR_ERR_AUTH_FAILED,
+ _("failed to initialize SASL library: %d (%s)"),
+ err, sasl_errstring(err, NULL, NULL));
return NULL;
}
}
if (virMutexInit(&ctxt->lock) < 0) {
- virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to initialized mutex"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to initialized mutex"));
VIR_FREE(ctxt);
return NULL;
}
err = sasl_server_init(NULL, "libvirt");
if (err != SASL_OK) {
- virNetError(VIR_ERR_AUTH_FAILED,
- _("failed to initialize SASL library: %d (%s)"),
- err, sasl_errstring(err, NULL, NULL));
+ virReportError(VIR_ERR_AUTH_FAILED,
+ _("failed to initialize SASL library: %d (%s)"),
+ err, sasl_errstring(err, NULL, NULL));
return NULL;
}
}
if (virMutexInit(&ctxt->lock) < 0) {
- virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to initialized mutex"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to initialized mutex"));
VIR_FREE(ctxt);
return NULL;
}
goto cleanup; /* Succesful match */
}
if (rv != FNM_NOMATCH) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("Malformed TLS whitelist regular expression '%s'"),
- *wildcards);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Malformed TLS whitelist regular expression '%s'"),
+ *wildcards);
goto cleanup;
}
VIR_ERROR(_("SASL client %s not allowed in whitelist"), identity);
/* This is the most common error: make it informative. */
- virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
- _("Client's username is not on the list of allowed clients"));
+ virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
+ _("Client's username is not on the list of allowed clients"));
ret = 0;
cleanup:
}
if (virMutexInit(&sasl->lock) < 0) {
- virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to initialized mutex"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to initialized mutex"));
VIR_FREE(sasl);
return NULL;
}
SASL_SUCCESS_DATA,
&sasl->conn);
if (err != SASL_OK) {
- virNetError(VIR_ERR_AUTH_FAILED,
- _("Failed to create SASL client context: %d (%s)"),
- err, sasl_errstring(err, NULL, NULL));
+ virReportError(VIR_ERR_AUTH_FAILED,
+ _("Failed to create SASL client context: %d (%s)"),
+ err, sasl_errstring(err, NULL, NULL));
goto cleanup;
}
}
if (virMutexInit(&sasl->lock) < 0) {
- virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to initialized mutex"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to initialized mutex"));
VIR_FREE(sasl);
return NULL;
}
SASL_SUCCESS_DATA,
&sasl->conn);
if (err != SASL_OK) {
- virNetError(VIR_ERR_AUTH_FAILED,
- _("Failed to create SASL client context: %d (%s)"),
- err, sasl_errstring(err, NULL, NULL));
+ virReportError(VIR_ERR_AUTH_FAILED,
+ _("Failed to create SASL client context: %d (%s)"),
+ err, sasl_errstring(err, NULL, NULL));
goto cleanup;
}
err = sasl_setprop(sasl->conn, SASL_SSF_EXTERNAL, &ssf);
if (err != SASL_OK) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("cannot set external SSF %d (%s)"),
- err, sasl_errstring(err, NULL, NULL));
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot set external SSF %d (%s)"),
+ err, sasl_errstring(err, NULL, NULL));
goto cleanup;
}
err = sasl_getprop(sasl->conn, SASL_USERNAME, &val);
if (err != SASL_OK) {
- virNetError(VIR_ERR_AUTH_FAILED,
- _("cannot query SASL username on connection %d (%s)"),
- err, sasl_errstring(err, NULL, NULL));
+ virReportError(VIR_ERR_AUTH_FAILED,
+ _("cannot query SASL username on connection %d (%s)"),
+ err, sasl_errstring(err, NULL, NULL));
val = NULL;
goto cleanup;
}
if (val == NULL) {
- virNetError(VIR_ERR_AUTH_FAILED,
- _("no client username was found"));
+ virReportError(VIR_ERR_AUTH_FAILED,
+ _("no client username was found"));
goto cleanup;
}
VIR_DEBUG("SASL client username %s", (const char *)val);
virMutexLock(&sasl->lock);
err = sasl_getprop(sasl->conn, SASL_SSF, &val);
if (err != SASL_OK) {
- virNetError(VIR_ERR_AUTH_FAILED,
- _("cannot query SASL ssf on connection %d (%s)"),
- err, sasl_errstring(err, NULL, NULL));
+ virReportError(VIR_ERR_AUTH_FAILED,
+ _("cannot query SASL ssf on connection %d (%s)"),
+ err, sasl_errstring(err, NULL, NULL));
ssf = -1;
goto cleanup;
}
err = sasl_setprop(sasl->conn, SASL_SEC_PROPS, &secprops);
if (err != SASL_OK) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("cannot set security props %d (%s)"),
- err, sasl_errstring(err, NULL, NULL));
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot set security props %d (%s)"),
+ err, sasl_errstring(err, NULL, NULL));
goto cleanup;
}
err = sasl_getprop(sasl->conn, SASL_MAXOUTBUF, &u.ptr);
if (err != SASL_OK) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("cannot get security props %d (%s)"),
- err, sasl_errstring(err, NULL, NULL));
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot get security props %d (%s)"),
+ err, sasl_errstring(err, NULL, NULL));
return -1;
}
NULL,
NULL);
if (err != SASL_OK) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("cannot list SASL mechanisms %d (%s)"),
- err, sasl_errdetail(sasl->conn));
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot list SASL mechanisms %d (%s)"),
+ err, sasl_errdetail(sasl->conn));
goto cleanup;
}
if (!(ret = strdup(mechlist))) {
ret = VIR_NET_SASL_INTERACT;
break;
default:
- virNetError(VIR_ERR_AUTH_FAILED,
- _("Failed to start SASL negotiation: %d (%s)"),
- err, sasl_errdetail(sasl->conn));
+ virReportError(VIR_ERR_AUTH_FAILED,
+ _("Failed to start SASL negotiation: %d (%s)"),
+ err, sasl_errdetail(sasl->conn));
break;
}
ret = VIR_NET_SASL_INTERACT;
break;
default:
- virNetError(VIR_ERR_AUTH_FAILED,
- _("Failed to step SASL negotiation: %d (%s)"),
- err, sasl_errdetail(sasl->conn));
+ virReportError(VIR_ERR_AUTH_FAILED,
+ _("Failed to step SASL negotiation: %d (%s)"),
+ err, sasl_errdetail(sasl->conn));
break;
}
ret = VIR_NET_SASL_INTERACT;
break;
default:
- virNetError(VIR_ERR_AUTH_FAILED,
- _("Failed to start SASL negotiation: %d (%s)"),
- err, sasl_errdetail(sasl->conn));
+ virReportError(VIR_ERR_AUTH_FAILED,
+ _("Failed to start SASL negotiation: %d (%s)"),
+ err, sasl_errdetail(sasl->conn));
break;
}
ret = VIR_NET_SASL_INTERACT;
break;
default:
- virNetError(VIR_ERR_AUTH_FAILED,
- _("Failed to start SASL negotiation: %d (%s)"),
- err, sasl_errdetail(sasl->conn));
+ virReportError(VIR_ERR_AUTH_FAILED,
+ _("Failed to start SASL negotiation: %d (%s)"),
+ err, sasl_errdetail(sasl->conn));
break;
}
*outputlen = outlen;
if (err != SASL_OK) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("failed to encode SASL data: %d (%s)"),
- err, sasl_errstring(err, NULL, NULL));
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("failed to encode SASL data: %d (%s)"),
+ err, sasl_errstring(err, NULL, NULL));
goto cleanup;
}
ret = 0;
&outlen);
*outputlen = outlen;
if (err != SASL_OK) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("failed to decode SASL data: %d (%s)"),
- err, sasl_errstring(err, NULL, NULL));
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("failed to decode SASL data: %d (%s)"),
+ err, sasl_errstring(err, NULL, NULL));
goto cleanup;
}
ret = 0;
#endif
#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 virNetServerSignal *virNetServerSignalPtr;
virNetServerLock(srv);
if (srv->nclients >= srv->nclients_max) {
- virNetError(VIR_ERR_RPC,
- _("Too many active clients (%zu), dropping connection from %s"),
- srv->nclients_max, virNetServerClientRemoteAddrString(client));
+ virReportError(VIR_ERR_RPC,
+ _("Too many active clients (%zu), dropping connection from %s"),
+ srv->nclients_max, virNetServerClientRemoteAddrString(client));
goto error;
}
#endif
if (virMutexInit(&srv->lock) < 0) {
- virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("cannot initialize mutex"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("cannot initialize mutex"));
goto error;
}
}
}
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("Unexpected signal received: %d"), siginfo.si_signo);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected signal received: %d"), siginfo.si_signo);
cleanup:
virNetServerUnlock(srv);
VIR_EVENT_HANDLE_READABLE,
virNetServerSignalEvent,
srv, NULL)) < 0) {
- virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to add signal handle watch"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to add signal handle watch"));
goto error;
}
(timerid = virEventAddTimeout(-1,
virNetServerAutoShutdownTimer,
srv, NULL)) < 0) {
- virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to register shutdown timeout"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to register shutdown timeout"));
goto cleanup;
}
#include "virkeepalive.h"
#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
* dispatch processing queue, instead of the workers.
ssize_t ret;
if (client->rx->bufferLength <= client->rx->bufferOffset) {
- virNetError(VIR_ERR_RPC,
- _("unexpected zero/negative length request %lld"),
- (long long int)(client->rx->bufferLength - client->rx->bufferOffset));
+ virReportError(VIR_ERR_RPC,
+ _("unexpected zero/negative length request %lld"),
+ (long long int)(client->rx->bufferLength - client->rx->bufferOffset));
client->wantClose = true;
return -1;
}
ssize_t ret;
if (client->tx->bufferLength < client->tx->bufferOffset) {
- virNetError(VIR_ERR_RPC,
- _("unexpected zero/negative length request %lld"),
- (long long int)(client->tx->bufferLength - client->tx->bufferOffset));
+ virReportError(VIR_ERR_RPC,
+ _("unexpected zero/negative length request %lld"),
+ (long long int)(client->tx->bufferLength - client->tx->bufferOffset));
client->wantClose = true;
return -1;
}
#include "logging.h"
#define VIR_FROM_THIS VIR_FROM_RPC
-#define virNetError(code, ...) \
- virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
- __FUNCTION__, __LINE__, __VA_ARGS__)
struct _virNetServerMDNSEntry {
char *type;
virNetServerMDNSWatchDispatch,
w,
virNetServerMDNSWatchDofree)) < 0) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("Failed to add watch for fd %d events %d"), fd, hEvents);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to add watch for fd %d events %d"), fd, hEvents);
VIR_FREE(w);
return NULL;
}
t->userdata = userdata;
if (t->timer < 0) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("Failed to add timer with timeout %lld"), timeout);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to add timer with timeout %lld"), timeout);
VIR_FREE(t);
return NULL;
}
mdns, &error);
if (!mdns->client) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("Failed to create mDNS client: %s"),
- avahi_strerror(error));
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to create mDNS client: %s"),
+ avahi_strerror(error));
return -1;
}
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_RPC
-#define virNetError(code, ...) \
- virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
- __FUNCTION__, __LINE__, __VA_ARGS__)
struct _virNetServerProgram {
int refs;
{
virNetMessageError rerr;
- virNetError(VIR_ERR_RPC,
- _("Cannot find program %d version %d"), req->prog, req->vers);
+ virReportError(VIR_ERR_RPC,
+ _("Cannot find program %d version %d"), req->prog, req->vers);
memset(&rerr, 0, sizeof(rerr));
return virNetServerProgramSendError(req->prog,
/* Check version, etc. */
if (msg->header.prog != prog->program) {
- virNetError(VIR_ERR_RPC,
- _("program mismatch (actual %x, expected %x)"),
- msg->header.prog, prog->program);
+ virReportError(VIR_ERR_RPC,
+ _("program mismatch (actual %x, expected %x)"),
+ msg->header.prog, prog->program);
goto error;
}
if (msg->header.vers != prog->version) {
- virNetError(VIR_ERR_RPC,
- _("version mismatch (actual %x, expected %x)"),
- msg->header.vers, prog->version);
+ virReportError(VIR_ERR_RPC,
+ _("version mismatch (actual %x, expected %x)"),
+ msg->header.vers, prog->version);
goto error;
}
break;
default:
- virNetError(VIR_ERR_RPC,
- _("Unexpected message type %u"),
- msg->header.type);
+ virReportError(VIR_ERR_RPC,
+ _("Unexpected message type %u"),
+ msg->header.type);
goto error;
}
memset(&rerr, 0, sizeof(rerr));
if (msg->header.status != VIR_NET_OK) {
- virNetError(VIR_ERR_RPC,
- _("Unexpected message status %u"),
- msg->header.status);
+ virReportError(VIR_ERR_RPC,
+ _("Unexpected message status %u"),
+ msg->header.status);
goto error;
}
dispatcher = virNetServerProgramGetProc(prog, msg->header.proc);
if (!dispatcher) {
- virNetError(VIR_ERR_RPC,
- _("unknown procedure: %d"),
- msg->header.proc);
+ virReportError(VIR_ERR_RPC,
+ _("unknown procedure: %d"),
+ msg->header.proc);
goto error;
}
/* Explicitly *NOT* calling remoteDispatchAuthError() because
we want back-compatibility with libvirt clients which don't
support the VIR_ERR_AUTH_FAILED error code */
- virNetError(VIR_ERR_RPC,
- "%s", _("authentication required"));
+ virReportError(VIR_ERR_RPC,
+ "%s", _("authentication required"));
goto error;
}
#define VIR_FROM_THIS VIR_FROM_RPC
-#define virNetError(code, ...) \
- virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
- __FUNCTION__, __LINE__, __VA_ARGS__)
-
struct _virNetSocket {
virMutex lock;
int e = getaddrinfo(nodename, service, &hints, &ai);
if (e != 0) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Unable to resolve address '%s' service '%s': %s"),
- nodename, service, gai_strerror(e));
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Unable to resolve address '%s' service '%s': %s"),
+ nodename, service, gai_strerror(e));
return -1;
}
int e = getaddrinfo(nodename, service, &hints, &ai);
if (e != 0) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Unable to resolve address '%s' service '%s': %s"),
- nodename, service, gai_strerror (e));
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Unable to resolve address '%s' service '%s': %s"),
+ nodename, service, gai_strerror (e));
return -1;
}
remoteAddr.len = sizeof(remoteAddr.data.un);
if (spawnDaemon && !binary) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("Auto-spawn of daemon requested, but no binary specified"));
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Auto-spawn of daemon requested, but no binary specified"));
return -1;
}
{
int ret = -1;
if (!virNetSocketHasPassFD(sock)) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("Sending file descriptors is not supported on this socket"));
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Sending file descriptors is not supported on this socket"));
return -1;
}
virMutexLock(&sock->lock);
*fd = -1;
if (!virNetSocketHasPassFD(sock)) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("Receiving file descriptors is not supported on this socket"));
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Receiving file descriptors is not supported on this socket"));
return -1;
}
virMutexLock(&sock->lock);
#define LIBVIRT_SERVERCERT LIBVIRT_PKI_DIR "/libvirt/servercert.pem"
#define VIR_FROM_THIS VIR_FROM_RPC
-#define virNetError(code, ...) \
- virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
- __FUNCTION__, __LINE__, __VA_ARGS__)
struct _virNetTLSContext {
virMutex lock;
}
if (gnutls_x509_crt_get_expiration_time(cert) < now) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- (isCA ?
- _("The CA certificate %s has expired") :
- (isServer ?
- _("The server certificate %s has expired") :
- _("The client certificate %s has expired"))),
- certFile);
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ (isCA ?
+ _("The CA certificate %s has expired") :
+ (isServer ?
+ _("The server certificate %s has expired") :
+ _("The client certificate %s has expired"))),
+ certFile);
return -1;
}
if (gnutls_x509_crt_get_activation_time(cert) > now) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- (isCA ?
- _("The CA certificate %s is not yet active") :
- (isServer ?
- _("The server certificate %s is not yet active") :
- _("The client certificate %s is not yet active"))),
- certFile);
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ (isCA ?
+ _("The CA certificate %s is not yet active") :
+ (isServer ?
+ _("The server certificate %s is not yet active") :
+ _("The client certificate %s is not yet active"))),
+ certFile);
return -1;
}
if (status > 0) { /* It is a CA cert */
if (!isCA) {
- virNetError(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 client"),
- certFile);
+ 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 client"),
+ certFile);
return -1;
}
} else if (status == 0) { /* It is not a CA cert */
if (isCA) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("The certificate %s basic constraints do not show a CA"),
- certFile);
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("The certificate %s basic constraints do not show a CA"),
+ certFile);
return -1;
}
} else if (status == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) { /* Missing basicConstraints */
if (isCA) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("The certificate %s is missing basic constraints for a CA"),
- certFile);
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("The certificate %s is missing basic constraints for a CA"),
+ certFile);
return -1;
}
} else { /* General error */
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Unable to query certificate %s basic constraints %s"),
- certFile, gnutls_strerror(status));
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Unable to query certificate %s basic constraints %s"),
+ certFile, gnutls_strerror(status));
return -1;
}
usage = isCA ? GNUTLS_KEY_KEY_CERT_SIGN :
GNUTLS_KEY_DIGITAL_SIGNATURE|GNUTLS_KEY_KEY_ENCIPHERMENT;
} else {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Unable to query certificate %s key usage %s"),
- certFile, gnutls_strerror(status));
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Unable to query certificate %s key usage %s"),
+ certFile, gnutls_strerror(status));
return -1;
}
}
if (isCA) {
if (!(usage & GNUTLS_KEY_KEY_CERT_SIGN)) {
if (critical) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Certificate %s usage does not permit certificate signing"),
- certFile);
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Certificate %s usage does not permit certificate signing"),
+ certFile);
return -1;
} else {
VIR_WARN("Certificate %s usage does not permit certificate signing",
} else {
if (!(usage & GNUTLS_KEY_DIGITAL_SIGNATURE)) {
if (critical) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Certificate %s usage does not permit digital signature"),
- certFile);
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Certificate %s usage does not permit digital signature"),
+ certFile);
return -1;
} else {
VIR_WARN("Certificate %s usage does not permit digital signature",
}
if (!(usage & GNUTLS_KEY_KEY_ENCIPHERMENT)) {
if (critical) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Certificate %s usage does not permit key encipherment"),
- certFile);
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Certificate %s usage does not permit key encipherment"),
+ certFile);
return -1;
} else {
VIR_WARN("Certificate %s usage does not permit key encipherment",
break;
}
if (status != GNUTLS_E_SHORT_MEMORY_BUFFER) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Unable to query certificate %s key purpose %s"),
- certFile, gnutls_strerror(status));
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Unable to query certificate %s key purpose %s"),
+ certFile, gnutls_strerror(status));
return -1;
}
status = gnutls_x509_crt_get_key_purpose_oid(cert, i, buffer, &size, &purposeCritical);
if (status < 0) {
VIR_FREE(buffer);
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Unable to query certificate %s key purpose %s"),
- certFile, gnutls_strerror(status));
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Unable to query certificate %s key purpose %s"),
+ certFile, gnutls_strerror(status));
return -1;
}
if (purposeCritical)
if (isServer) {
if (!allowServer) {
if (critical) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Certificate %s purpose does not allow use for with a TLS server"),
- certFile);
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Certificate %s purpose does not allow use for with a TLS server"),
+ certFile);
return -1;
} else {
VIR_WARN("Certificate %s purpose does not allow use for with a TLS server",
} else {
if (!allowClient) {
if (critical) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Certificate %s purpose does not allow use for with a TLS client"),
- certFile);
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Certificate %s purpose does not allow use for with a TLS client"),
+ certFile);
return -1;
} else {
VIR_WARN("Certificate %s purpose does not allow use for with a TLS client",
if (ret == 0) /* Succesful match */
return 1;
if (ret != FNM_NOMATCH) {
- virNetError(VIR_ERR_INTERNAL_ERROR,
- _("Malformed TLS whitelist regular expression '%s'"),
- *wildcards);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Malformed TLS whitelist regular expression '%s'"),
+ *wildcards);
return -1;
}
VIR_DEBUG("Failed whitelist check for client DN '%s'", dname);
/* This is the most common error: make it informative. */
- virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
- _("Client's Distinguished Name is not on the list "
- "of allowed clients (tls_allowed_dn_list). Use "
- "'certtool -i --infile clientcert.pem' to view the"
- "Distinguished Name field in the client certificate,"
- "or run this daemon with --verbose option."));
+ virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
+ _("Client's Distinguished Name is not on the list "
+ "of allowed clients (tls_allowed_dn_list). Use "
+ "'certtool -i --infile clientcert.pem' to view the"
+ "Distinguished Name field in the client certificate,"
+ "or run this daemon with --verbose option."));
return 0;
}
if (hostname &&
!gnutls_x509_crt_check_hostname(cert, hostname)) {
- virNetError(VIR_ERR_RPC,
- _("Certificate %s owner does not match the hostname %s"),
- certFile, hostname);
+ virReportError(VIR_ERR_RPC,
+ _("Certificate %s owner does not match the hostname %s"),
+ certFile, hostname);
return -1;
}
&cacert, 1,
NULL, 0,
0, &status) < 0) {
- virNetError(VIR_ERR_SYSTEM_ERROR, isServer ?
- _("Unable to verify server certificate %s against CA certificate %s") :
- _("Unable to verify client certificate %s against CA certificate %s"),
- certFile, cacertFile);
+ virReportError(VIR_ERR_SYSTEM_ERROR, isServer ?
+ _("Unable to verify server certificate %s against CA certificate %s") :
+ _("Unable to verify client certificate %s against CA certificate %s"),
+ certFile, cacertFile);
return -1;
}
reason = _("The certificate uses an insecure algorithm");
#endif
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Our own certificate %s failed validation against %s: %s"),
- certFile, cacertFile, reason);
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Our own certificate %s failed validation against %s: %s"),
+ certFile, cacertFile, reason);
return -1;
}
isServer, isCA, certFile);
if (gnutls_x509_crt_init(&cert) < 0) {
- virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
- _("Unable to initialize certificate"));
+ virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
+ _("Unable to initialize certificate"));
goto cleanup;
}
data.size = strlen(buf);
if (gnutls_x509_crt_import(cert, &data, GNUTLS_X509_FMT_PEM) < 0) {
- virNetError(VIR_ERR_SYSTEM_ERROR, isServer ?
- _("Unable to import server certificate %s") :
- _("Unable to import client certificate %s"),
- certFile);
+ virReportError(VIR_ERR_SYSTEM_ERROR, isServer ?
+ _("Unable to import server certificate %s") :
+ _("Unable to import client certificate %s"),
+ certFile);
goto cleanup;
}
cacert,
GNUTLS_X509_FMT_PEM);
if (err < 0) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Unable to set x509 CA certificate: %s: %s"),
- cacert, gnutls_strerror (err));
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Unable to set x509 CA certificate: %s: %s"),
+ cacert, gnutls_strerror (err));
goto cleanup;
}
}
cacrl,
GNUTLS_X509_FMT_PEM);
if (err < 0) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Unable to set x509 certificate revocation list: %s: %s"),
- cacrl, gnutls_strerror(err));
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Unable to set x509 certificate revocation list: %s: %s"),
+ cacrl, gnutls_strerror(err));
goto cleanup;
}
} else {
cert, key,
GNUTLS_X509_FMT_PEM);
if (err < 0) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Unable to set x509 key and certificate: %s, %s: %s"),
- key, cert, gnutls_strerror(err));
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Unable to set x509 key and certificate: %s, %s: %s"),
+ key, cert, gnutls_strerror(err));
goto cleanup;
}
} else {
}
if (virMutexInit(&ctxt->lock) < 0) {
- virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to initialized mutex"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to initialized mutex"));
VIR_FREE(ctxt);
return NULL;
}
err = gnutls_certificate_allocate_credentials(&ctxt->x509cred);
if (err) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Unable to allocate x509 credentials: %s"),
- gnutls_strerror(err));
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Unable to allocate x509 credentials: %s"),
+ gnutls_strerror(err));
goto error;
}
if (isServer) {
err = gnutls_dh_params_init(&ctxt->dhParams);
if (err < 0) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Unable to initialize diffie-hellman parameters: %s"),
- gnutls_strerror(err));
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Unable to initialize diffie-hellman parameters: %s"),
+ gnutls_strerror(err));
goto error;
}
err = gnutls_dh_params_generate2(ctxt->dhParams, DH_BITS);
if (err < 0) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Unable to generate diffie-hellman parameters: %s"),
- gnutls_strerror(err));
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Unable to generate diffie-hellman parameters: %s"),
+ gnutls_strerror(err));
goto error;
}
memset(dname, 0, dnamesize);
if ((ret = gnutls_certificate_verify_peers2(sess->session, &status)) < 0){
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Unable to verify TLS peer: %s"),
- gnutls_strerror(ret));
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Unable to verify TLS peer: %s"),
+ gnutls_strerror(ret));
goto authdeny;
}
reason = _("The certificate uses an insecure algorithm");
#endif
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Certificate failed validation: %s"),
- reason);
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Certificate failed validation: %s"),
+ reason);
goto authdeny;
}
if (gnutls_certificate_type_get(sess->session) != GNUTLS_CRT_X509) {
- virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
- _("Only x509 certificates are supported"));
+ virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
+ _("Only x509 certificates are supported"));
goto authdeny;
}
if (!(certs = gnutls_certificate_get_peers(sess->session, &nCerts))) {
- virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
- _("The certificate has no peers"));
+ virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
+ _("The certificate has no peers"));
goto authdeny;
}
gnutls_x509_crt_t cert;
if (gnutls_x509_crt_init(&cert) < 0) {
- virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
- _("Unable to initialize certificate"));
+ virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
+ _("Unable to initialize certificate"));
goto authfail;
}
if (gnutls_x509_crt_import(cert, &certs[i], GNUTLS_X509_FMT_DER) < 0) {
- virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
- _("Unable to load certificate"));
+ virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
+ _("Unable to load certificate"));
gnutls_x509_crt_deinit(cert);
goto authfail;
}
if (i == 0) {
ret = gnutls_x509_crt_get_dn(cert, dname, &dnamesize);
if (ret != 0) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Failed to get certificate %s distinguished name: %s"),
- "[session]", gnutls_strerror(ret));
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Failed to get certificate %s distinguished name: %s"),
+ "[session]", gnutls_strerror(ret));
goto authfail;
}
VIR_DEBUG("Peer DN is %s", dname);
virErrorPtr err = virGetLastError();
VIR_WARN("Certificate check failed %s", err && err->message ? err->message : "<unknown>");
if (ctxt->requireValidCert) {
- virNetError(VIR_ERR_AUTH_FAILED, "%s",
- _("Failed to verify peer's certificate"));
+ virReportError(VIR_ERR_AUTH_FAILED, "%s",
+ _("Failed to verify peer's certificate"));
goto cleanup;
}
virResetLastError();
}
if (virMutexInit(&sess->lock) < 0) {
- virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to initialized mutex"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to initialized mutex"));
VIR_FREE(sess);
return NULL;
}
if ((err = gnutls_init(&sess->session,
ctxt->isServer ? GNUTLS_SERVER : GNUTLS_CLIENT)) != 0) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Failed to initialize TLS session: %s"),
- gnutls_strerror(err));
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Failed to initialize TLS session: %s"),
+ gnutls_strerror(err));
goto error;
}
* are adequate.
*/
if ((err = gnutls_set_default_priority(sess->session)) != 0) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Failed to set TLS session priority %s"),
- gnutls_strerror(err));
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Failed to set TLS session priority %s"),
+ gnutls_strerror(err));
goto error;
}
if ((err = gnutls_credentials_set(sess->session,
GNUTLS_CRD_CERTIFICATE,
ctxt->x509cred)) != 0) {
- virNetError(VIR_ERR_SYSTEM_ERROR,
- _("Failed set TLS x509 credentials: %s"),
- gnutls_strerror(err));
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Failed set TLS x509 credentials: %s"),
+ gnutls_strerror(err));
goto error;
}
virNetServerClientGetFD(client));
#endif
- virNetError(VIR_ERR_AUTH_FAILED,
- _("TLS handshake failed %s"),
- gnutls_strerror(ret));
+ virReportError(VIR_ERR_AUTH_FAILED,
+ _("TLS handshake failed %s"),
+ gnutls_strerror(ret));
ret = -1;
cleanup:
virMutexLock(&sess->lock);
cipher = gnutls_cipher_get(sess->session);
if (!(ssf = gnutls_cipher_get_key_size(cipher))) {
- virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("invalid cipher size for TLS session"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("invalid cipher size for TLS session"));
ssf = -1;
goto cleanup;
}