Mark all qemudLog diagnostics for translation.

* po/POTFILES.in: Add names of many new files.
* Makefile.maint (err_func_re): Add qemudLog.
Mark diagnostics with _(...).  Split some long lines.
* qemud/qemud.c (remoteCheckCertFile, remoteInitializeGnuTLS):
(qemudDispatchSignalEvent, qemudSetCloseExec, qemudSetNonBlock):
(qemudWritePidFile, qemudListenUnix, remoteMakeSockets):
(remoteListenTCP, qemudInitPaths, qemudInitialize):
(qemudNetworkInit, remoteInitializeTLSSession, remoteCheckDN):
(remoteCheckCertificate, remoteCheckAccess, qemudDispatchServer):
(qemudClientReadBuf, qemudDispatchClientRead):
(qemudClientWriteBuf, qemudDispatchClientWrite, qemudOneLoop):
(remoteConfigGetStringList, checkType, GET_CONF_STR):
(remoteConfigGetAuth, remoteReadConfigFile, main):
* qemud/remote.c (remoteDispatchAuthSaslInit, remoteSASLCheckSSF):
(remoteSASLCheckAccess, remoteDispatchAuthSaslStart):
(remoteDispatchAuthSaslStep, remoteDispatchAuthSaslInit):
(remoteDispatchAuthSaslStart, remoteDispatchAuthSaslStep):
(qemudGetSocketIdentity, remoteDispatchAuthPolkit):
* src/iptables.c (notifyRulesUpdated, MAX_FILE_LEN, iptRulesSave):
(iptRulesReload):
* src/qemu_conf.c (qemudExtractVersionInfo, qemudLoadConfig):
(qemudLoadNetworkConfig, qemudScanConfigDir):
* src/qemu_driver.c (qemudSetCloseExec, qemudSetNonBlock):
(qemudAutostartConfigs, qemudStartup, qemudReload):
(qemudWaitForMonitor, qemudStartVMDaemon, qemudVMData):
(qemudShutdownVMDaemon, qemudStartNetworkDaemon):
(qemudShutdownNetworkDaemon, qemudMonitorCommand):
(qemudDomainUndefine, qemudNetworkUndefine):
* src/uuid.c (virUUIDGenerate):
* src/xm_internal.c (xenXMAttachInterface):
This commit is contained in:
Jim Meyering 2008-02-07 16:50:17 +00:00
parent e8ff93b4e6
commit 247df6e448
9 changed files with 262 additions and 174 deletions

View File

@ -1,5 +1,37 @@
Thu Feb 7 17:48:30 CET 2008 Jim Meyering <meyering@redhat.com> Thu Feb 7 17:48:30 CET 2008 Jim Meyering <meyering@redhat.com>
Mark all qemudLog diagnostics for translation.
* po/POTFILES.in: Add names of many new files.
* Makefile.maint (err_func_re): Add qemudLog.
Mark diagnostics with _(...). Split some long lines.
* qemud/qemud.c (remoteCheckCertFile, remoteInitializeGnuTLS):
(qemudDispatchSignalEvent, qemudSetCloseExec, qemudSetNonBlock):
(qemudWritePidFile, qemudListenUnix, remoteMakeSockets):
(remoteListenTCP, qemudInitPaths, qemudInitialize):
(qemudNetworkInit, remoteInitializeTLSSession, remoteCheckDN):
(remoteCheckCertificate, remoteCheckAccess, qemudDispatchServer):
(qemudClientReadBuf, qemudDispatchClientRead):
(qemudClientWriteBuf, qemudDispatchClientWrite, qemudOneLoop):
(remoteConfigGetStringList, checkType, GET_CONF_STR):
(remoteConfigGetAuth, remoteReadConfigFile, main):
* qemud/remote.c (remoteDispatchAuthSaslInit, remoteSASLCheckSSF):
(remoteSASLCheckAccess, remoteDispatchAuthSaslStart):
(remoteDispatchAuthSaslStep, remoteDispatchAuthSaslInit):
(remoteDispatchAuthSaslStart, remoteDispatchAuthSaslStep):
(qemudGetSocketIdentity, remoteDispatchAuthPolkit):
* src/iptables.c (notifyRulesUpdated, MAX_FILE_LEN, iptRulesSave):
(iptRulesReload):
* src/qemu_conf.c (qemudExtractVersionInfo, qemudLoadConfig):
(qemudLoadNetworkConfig, qemudScanConfigDir):
* src/qemu_driver.c (qemudSetCloseExec, qemudSetNonBlock):
(qemudAutostartConfigs, qemudStartup, qemudReload):
(qemudWaitForMonitor, qemudStartVMDaemon, qemudVMData):
(qemudShutdownVMDaemon, qemudStartNetworkDaemon):
(qemudShutdownNetworkDaemon, qemudMonitorCommand):
(qemudDomainUndefine, qemudNetworkUndefine):
* src/uuid.c (virUUIDGenerate):
* src/xm_internal.c (xenXMAttachInterface):
Remove more useless if tests before "free"-like functions. Remove more useless if tests before "free"-like functions.
* build-aux/useless-if-before-free: Rename from ... * build-aux/useless-if-before-free: Rename from ...
* build-aux/find-unnecessary-if-before-free: ... this. Remove file. * build-aux/find-unnecessary-if-before-free: ... this. Remove file.

View File

@ -289,7 +289,7 @@ sc_two_space_separator_in_usage:
1>&2; exit 1; } || : 1>&2; exit 1; } || :
err_func_re = \ err_func_re = \
(DISABLE_fprintf|(xmlRpc|vir(Xend|XML|Hash|Conf|Test|LibConn))Error) (DISABLE_fprintf|qemudLog|(xmlRpc|vir(Xend|XML|Hash|Conf|Test|LibConn))Error)
# Look for diagnostics that aren't marked for translation. # Look for diagnostics that aren't marked for translation.
# This won't find any for which error's format string is on a separate line. # This won't find any for which error's format string is on a separate line.

View File

@ -1,12 +1,18 @@
gnulib/lib/gai_strerror.c gnulib/lib/gai_strerror.c
qemud/remote.c
qemud/qemud.c
src/conf.c src/conf.c
src/console.c src/console.c
src/hash.c src/hash.c
src/iptables.c
src/libvirt.c src/libvirt.c
src/proxy_internal.c src/proxy_internal.c
src/qemu_conf.c
src/qemu_driver.c
src/remote_internal.c src/remote_internal.c
src/sexpr.c src/sexpr.c
src/test.c src/test.c
src/uuid.c
src/virsh.c src/virsh.c
src/virterror.c src/virterror.c
src/xen_internal.c src/xen_internal.c

View File

@ -1,7 +1,7 @@
/* /*
* qemud.c: daemon start of day, guest process & i/o management * qemud.c: daemon start of day, guest process & i/o management
* *
* Copyright (C) 2006, 2007 Red Hat, Inc. * Copyright (C) 2006, 2007, 2008 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange * Copyright (C) 2006 Daniel P. Berrange
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -137,7 +137,7 @@ remoteCheckCertFile(const char *type, const char *file)
{ {
struct stat sb; struct stat sb;
if (stat(file, &sb) < 0) { if (stat(file, &sb) < 0) {
qemudLog (QEMUD_ERR, "Cannot access %s '%s': %s (%d)", qemudLog (QEMUD_ERR, _("Cannot access %s '%s': %s (%d)"),
type, file, strerror(errno), errno); type, file, strerror(errno), errno);
return -1; return -1;
} }
@ -154,7 +154,7 @@ remoteInitializeGnuTLS (void)
err = gnutls_certificate_allocate_credentials (&x509_cred); err = gnutls_certificate_allocate_credentials (&x509_cred);
if (err) { if (err) {
qemudLog (QEMUD_ERR, "gnutls_certificate_allocate_credentials: %s", qemudLog (QEMUD_ERR, _("gnutls_certificate_allocate_credentials: %s"),
gnutls_strerror (err)); gnutls_strerror (err));
return -1; return -1;
} }
@ -167,7 +167,7 @@ remoteInitializeGnuTLS (void)
err = gnutls_certificate_set_x509_trust_file (x509_cred, ca_file, err = gnutls_certificate_set_x509_trust_file (x509_cred, ca_file,
GNUTLS_X509_FMT_PEM); GNUTLS_X509_FMT_PEM);
if (err < 0) { if (err < 0) {
qemudLog (QEMUD_ERR, "gnutls_certificate_set_x509_trust_file: %s", qemudLog (QEMUD_ERR, _("gnutls_certificate_set_x509_trust_file: %s"),
gnutls_strerror (err)); gnutls_strerror (err));
return -1; return -1;
} }
@ -181,7 +181,7 @@ remoteInitializeGnuTLS (void)
err = gnutls_certificate_set_x509_crl_file (x509_cred, crl_file, err = gnutls_certificate_set_x509_crl_file (x509_cred, crl_file,
GNUTLS_X509_FMT_PEM); GNUTLS_X509_FMT_PEM);
if (err < 0) { if (err < 0) {
qemudLog (QEMUD_ERR, "gnutls_certificate_set_x509_crl_file: %s", qemudLog (QEMUD_ERR, _("gnutls_certificate_set_x509_crl_file: %s"),
gnutls_strerror (err)); gnutls_strerror (err));
return -1; return -1;
} }
@ -199,7 +199,7 @@ remoteInitializeGnuTLS (void)
cert_file, key_file, cert_file, key_file,
GNUTLS_X509_FMT_PEM); GNUTLS_X509_FMT_PEM);
if (err < 0) { if (err < 0) {
qemudLog (QEMUD_ERR, "gnutls_certificate_set_x509_key_file: %s", qemudLog (QEMUD_ERR, _("gnutls_certificate_set_x509_key_file: %s"),
gnutls_strerror (err)); gnutls_strerror (err));
return -1; return -1;
} }
@ -212,13 +212,13 @@ remoteInitializeGnuTLS (void)
*/ */
err = gnutls_dh_params_init (&dh_params); err = gnutls_dh_params_init (&dh_params);
if (err < 0) { if (err < 0) {
qemudLog (QEMUD_ERR, "gnutls_dh_params_init: %s", qemudLog (QEMUD_ERR, _("gnutls_dh_params_init: %s"),
gnutls_strerror (err)); gnutls_strerror (err));
return -1; return -1;
} }
err = gnutls_dh_params_generate2 (dh_params, DH_BITS); err = gnutls_dh_params_generate2 (dh_params, DH_BITS);
if (err < 0) { if (err < 0) {
qemudLog (QEMUD_ERR, "gnutls_dh_params_generate2: %s", qemudLog (QEMUD_ERR, _("gnutls_dh_params_generate2: %s"),
gnutls_strerror (err)); gnutls_strerror (err));
return -1; return -1;
} }
@ -236,7 +236,7 @@ static void qemudDispatchSignalEvent(int fd ATTRIBUTE_UNUSED,
int ret; int ret;
if (read(server->sigread, &sigc, 1) != 1) { if (read(server->sigread, &sigc, 1) != 1) {
qemudLog(QEMUD_ERR, "Failed to read from signal pipe: %s", qemudLog(QEMUD_ERR, _("Failed to read from signal pipe: %s"),
strerror(errno)); strerror(errno));
return; return;
} }
@ -245,15 +245,15 @@ static void qemudDispatchSignalEvent(int fd ATTRIBUTE_UNUSED,
switch (sigc) { switch (sigc) {
case SIGHUP: case SIGHUP:
qemudLog(QEMUD_INFO, "Reloading configuration on SIGHUP"); qemudLog(QEMUD_INFO, _("Reloading configuration on SIGHUP"));
if (virStateReload() < 0) if (virStateReload() < 0)
qemudLog(QEMUD_WARN, "Error while reloading drivers"); qemudLog(QEMUD_WARN, _("Error while reloading drivers"));
break; break;
case SIGINT: case SIGINT:
case SIGQUIT: case SIGQUIT:
case SIGTERM: case SIGTERM:
qemudLog(QEMUD_WARN, "Shutting down on signal %d", sigc); qemudLog(QEMUD_WARN, _("Shutting down on signal %d"), sigc);
server->shutdown = 1; server->shutdown = 1;
break; break;
@ -274,7 +274,7 @@ static int qemudSetCloseExec(int fd) {
goto error; goto error;
return 0; return 0;
error: error:
qemudLog(QEMUD_ERR, "Failed to set close-on-exec file descriptor flag"); qemudLog(QEMUD_ERR, _("Failed to set close-on-exec file descriptor flag"));
return -1; return -1;
} }
@ -288,7 +288,7 @@ static int qemudSetNonBlock(int fd) {
goto error; goto error;
return 0; return 0;
error: error:
qemudLog(QEMUD_ERR, "Failed to set non-blocking file descriptor flag"); qemudLog(QEMUD_ERR, _("Failed to set non-blocking file descriptor flag"));
return -1; return -1;
} }
@ -430,27 +430,27 @@ static int qemudWritePidFile(const char *pidFile) {
return 0; return 0;
if ((fd = open(pidFile, O_WRONLY|O_CREAT|O_EXCL, 0644)) < 0) { if ((fd = open(pidFile, O_WRONLY|O_CREAT|O_EXCL, 0644)) < 0) {
qemudLog(QEMUD_ERR, "Failed to open pid file '%s' : %s", qemudLog(QEMUD_ERR, _("Failed to open pid file '%s' : %s"),
pidFile, strerror(errno)); pidFile, strerror(errno));
return -1; return -1;
} }
if (!(fh = fdopen(fd, "w"))) { if (!(fh = fdopen(fd, "w"))) {
qemudLog(QEMUD_ERR, "Failed to fdopen pid file '%s' : %s", qemudLog(QEMUD_ERR, _("Failed to fdopen pid file '%s' : %s"),
pidFile, strerror(errno)); pidFile, strerror(errno));
close(fd); close(fd);
return -1; return -1;
} }
if (fprintf(fh, "%lu\n", (unsigned long)getpid()) < 0) { if (fprintf(fh, "%lu\n", (unsigned long)getpid()) < 0) {
qemudLog(QEMUD_ERR, "Failed to write to pid file '%s' : %s", qemudLog(QEMUD_ERR, _("Failed to write to pid file '%s' : %s"),
pidFile, strerror(errno)); pidFile, strerror(errno));
close(fd); close(fd);
return -1; return -1;
} }
if (fclose(fh) == EOF) { if (fclose(fh) == EOF) {
qemudLog(QEMUD_ERR, "Failed to close pid file '%s' : %s", qemudLog(QEMUD_ERR, _("Failed to close pid file '%s' : %s"),
pidFile, strerror(errno)); pidFile, strerror(errno));
return -1; return -1;
} }
@ -466,7 +466,8 @@ static int qemudListenUnix(struct qemud_server *server,
gid_t oldgrp; gid_t oldgrp;
if (!sock) { if (!sock) {
qemudLog(QEMUD_ERR, "Failed to allocate memory for struct qemud_socket"); qemudLog(QEMUD_ERR,
_("Failed to allocate memory for struct qemud_socket"));
return -1; return -1;
} }
@ -476,7 +477,7 @@ static int qemudListenUnix(struct qemud_server *server,
sock->auth = auth; sock->auth = auth;
if ((sock->fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { if ((sock->fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
qemudLog(QEMUD_ERR, "Failed to create socket: %s", qemudLog(QEMUD_ERR, _("Failed to create socket: %s"),
strerror(errno)); strerror(errno));
goto cleanup; goto cleanup;
} }
@ -498,7 +499,7 @@ static int qemudListenUnix(struct qemud_server *server,
setgid(unix_sock_gid); setgid(unix_sock_gid);
if (bind(sock->fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { if (bind(sock->fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
qemudLog(QEMUD_ERR, "Failed to bind socket to '%s': %s", qemudLog(QEMUD_ERR, _("Failed to bind socket to '%s': %s"),
path, strerror(errno)); path, strerror(errno));
goto cleanup; goto cleanup;
} }
@ -507,7 +508,7 @@ static int qemudListenUnix(struct qemud_server *server,
setgid(oldgrp); setgid(oldgrp);
if (listen(sock->fd, 30) < 0) { if (listen(sock->fd, 30) < 0) {
qemudLog(QEMUD_ERR, "Failed to listen for connections on '%s': %s", qemudLog(QEMUD_ERR, _("Failed to listen for connections on '%s': %s"),
path, strerror(errno)); path, strerror(errno));
goto cleanup; goto cleanup;
} }
@ -516,7 +517,7 @@ static int qemudListenUnix(struct qemud_server *server,
POLLIN| POLLERR | POLLHUP, POLLIN| POLLERR | POLLHUP,
qemudDispatchServerEvent, qemudDispatchServerEvent,
server) < 0) { server) < 0) {
qemudLog(QEMUD_ERR, "Failed to add server event callback"); qemudLog(QEMUD_ERR, _("Failed to add server event callback"));
goto cleanup; goto cleanup;
} }
@ -545,7 +546,7 @@ remoteMakeSockets (int *fds, int max_fds, int *nfds_r, const char *service)
int e = getaddrinfo (NULL, service, &hints, &ai); int e = getaddrinfo (NULL, service, &hints, &ai);
if (e != 0) { if (e != 0) {
qemudLog (QEMUD_ERR, "getaddrinfo: %s\n", gai_strerror (e)); qemudLog (QEMUD_ERR, _("getaddrinfo: %s\n"), gai_strerror (e));
return -1; return -1;
} }
@ -554,7 +555,7 @@ remoteMakeSockets (int *fds, int max_fds, int *nfds_r, const char *service)
fds[*nfds_r] = socket (runp->ai_family, runp->ai_socktype, fds[*nfds_r] = socket (runp->ai_family, runp->ai_socktype,
runp->ai_protocol); runp->ai_protocol);
if (fds[*nfds_r] == -1) { if (fds[*nfds_r] == -1) {
qemudLog (QEMUD_ERR, "socket: %s", strerror (errno)); qemudLog (QEMUD_ERR, _("socket: %s"), strerror (errno));
return -1; return -1;
} }
@ -563,14 +564,14 @@ remoteMakeSockets (int *fds, int max_fds, int *nfds_r, const char *service)
if (bind (fds[*nfds_r], runp->ai_addr, runp->ai_addrlen) == -1) { if (bind (fds[*nfds_r], runp->ai_addr, runp->ai_addrlen) == -1) {
if (errno != EADDRINUSE) { if (errno != EADDRINUSE) {
qemudLog (QEMUD_ERR, "bind: %s", strerror (errno)); qemudLog (QEMUD_ERR, _("bind: %s"), strerror (errno));
return -1; return -1;
} }
close (fds[*nfds_r]); close (fds[*nfds_r]);
} }
else { else {
if (listen (fds[*nfds_r], SOMAXCONN) == -1) { if (listen (fds[*nfds_r], SOMAXCONN) == -1) {
qemudLog (QEMUD_ERR, "listen: %s", strerror (errno)); qemudLog (QEMUD_ERR, _("listen: %s"), strerror (errno));
return -1; return -1;
} }
++*nfds_r; ++*nfds_r;
@ -607,7 +608,7 @@ remoteListenTCP (struct qemud_server *server,
if (!sock) { if (!sock) {
qemudLog (QEMUD_ERR, qemudLog (QEMUD_ERR,
"remoteListenTCP: calloc: %s", strerror (errno)); _("remoteListenTCP: calloc: %s"), strerror (errno));
return -1; return -1;
} }
@ -638,7 +639,7 @@ remoteListenTCP (struct qemud_server *server,
if (listen (sock->fd, 30) < 0) { if (listen (sock->fd, 30) < 0) {
qemudLog (QEMUD_ERR, qemudLog (QEMUD_ERR,
"remoteListenTCP: listen: %s", strerror (errno)); _("remoteListenTCP: listen: %s"), strerror (errno));
return -1; return -1;
} }
@ -646,7 +647,7 @@ remoteListenTCP (struct qemud_server *server,
POLLIN| POLLERR | POLLHUP, POLLIN| POLLERR | POLLHUP,
qemudDispatchServerEvent, qemudDispatchServerEvent,
server) < 0) { server) < 0) {
qemudLog(QEMUD_ERR, "Failed to add server event callback"); qemudLog(QEMUD_ERR, _("Failed to add server event callback"));
return -1; return -1;
} }
@ -680,7 +681,7 @@ static int qemudInitPaths(struct qemud_server *server,
struct passwd *pw; struct passwd *pw;
if (!(pw = getpwuid(uid))) { if (!(pw = getpwuid(uid))) {
qemudLog(QEMUD_ERR, "Failed to find user record for uid '%d': %s", qemudLog(QEMUD_ERR, _("Failed to find user record for uid '%d': %s"),
uid, strerror(errno)); uid, strerror(errno));
return -1; return -1;
} }
@ -696,7 +697,8 @@ static int qemudInitPaths(struct qemud_server *server,
return 0; return 0;
snprintf_error: snprintf_error:
qemudLog(QEMUD_ERR, "Resulting path to long for buffer in qemudInitPaths()"); qemudLog(QEMUD_ERR,
_("Resulting path to long for buffer in qemudInitPaths()"));
return -1; return -1;
} }
@ -704,7 +706,7 @@ static struct qemud_server *qemudInitialize(int sigread) {
struct qemud_server *server; struct qemud_server *server;
if (!(server = calloc(1, sizeof(*server)))) { if (!(server = calloc(1, sizeof(*server)))) {
qemudLog(QEMUD_ERR, "Failed to allocate struct qemud_server"); qemudLog(QEMUD_ERR, _("Failed to allocate struct qemud_server"));
return NULL; return NULL;
} }
@ -747,7 +749,8 @@ static struct qemud_server *qemudNetworkInit(struct qemud_server *server) {
auth_tcp == REMOTE_AUTH_SASL || auth_tcp == REMOTE_AUTH_SASL ||
auth_tls == REMOTE_AUTH_SASL) { auth_tls == REMOTE_AUTH_SASL) {
if ((err = sasl_server_init(NULL, "libvirt")) != SASL_OK) { if ((err = sasl_server_init(NULL, "libvirt")) != SASL_OK) {
qemudLog(QEMUD_ERR, "Failed to initialize SASL authentication %s", qemudLog(QEMUD_ERR,
_("Failed to initialize SASL authentication %s"),
sasl_errstring(err, NULL, NULL)); sasl_errstring(err, NULL, NULL));
goto cleanup; goto cleanup;
} }
@ -761,7 +764,8 @@ static struct qemud_server *qemudNetworkInit(struct qemud_server *server) {
dbus_error_init(&derr); dbus_error_init(&derr);
server->sysbus = dbus_bus_get(DBUS_BUS_SYSTEM, &derr); server->sysbus = dbus_bus_get(DBUS_BUS_SYSTEM, &derr);
if (!(server->sysbus)) { if (!(server->sysbus)) {
qemudLog(QEMUD_ERR, "Failed to connect to system bus for PolicyKit auth: %s", qemudLog(QEMUD_ERR,
_("Failed to connect to system bus for PolicyKit auth: %s"),
derr.message); derr.message);
dbus_error_free(&derr); dbus_error_free(&derr);
goto cleanup; goto cleanup;
@ -872,7 +876,7 @@ remoteInitializeTLSSession (void)
return session; return session;
failed: failed:
qemudLog (QEMUD_ERR, "remoteInitializeTLSSession: %s", qemudLog (QEMUD_ERR, _("remoteInitializeTLSSession: %s"),
gnutls_strerror (err)); gnutls_strerror (err));
return NULL; return NULL;
} }
@ -889,7 +893,7 @@ remoteCheckDN (gnutls_x509_crt_t cert)
err = gnutls_x509_crt_get_dn (cert, name, &namesize); err = gnutls_x509_crt_get_dn (cert, name, &namesize);
if (err != 0) { if (err != 0) {
qemudLog (QEMUD_ERR, qemudLog (QEMUD_ERR,
"remoteCheckDN: gnutls_x509_cert_get_dn: %s", _("remoteCheckDN: gnutls_x509_cert_get_dn: %s"),
gnutls_strerror (err)); gnutls_strerror (err));
return 0; return 0;
} }
@ -908,7 +912,7 @@ remoteCheckDN (gnutls_x509_crt_t cert)
#ifdef ENABLE_DEBUG #ifdef ENABLE_DEBUG
/* Print the client's DN. */ /* Print the client's DN. */
qemudLog (QEMUD_DEBUG, qemudLog (QEMUD_DEBUG,
"remoteCheckDN: failed: client DN is %s", name); _("remoteCheckDN: failed: client DN is %s"), name);
#endif #endif
return 0; // Not found. return 0; // Not found.
@ -924,36 +928,42 @@ remoteCheckCertificate (gnutls_session_t session)
time_t now; time_t now;
if ((ret = gnutls_certificate_verify_peers2 (session, &status)) < 0){ if ((ret = gnutls_certificate_verify_peers2 (session, &status)) < 0){
qemudLog (QEMUD_ERR, "remoteCheckCertificate: verify failed: %s", qemudLog (QEMUD_ERR, _("remoteCheckCertificate: verify failed: %s"),
gnutls_strerror (ret)); gnutls_strerror (ret));
return -1; return -1;
} }
if (status != 0) { if (status != 0) {
if (status & GNUTLS_CERT_INVALID) if (status & GNUTLS_CERT_INVALID)
qemudLog (QEMUD_ERR, "remoteCheckCertificate: the client certificate is not trusted."); qemudLog (QEMUD_ERR, _("remoteCheckCertificate: "
"the client certificate is not trusted."));
if (status & GNUTLS_CERT_SIGNER_NOT_FOUND) if (status & GNUTLS_CERT_SIGNER_NOT_FOUND)
qemudLog (QEMUD_ERR, "remoteCheckCertificate: the client certificate hasn't got a known issuer."); qemudLog (QEMUD_ERR, _("remoteCheckCertificate: the client "
"certificate has unknown issuer."));
if (status & GNUTLS_CERT_REVOKED) if (status & GNUTLS_CERT_REVOKED)
qemudLog (QEMUD_ERR, "remoteCheckCertificate: the client certificate has been revoked."); qemudLog (QEMUD_ERR, _("remoteCheckCertificate: "
"the client certificate has been revoked."));
#ifndef GNUTLS_1_0_COMPAT #ifndef GNUTLS_1_0_COMPAT
if (status & GNUTLS_CERT_INSECURE_ALGORITHM) if (status & GNUTLS_CERT_INSECURE_ALGORITHM)
qemudLog (QEMUD_ERR, "remoteCheckCertificate: the client certificate uses an insecure algorithm."); qemudLog (QEMUD_ERR,
_("remoteCheckCertificate: the client certificate"
" uses an insecure algorithm."));
#endif #endif
return -1; return -1;
} }
if (gnutls_certificate_type_get (session) != GNUTLS_CRT_X509) { if (gnutls_certificate_type_get (session) != GNUTLS_CRT_X509) {
qemudLog (QEMUD_ERR, "remoteCheckCertificate: certificate is not X.509"); qemudLog (QEMUD_ERR, _("remoteCheckCertificate: "
"certificate is not X.509"));
return -1; return -1;
} }
if (!(certs = gnutls_certificate_get_peers(session, &nCerts))) { if (!(certs = gnutls_certificate_get_peers(session, &nCerts))) {
qemudLog (QEMUD_ERR, "remoteCheckCertificate: no peers"); qemudLog (QEMUD_ERR, _("remoteCheckCertificate: no peers"));
return -1; return -1;
} }
@ -963,7 +973,8 @@ remoteCheckCertificate (gnutls_session_t session)
gnutls_x509_crt_t cert; gnutls_x509_crt_t cert;
if (gnutls_x509_crt_init (&cert) < 0) { if (gnutls_x509_crt_init (&cert) < 0) {
qemudLog (QEMUD_ERR, "remoteCheckCertificate: gnutls_x509_crt_init failed"); qemudLog (QEMUD_ERR,
_("remoteCheckCertificate: gnutls_x509_crt_init failed"));
return -1; return -1;
} }
@ -973,13 +984,15 @@ remoteCheckCertificate (gnutls_session_t session)
} }
if (gnutls_x509_crt_get_expiration_time (cert) < now) { if (gnutls_x509_crt_get_expiration_time (cert) < now) {
qemudLog (QEMUD_ERR, "remoteCheckCertificate: the client certificate has expired"); qemudLog (QEMUD_ERR, _("remoteCheckCertificate: "
"the client certificate has expired"));
gnutls_x509_crt_deinit (cert); gnutls_x509_crt_deinit (cert);
return -1; return -1;
} }
if (gnutls_x509_crt_get_activation_time (cert) > now) { if (gnutls_x509_crt_get_activation_time (cert) > now) {
qemudLog (QEMUD_ERR, "remoteCheckCertificate: the client certificate is not yet activated"); qemudLog (QEMUD_ERR, _("remoteCheckCertificate: the client "
"certificate is not yet activated"));
gnutls_x509_crt_deinit (cert); gnutls_x509_crt_deinit (cert);
return -1; return -1;
} }
@ -987,7 +1000,7 @@ remoteCheckCertificate (gnutls_session_t session)
if (i == 0) { if (i == 0) {
if (!remoteCheckDN (cert)) { if (!remoteCheckDN (cert)) {
/* This is the most common error: make it informative. */ /* This is the most common error: make it informative. */
qemudLog (QEMUD_ERR, "remoteCheckCertificate: client's Distinguished Name is not on the list of allowed clients (tls_allowed_dn_list). Use 'openssl x509 -in clientcert.pem -text' to view the Distinguished Name field in the client certificate, or run this daemon with --verbose option."); qemudLog (QEMUD_ERR, _("remoteCheckCertificate: client's Distinguished Name is not on the list of allowed clients (tls_allowed_dn_list). Use 'openssl x509 -in clientcert.pem -text' to view the Distinguished Name field in the client certificate, or run this daemon with --verbose option."));
gnutls_x509_crt_deinit (cert); gnutls_x509_crt_deinit (cert);
return -1; return -1;
} }
@ -1003,9 +1016,9 @@ remoteCheckAccess (struct qemud_client *client)
{ {
/* Verify client certificate. */ /* Verify client certificate. */
if (remoteCheckCertificate (client->tlssession) == -1) { if (remoteCheckCertificate (client->tlssession) == -1) {
qemudLog (QEMUD_ERR, "remoteCheckCertificate: failed to verify client's certificate"); qemudLog (QEMUD_ERR, _("remoteCheckCertificate: failed to verify client's certificate"));
if (!tls_no_verify_certificate) return -1; if (!tls_no_verify_certificate) return -1;
else qemudLog (QEMUD_INFO, "remoteCheckCertificate: tls_no_verify_certificate is set so the bad certificate is ignored"); else qemudLog (QEMUD_INFO, _("remoteCheckCertificate: tls_no_verify_certificate is set so the bad certificate is ignored"));
} }
/* Checks have succeeded. Write a '\1' byte back to the client to /* Checks have succeeded. Write a '\1' byte back to the client to
@ -1029,7 +1042,7 @@ static int qemudDispatchServer(struct qemud_server *server, struct qemud_socket
if ((fd = accept(sock->fd, (struct sockaddr *)&addr, &addrlen)) < 0) { if ((fd = accept(sock->fd, (struct sockaddr *)&addr, &addrlen)) < 0) {
if (errno == EAGAIN) if (errno == EAGAIN)
return 0; return 0;
qemudLog(QEMUD_ERR, "Failed to accept connection: %s", strerror(errno)); qemudLog(QEMUD_ERR, _("Failed to accept connection: %s"), strerror(errno));
return -1; return -1;
} }
@ -1087,7 +1100,7 @@ static int qemudDispatchServer(struct qemud_server *server, struct qemud_socket
if (qemudRegisterClientEvent (server, client, 0) < 0) if (qemudRegisterClientEvent (server, client, 0) < 0)
goto cleanup; goto cleanup;
} else { } else {
qemudLog (QEMUD_ERR, "TLS handshake failed: %s", qemudLog (QEMUD_ERR, _("TLS handshake failed: %s"),
gnutls_strerror (ret)); gnutls_strerror (ret));
goto cleanup; goto cleanup;
} }
@ -1152,7 +1165,7 @@ static int qemudClientReadBuf(struct qemud_server *server,
if ((ret = read (client->fd, data, len)) <= 0) { if ((ret = read (client->fd, data, len)) <= 0) {
if (ret == 0 || errno != EAGAIN) { if (ret == 0 || errno != EAGAIN) {
if (ret != 0) if (ret != 0)
qemudLog (QEMUD_ERR, "read: %s", strerror (errno)); qemudLog (QEMUD_ERR, _("read: %s"), strerror (errno));
qemudDispatchClientFailure(server, client); qemudDispatchClientFailure(server, client);
} }
return -1; return -1;
@ -1165,7 +1178,7 @@ static int qemudClientReadBuf(struct qemud_server *server,
if (ret == 0 || (ret != GNUTLS_E_AGAIN && if (ret == 0 || (ret != GNUTLS_E_AGAIN &&
ret != GNUTLS_E_INTERRUPTED)) { ret != GNUTLS_E_INTERRUPTED)) {
if (ret != 0) if (ret != 0)
qemudLog (QEMUD_ERR, "gnutls_record_recv: %s", qemudLog (QEMUD_ERR, _("gnutls_record_recv: %s"),
gnutls_strerror (ret)); gnutls_strerror (ret));
qemudDispatchClientFailure (server, client); qemudDispatchClientFailure (server, client);
} }
@ -1324,7 +1337,7 @@ static void qemudDispatchClientRead(struct qemud_server *server, struct qemud_cl
else if (qemudRegisterClientEvent (server, client, 1) < 0) else if (qemudRegisterClientEvent (server, client, 1) < 0)
qemudDispatchClientFailure (server, client); qemudDispatchClientFailure (server, client);
} else if (ret != GNUTLS_E_AGAIN && ret != GNUTLS_E_INTERRUPTED) { } else if (ret != GNUTLS_E_AGAIN && ret != GNUTLS_E_INTERRUPTED) {
qemudLog (QEMUD_ERR, "TLS handshake failed: %s", qemudLog (QEMUD_ERR, _("TLS handshake failed: %s"),
gnutls_strerror (ret)); gnutls_strerror (ret));
qemudDispatchClientFailure (server, client); qemudDispatchClientFailure (server, client);
} else { } else {
@ -1349,7 +1362,7 @@ static int qemudClientWriteBuf(struct qemud_server *server,
if (!client->tlssession) { if (!client->tlssession) {
if ((ret = write(client->fd, data, len)) == -1) { if ((ret = write(client->fd, data, len)) == -1) {
if (errno != EAGAIN) { if (errno != EAGAIN) {
qemudLog (QEMUD_ERR, "write: %s", strerror (errno)); qemudLog (QEMUD_ERR, _("write: %s"), strerror (errno));
qemudDispatchClientFailure(server, client); qemudDispatchClientFailure(server, client);
} }
return -1; return -1;
@ -1360,7 +1373,7 @@ static int qemudClientWriteBuf(struct qemud_server *server,
qemudDispatchClientFailure (server, client); qemudDispatchClientFailure (server, client);
else if (ret < 0) { else if (ret < 0) {
if (ret != GNUTLS_E_INTERRUPTED && ret != GNUTLS_E_AGAIN) { if (ret != GNUTLS_E_INTERRUPTED && ret != GNUTLS_E_AGAIN) {
qemudLog (QEMUD_ERR, "gnutls_record_send: %s", qemudLog (QEMUD_ERR, _("gnutls_record_send: %s"),
gnutls_strerror (ret)); gnutls_strerror (ret));
qemudDispatchClientFailure (server, client); qemudDispatchClientFailure (server, client);
} }
@ -1464,7 +1477,7 @@ static void qemudDispatchClientWrite(struct qemud_server *server, struct qemud_c
else if (qemudRegisterClientEvent (server, client, 1)) else if (qemudRegisterClientEvent (server, client, 1))
qemudDispatchClientFailure (server, client); qemudDispatchClientFailure (server, client);
} else if (ret != GNUTLS_E_AGAIN && ret != GNUTLS_E_INTERRUPTED) { } else if (ret != GNUTLS_E_AGAIN && ret != GNUTLS_E_INTERRUPTED) {
qemudLog (QEMUD_ERR, "TLS handshake failed: %s", qemudLog (QEMUD_ERR, _("TLS handshake failed: %s"),
gnutls_strerror (ret)); gnutls_strerror (ret));
qemudDispatchClientFailure (server, client); qemudDispatchClientFailure (server, client);
} else { } else {
@ -1572,7 +1585,7 @@ static int qemudOneLoop(void) {
if (errors) { if (errors) {
sig_errors -= errors; sig_errors -= errors;
qemudLog (QEMUD_ERR, qemudLog (QEMUD_ERR,
"Signal handler reported %d errors: last error: %s", _("Signal handler reported %d errors: last error: %s"),
errors, strerror (sig_lasterrno)); errors, strerror (sig_lasterrno));
return -1; return -1;
} }
@ -1668,14 +1681,14 @@ remoteConfigGetStringList(virConfPtr conf, const char *key, char ***list_arg,
list = malloc (2 * sizeof (*list)); list = malloc (2 * sizeof (*list));
if (list == NULL) { if (list == NULL) {
qemudLog (QEMUD_ERR, qemudLog (QEMUD_ERR,
"failed to allocate memory for %s config list", key); _("failed to allocate memory for %s config list"), key);
return -1; return -1;
} }
list[0] = strdup (p->str); list[0] = strdup (p->str);
list[1] = NULL; list[1] = NULL;
if (list[0] == NULL) { if (list[0] == NULL) {
qemudLog (QEMUD_ERR, qemudLog (QEMUD_ERR,
"failed to allocate memory for %s config list value", _("failed to allocate memory for %s config list value"),
key); key);
free (list); free (list);
return -1; return -1;
@ -1690,13 +1703,13 @@ remoteConfigGetStringList(virConfPtr conf, const char *key, char ***list_arg,
list = calloc (1+len, sizeof (*list)); list = calloc (1+len, sizeof (*list));
if (list == NULL) { if (list == NULL) {
qemudLog (QEMUD_ERR, qemudLog (QEMUD_ERR,
"failed to allocate memory for %s config list", key); _("failed to allocate memory for %s config list"), key);
return -1; return -1;
} }
for (i = 0, pp = p->list; pp; ++i, pp = pp->next) { for (i = 0, pp = p->list; pp; ++i, pp = pp->next) {
if (pp->type != VIR_CONF_STRING) { if (pp->type != VIR_CONF_STRING) {
qemudLog (QEMUD_ERR, "remoteReadConfigFile: %s: %s:" qemudLog (QEMUD_ERR, _("remoteReadConfigFile: %s: %s:"
" must be a string or list of strings\n", " must be a string or list of strings\n"),
filename, key); filename, key);
free (list); free (list);
return -1; return -1;
@ -1707,8 +1720,8 @@ remoteConfigGetStringList(virConfPtr conf, const char *key, char ***list_arg,
for (j = 0 ; j < i ; j++) for (j = 0 ; j < i ; j++)
free (list[j]); free (list[j]);
free (list); free (list);
qemudLog (QEMUD_ERR, "failed to allocate memory" qemudLog (QEMUD_ERR, _("failed to allocate memory"
" for %s config list value", key); " for %s config list value"), key);
return -1; return -1;
} }
@ -1718,8 +1731,8 @@ remoteConfigGetStringList(virConfPtr conf, const char *key, char ***list_arg,
} }
default: default:
qemudLog (QEMUD_ERR, "remoteReadConfigFile: %s: %s:" qemudLog (QEMUD_ERR, _("remoteReadConfigFile: %s: %s:"
" must be a string or list of strings\n", " must be a string or list of strings\n"),
filename, key); filename, key);
return -1; return -1;
} }
@ -1735,8 +1748,8 @@ checkType (virConfValuePtr p, const char *filename,
{ {
if (p->type != required_type) { if (p->type != required_type) {
qemudLog (QEMUD_ERR, qemudLog (QEMUD_ERR,
"remoteReadConfigFile: %s: %s: invalid type:" _("remoteReadConfigFile: %s: %s: invalid type:"
" got %s; expected %s\n", filename, key, " got %s; expected %s\n"), filename, key,
virConfTypeName (p->type), virConfTypeName (p->type),
virConfTypeName (required_type)); virConfTypeName (required_type));
return -1; return -1;
@ -1756,7 +1769,7 @@ checkType (virConfValuePtr p, const char *filename,
goto free_and_fail; \ goto free_and_fail; \
(var_name) = strdup (p->str); \ (var_name) = strdup (p->str); \
if ((var_name) == NULL) { \ if ((var_name) == NULL) { \
qemudLog (QEMUD_ERR, "remoteReadConfigFile: %s\n", \ qemudLog (QEMUD_ERR, _("remoteReadConfigFile: %s\n"), \
strerror (errno)); \ strerror (errno)); \
goto free_and_fail; \ goto free_and_fail; \
} \ } \
@ -1799,7 +1812,9 @@ static int remoteConfigGetAuth(virConfPtr conf, const char *key, int *auth, cons
*auth = REMOTE_AUTH_POLKIT; *auth = REMOTE_AUTH_POLKIT;
#endif #endif
} else { } else {
qemudLog (QEMUD_ERR, "remoteReadConfigFile: %s: %s: unsupported auth %s\n", filename, key, p->str); qemudLog (QEMUD_ERR,
_("remoteReadConfigFile: %s: %s: unsupported auth %s\n"),
filename, key, p->str);
return -1; return -1;
} }
@ -1873,11 +1888,12 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename)
GET_CONF_STR (conf, filename, unix_sock_group); GET_CONF_STR (conf, filename, unix_sock_group);
if (unix_sock_group) { if (unix_sock_group) {
if (getuid() != 0) { if (getuid() != 0) {
qemudLog (QEMUD_WARN, "Cannot set group when not running as root"); qemudLog (QEMUD_WARN,
_("Cannot set group when not running as root"));
} else { } else {
struct group *grp = getgrnam(unix_sock_group); struct group *grp = getgrnam(unix_sock_group);
if (!grp) { if (!grp) {
qemudLog (QEMUD_ERR, "Failed to lookup group '%s'", qemudLog (QEMUD_ERR, _("Failed to lookup group '%s'"),
unix_sock_group); unix_sock_group);
goto free_and_fail; goto free_and_fail;
} }
@ -1890,7 +1906,7 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename)
GET_CONF_STR (conf, filename, unix_sock_ro_perms); GET_CONF_STR (conf, filename, unix_sock_ro_perms);
if (unix_sock_ro_perms) { if (unix_sock_ro_perms) {
if (xstrtol_i (unix_sock_ro_perms, NULL, 8, &unix_sock_ro_mask) != 0) { if (xstrtol_i (unix_sock_ro_perms, NULL, 8, &unix_sock_ro_mask) != 0) {
qemudLog (QEMUD_ERR, "Failed to parse mode '%s'", qemudLog (QEMUD_ERR, _("Failed to parse mode '%s'"),
unix_sock_ro_perms); unix_sock_ro_perms);
goto free_and_fail; goto free_and_fail;
} }
@ -1901,7 +1917,7 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename)
GET_CONF_STR (conf, filename, unix_sock_rw_perms); GET_CONF_STR (conf, filename, unix_sock_rw_perms);
if (unix_sock_rw_perms) { if (unix_sock_rw_perms) {
if (xstrtol_i (unix_sock_rw_perms, NULL, 8, &unix_sock_rw_mask) != 0) { if (xstrtol_i (unix_sock_rw_perms, NULL, 8, &unix_sock_rw_mask) != 0) {
qemudLog (QEMUD_ERR, "Failed to parse mode '%s'", qemudLog (QEMUD_ERR, _("Failed to parse mode '%s'"),
unix_sock_rw_perms); unix_sock_rw_perms);
goto free_and_fail; goto free_and_fail;
} }
@ -2074,7 +2090,7 @@ int main(int argc, char **argv) {
if (pipe(sigpipe) < 0 || if (pipe(sigpipe) < 0 ||
qemudSetNonBlock(sigpipe[0]) < 0 || qemudSetNonBlock(sigpipe[0]) < 0 ||
qemudSetNonBlock(sigpipe[1]) < 0) { qemudSetNonBlock(sigpipe[1]) < 0) {
qemudLog(QEMUD_ERR, "Failed to create pipe: %s", qemudLog(QEMUD_ERR, _("Failed to create pipe: %s"),
strerror(errno)); strerror(errno));
goto error1; goto error1;
} }
@ -2094,7 +2110,7 @@ int main(int argc, char **argv) {
openlog("libvirtd", 0, 0); openlog("libvirtd", 0, 0);
pid = qemudGoDaemon(); pid = qemudGoDaemon();
if (pid < 0) { if (pid < 0) {
qemudLog(QEMUD_ERR, "Failed to fork as daemon: %s", qemudLog(QEMUD_ERR, _("Failed to fork as daemon: %s"),
strerror(errno)); strerror(errno));
goto error1; goto error1;
} }
@ -2128,7 +2144,7 @@ int main(int argc, char **argv) {
POLLIN, POLLIN,
qemudDispatchSignalEvent, qemudDispatchSignalEvent,
server) < 0) { server) < 0) {
qemudLog(QEMUD_ERR, "Failed to register callback for signal pipe"); qemudLog(QEMUD_ERR, _("Failed to register callback for signal pipe"));
ret = 3; ret = 3;
goto error2; goto error2;
} }

View File

@ -1,7 +1,7 @@
/* /*
* remote.c: code handling remote requests (from remote_internal.c) * remote.c: code handling remote requests (from remote_internal.c)
* *
* Copyright (C) 2007 Red Hat, Inc. * Copyright (C) 2007, 2008 Red Hat, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -2126,7 +2126,7 @@ remoteDispatchAuthSaslInit (struct qemud_server *server ATTRIBUTE_UNUSED,
REMOTE_DEBUG("Initialize SASL auth %d", client->fd); REMOTE_DEBUG("Initialize SASL auth %d", client->fd);
if (client->auth != REMOTE_AUTH_SASL || if (client->auth != REMOTE_AUTH_SASL ||
client->saslconn != NULL) { client->saslconn != NULL) {
qemudLog(QEMUD_ERR, "client tried invalid SASL init request"); qemudLog(QEMUD_ERR, _("client tried invalid SASL init request"));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
return -2; return -2;
} }
@ -2166,7 +2166,7 @@ remoteDispatchAuthSaslInit (struct qemud_server *server ATTRIBUTE_UNUSED,
free(localAddr); free(localAddr);
free(remoteAddr); free(remoteAddr);
if (err != SASL_OK) { if (err != SASL_OK) {
qemudLog(QEMUD_ERR, "sasl context setup failed %d (%s)", qemudLog(QEMUD_ERR, _("sasl context setup failed %d (%s)"),
err, sasl_errstring(err, NULL, NULL)); err, sasl_errstring(err, NULL, NULL));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
client->saslconn = NULL; client->saslconn = NULL;
@ -2180,7 +2180,7 @@ remoteDispatchAuthSaslInit (struct qemud_server *server ATTRIBUTE_UNUSED,
cipher = gnutls_cipher_get(client->tlssession); cipher = gnutls_cipher_get(client->tlssession);
if (!(ssf = (sasl_ssf_t)gnutls_cipher_get_key_size(cipher))) { if (!(ssf = (sasl_ssf_t)gnutls_cipher_get_key_size(cipher))) {
qemudLog(QEMUD_ERR, "cannot TLS get cipher size"); qemudLog(QEMUD_ERR, _("cannot TLS get cipher size"));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
sasl_dispose(&client->saslconn); sasl_dispose(&client->saslconn);
client->saslconn = NULL; client->saslconn = NULL;
@ -2190,7 +2190,7 @@ remoteDispatchAuthSaslInit (struct qemud_server *server ATTRIBUTE_UNUSED,
err = sasl_setprop(client->saslconn, SASL_SSF_EXTERNAL, &ssf); err = sasl_setprop(client->saslconn, SASL_SSF_EXTERNAL, &ssf);
if (err != SASL_OK) { if (err != SASL_OK) {
qemudLog(QEMUD_ERR, "cannot set SASL external SSF %d (%s)", qemudLog(QEMUD_ERR, _("cannot set SASL external SSF %d (%s)"),
err, sasl_errstring(err, NULL, NULL)); err, sasl_errstring(err, NULL, NULL));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
sasl_dispose(&client->saslconn); sasl_dispose(&client->saslconn);
@ -2219,7 +2219,7 @@ remoteDispatchAuthSaslInit (struct qemud_server *server ATTRIBUTE_UNUSED,
err = sasl_setprop(client->saslconn, SASL_SEC_PROPS, &secprops); err = sasl_setprop(client->saslconn, SASL_SEC_PROPS, &secprops);
if (err != SASL_OK) { if (err != SASL_OK) {
qemudLog(QEMUD_ERR, "cannot set SASL security props %d (%s)", qemudLog(QEMUD_ERR, _("cannot set SASL security props %d (%s)"),
err, sasl_errstring(err, NULL, NULL)); err, sasl_errstring(err, NULL, NULL));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
sasl_dispose(&client->saslconn); sasl_dispose(&client->saslconn);
@ -2236,7 +2236,7 @@ remoteDispatchAuthSaslInit (struct qemud_server *server ATTRIBUTE_UNUSED,
NULL, NULL,
NULL); NULL);
if (err != SASL_OK) { if (err != SASL_OK) {
qemudLog(QEMUD_ERR, "cannot list SASL mechanisms %d (%s)", qemudLog(QEMUD_ERR, _("cannot list SASL mechanisms %d (%s)"),
err, sasl_errdetail(client->saslconn)); err, sasl_errdetail(client->saslconn));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
sasl_dispose(&client->saslconn); sasl_dispose(&client->saslconn);
@ -2246,7 +2246,7 @@ remoteDispatchAuthSaslInit (struct qemud_server *server ATTRIBUTE_UNUSED,
REMOTE_DEBUG("Available mechanisms for client: '%s'", mechlist); REMOTE_DEBUG("Available mechanisms for client: '%s'", mechlist);
ret->mechlist = strdup(mechlist); ret->mechlist = strdup(mechlist);
if (!ret->mechlist) { if (!ret->mechlist) {
qemudLog(QEMUD_ERR, "cannot allocate mechlist"); qemudLog(QEMUD_ERR, _("cannot allocate mechlist"));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
sasl_dispose(&client->saslconn); sasl_dispose(&client->saslconn);
client->saslconn = NULL; client->saslconn = NULL;
@ -2271,7 +2271,7 @@ remoteSASLCheckSSF (struct qemud_client *client,
err = sasl_getprop(client->saslconn, SASL_SSF, &val); err = sasl_getprop(client->saslconn, SASL_SSF, &val);
if (err != SASL_OK) { if (err != SASL_OK) {
qemudLog(QEMUD_ERR, "cannot query SASL ssf on connection %d (%s)", qemudLog(QEMUD_ERR, _("cannot query SASL ssf on connection %d (%s)"),
err, sasl_errstring(err, NULL, NULL)); err, sasl_errstring(err, NULL, NULL));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
sasl_dispose(&client->saslconn); sasl_dispose(&client->saslconn);
@ -2281,7 +2281,7 @@ remoteSASLCheckSSF (struct qemud_client *client,
ssf = *(const int *)val; ssf = *(const int *)val;
REMOTE_DEBUG("negotiated an SSF of %d", ssf); REMOTE_DEBUG("negotiated an SSF of %d", ssf);
if (ssf < 56) { /* 56 is good for Kerberos */ if (ssf < 56) { /* 56 is good for Kerberos */
qemudLog(QEMUD_ERR, "negotiated SSF %d was not strong enough", ssf); qemudLog(QEMUD_ERR, _("negotiated SSF %d was not strong enough"), ssf);
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
sasl_dispose(&client->saslconn); sasl_dispose(&client->saslconn);
client->saslconn = NULL; client->saslconn = NULL;
@ -2310,7 +2310,8 @@ remoteSASLCheckAccess (struct qemud_server *server,
err = sasl_getprop(client->saslconn, SASL_USERNAME, &val); err = sasl_getprop(client->saslconn, SASL_USERNAME, &val);
if (err != SASL_OK) { if (err != SASL_OK) {
qemudLog(QEMUD_ERR, "cannot query SASL username on connection %d (%s)", qemudLog(QEMUD_ERR,
_("cannot query SASL username on connection %d (%s)"),
err, sasl_errstring(err, NULL, NULL)); err, sasl_errstring(err, NULL, NULL));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
sasl_dispose(&client->saslconn); sasl_dispose(&client->saslconn);
@ -2318,7 +2319,7 @@ remoteSASLCheckAccess (struct qemud_server *server,
return -1; return -1;
} }
if (val == NULL) { if (val == NULL) {
qemudLog(QEMUD_ERR, "no client username was found"); qemudLog(QEMUD_ERR, _("no client username was found"));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
sasl_dispose(&client->saslconn); sasl_dispose(&client->saslconn);
client->saslconn = NULL; client->saslconn = NULL;
@ -2328,7 +2329,7 @@ remoteSASLCheckAccess (struct qemud_server *server,
client->saslUsername = strdup((const char*)val); client->saslUsername = strdup((const char*)val);
if (client->saslUsername == NULL) { if (client->saslUsername == NULL) {
qemudLog(QEMUD_ERR, "out of memory copying username"); qemudLog(QEMUD_ERR, _("out of memory copying username"));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
sasl_dispose(&client->saslconn); sasl_dispose(&client->saslconn);
client->saslconn = NULL; client->saslconn = NULL;
@ -2347,7 +2348,8 @@ remoteSASLCheckAccess (struct qemud_server *server,
} }
/* Denied */ /* Denied */
qemudLog(QEMUD_ERR, "SASL client %s not allowed in whitelist", client->saslUsername); qemudLog(QEMUD_ERR, _("SASL client %s not allowed in whitelist"),
client->saslUsername);
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
sasl_dispose(&client->saslconn); sasl_dispose(&client->saslconn);
client->saslconn = NULL; client->saslconn = NULL;
@ -2372,7 +2374,7 @@ remoteDispatchAuthSaslStart (struct qemud_server *server,
REMOTE_DEBUG("Start SASL auth %d", client->fd); REMOTE_DEBUG("Start SASL auth %d", client->fd);
if (client->auth != REMOTE_AUTH_SASL || if (client->auth != REMOTE_AUTH_SASL ||
client->saslconn == NULL) { client->saslconn == NULL) {
qemudLog(QEMUD_ERR, "client tried invalid SASL start request"); qemudLog(QEMUD_ERR, _("client tried invalid SASL start request"));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
return -2; return -2;
} }
@ -2388,7 +2390,7 @@ remoteDispatchAuthSaslStart (struct qemud_server *server,
&serveroutlen); &serveroutlen);
if (err != SASL_OK && if (err != SASL_OK &&
err != SASL_CONTINUE) { err != SASL_CONTINUE) {
qemudLog(QEMUD_ERR, "sasl start failed %d (%s)", qemudLog(QEMUD_ERR, _("sasl start failed %d (%s)"),
err, sasl_errdetail(client->saslconn)); err, sasl_errdetail(client->saslconn));
sasl_dispose(&client->saslconn); sasl_dispose(&client->saslconn);
client->saslconn = NULL; client->saslconn = NULL;
@ -2396,7 +2398,8 @@ remoteDispatchAuthSaslStart (struct qemud_server *server,
return -2; return -2;
} }
if (serveroutlen > REMOTE_AUTH_SASL_DATA_MAX) { if (serveroutlen > REMOTE_AUTH_SASL_DATA_MAX) {
qemudLog(QEMUD_ERR, "sasl start reply data too long %d", serveroutlen); qemudLog(QEMUD_ERR, _("sasl start reply data too long %d"),
serveroutlen);
sasl_dispose(&client->saslconn); sasl_dispose(&client->saslconn);
client->saslconn = NULL; client->saslconn = NULL;
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
@ -2451,7 +2454,7 @@ remoteDispatchAuthSaslStep (struct qemud_server *server,
REMOTE_DEBUG("Step SASL auth %d", client->fd); REMOTE_DEBUG("Step SASL auth %d", client->fd);
if (client->auth != REMOTE_AUTH_SASL || if (client->auth != REMOTE_AUTH_SASL ||
client->saslconn == NULL) { client->saslconn == NULL) {
qemudLog(QEMUD_ERR, "client tried invalid SASL start request"); qemudLog(QEMUD_ERR, _("client tried invalid SASL start request"));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
return -2; return -2;
} }
@ -2466,7 +2469,7 @@ remoteDispatchAuthSaslStep (struct qemud_server *server,
&serveroutlen); &serveroutlen);
if (err != SASL_OK && if (err != SASL_OK &&
err != SASL_CONTINUE) { err != SASL_CONTINUE) {
qemudLog(QEMUD_ERR, "sasl step failed %d (%s)", qemudLog(QEMUD_ERR, _("sasl step failed %d (%s)"),
err, sasl_errdetail(client->saslconn)); err, sasl_errdetail(client->saslconn));
sasl_dispose(&client->saslconn); sasl_dispose(&client->saslconn);
client->saslconn = NULL; client->saslconn = NULL;
@ -2475,7 +2478,8 @@ remoteDispatchAuthSaslStep (struct qemud_server *server,
} }
if (serveroutlen > REMOTE_AUTH_SASL_DATA_MAX) { if (serveroutlen > REMOTE_AUTH_SASL_DATA_MAX) {
qemudLog(QEMUD_ERR, "sasl step reply data too long %d", serveroutlen); qemudLog(QEMUD_ERR, _("sasl step reply data too long %d"),
serveroutlen);
sasl_dispose(&client->saslconn); sasl_dispose(&client->saslconn);
client->saslconn = NULL; client->saslconn = NULL;
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
@ -2524,7 +2528,7 @@ remoteDispatchAuthSaslInit (struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED, void *args ATTRIBUTE_UNUSED,
remote_auth_sasl_init_ret *ret ATTRIBUTE_UNUSED) remote_auth_sasl_init_ret *ret ATTRIBUTE_UNUSED)
{ {
qemudLog(QEMUD_ERR, "client tried unsupported SASL init request"); qemudLog(QEMUD_ERR, _("client tried unsupported SASL init request"));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
return -1; return -1;
} }
@ -2536,7 +2540,7 @@ remoteDispatchAuthSaslStart (struct qemud_server *server ATTRIBUTE_UNUSED,
remote_auth_sasl_start_args *args ATTRIBUTE_UNUSED, remote_auth_sasl_start_args *args ATTRIBUTE_UNUSED,
remote_auth_sasl_start_ret *ret ATTRIBUTE_UNUSED) remote_auth_sasl_start_ret *ret ATTRIBUTE_UNUSED)
{ {
qemudLog(QEMUD_ERR, "client tried unsupported SASL start request"); qemudLog(QEMUD_ERR, _("client tried unsupported SASL start request"));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
return -1; return -1;
} }
@ -2548,7 +2552,7 @@ remoteDispatchAuthSaslStep (struct qemud_server *server ATTRIBUTE_UNUSED,
remote_auth_sasl_step_args *args ATTRIBUTE_UNUSED, remote_auth_sasl_step_args *args ATTRIBUTE_UNUSED,
remote_auth_sasl_step_ret *ret ATTRIBUTE_UNUSED) remote_auth_sasl_step_ret *ret ATTRIBUTE_UNUSED)
{ {
qemudLog(QEMUD_ERR, "client tried unsupported SASL step request"); qemudLog(QEMUD_ERR, _("client tried unsupported SASL step request"));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
return -1; return -1;
} }
@ -2562,7 +2566,8 @@ static int qemudGetSocketIdentity(int fd, uid_t *uid, pid_t *pid) {
unsigned int cr_len = sizeof (cr); unsigned int cr_len = sizeof (cr);
if (getsockopt (fd, SOL_SOCKET, SO_PEERCRED, &cr, &cr_len) < 0) { if (getsockopt (fd, SOL_SOCKET, SO_PEERCRED, &cr, &cr_len) < 0) {
qemudLog(QEMUD_ERR, "Failed to verify client credentials: %s", strerror(errno)); qemudLog(QEMUD_ERR, _("Failed to verify client credentials: %s"),
strerror(errno));
return -1; return -1;
} }
@ -2588,13 +2593,13 @@ remoteDispatchAuthPolkit (struct qemud_server *server ATTRIBUTE_UNUSED,
REMOTE_DEBUG("Start PolicyKit auth %d", client->fd); REMOTE_DEBUG("Start PolicyKit auth %d", client->fd);
if (client->auth != REMOTE_AUTH_POLKIT) { if (client->auth != REMOTE_AUTH_POLKIT) {
qemudLog(QEMUD_ERR, "client tried invalid PolicyKit init request"); qemudLog(QEMUD_ERR, _("client tried invalid PolicyKit init request"));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
return -2; return -2;
} }
if (qemudGetSocketIdentity(client->fd, &callerUid, &callerPid) < 0) { if (qemudGetSocketIdentity(client->fd, &callerUid, &callerPid) < 0) {
qemudLog(QEMUD_ERR, "cannot get peer socket identity"); qemudLog(QEMUD_ERR, _("cannot get peer socket identity"));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
return -2; return -2;
} }
@ -2604,7 +2609,7 @@ remoteDispatchAuthPolkit (struct qemud_server *server ATTRIBUTE_UNUSED,
change policykit policy anyway, so its pointless trying change policykit policy anyway, so its pointless trying
to restrict root */ to restrict root */
if (callerUid == 0) { if (callerUid == 0) {
qemudLog(QEMUD_INFO, "Allowing PID %d running as root", callerPid); qemudLog(QEMUD_INFO, _("Allowing PID %d running as root"), callerPid);
ret->complete = 1; ret->complete = 1;
client->auth = REMOTE_AUTH_NONE; client->auth = REMOTE_AUTH_NONE;
} else { } else {
@ -2618,17 +2623,21 @@ remoteDispatchAuthPolkit (struct qemud_server *server ATTRIBUTE_UNUSED,
"org.libvirt.unix.monitor" : "org.libvirt.unix.monitor" :
"org.libvirt.unix.manage"; "org.libvirt.unix.manage";
qemudLog(QEMUD_INFO, "Checking PID %d running as %d", callerPid, callerUid); qemudLog(QEMUD_INFO, _("Checking PID %d running as %d"),
callerPid, callerUid);
dbus_error_init(&err); dbus_error_init(&err);
if (!(pkcaller = polkit_caller_new_from_pid(server->sysbus, callerPid, &err))) { if (!(pkcaller = polkit_caller_new_from_pid(server->sysbus,
qemudLog(QEMUD_ERR, "Failed to lookup policy kit caller: %s", err.message); callerPid, &err))) {
qemudLog(QEMUD_ERR, _("Failed to lookup policy kit caller: %s"),
err.message);
dbus_error_free(&err); dbus_error_free(&err);
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
return -2; return -2;
} }
if (!(pkaction = polkit_action_new())) { if (!(pkaction = polkit_action_new())) {
qemudLog(QEMUD_ERR, "Failed to create polkit action %s\n", strerror(errno)); qemudLog(QEMUD_ERR, _("Failed to create polkit action %s\n"),
strerror(errno));
polkit_caller_unref(pkcaller); polkit_caller_unref(pkcaller);
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
return -2; return -2;
@ -2637,8 +2646,9 @@ remoteDispatchAuthPolkit (struct qemud_server *server ATTRIBUTE_UNUSED,
if (!(pkcontext = polkit_context_new()) || if (!(pkcontext = polkit_context_new()) ||
!polkit_context_init(pkcontext, &pkerr)) { !polkit_context_init(pkcontext, &pkerr)) {
qemudLog(QEMUD_ERR, "Failed to create polkit context %s\n", qemudLog(QEMUD_ERR, _("Failed to create polkit context %s\n"),
pkerr ? polkit_error_get_error_message(pkerr) : strerror(errno)); (pkerr ? polkit_error_get_error_message(pkerr)
: strerror(errno));
if (pkerr) if (pkerr)
polkit_error_free(pkerr); polkit_error_free(pkerr);
polkit_caller_unref(pkcaller); polkit_caller_unref(pkcaller);
@ -2648,18 +2658,24 @@ remoteDispatchAuthPolkit (struct qemud_server *server ATTRIBUTE_UNUSED,
return -2; return -2;
} }
pkresult = polkit_context_can_caller_do_action(pkcontext, pkaction, pkcaller); pkresult = polkit_context_can_caller_do_action(pkcontext, pkaction,
pkcaller);
polkit_context_unref(pkcontext); polkit_context_unref(pkcontext);
polkit_caller_unref(pkcaller); polkit_caller_unref(pkcaller);
polkit_action_unref(pkaction); polkit_action_unref(pkaction);
if (pkresult != POLKIT_RESULT_YES) { if (pkresult != POLKIT_RESULT_YES) {
qemudLog(QEMUD_ERR, "Policy kit denied action %s from pid %d, uid %d, result: %s\n", qemudLog(QEMUD_ERR,
action, callerPid, callerUid, polkit_result_to_string_representation(pkresult)); _("Policy kit denied action %s from pid %d, uid %d,"
" result: %s\n"),
action, callerPid, callerUid,
polkit_result_to_string_representation(pkresult));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
return -2; return -2;
} }
qemudLog(QEMUD_INFO, "Policy allowed action %s from pid %d, uid %d, result %s", qemudLog(QEMUD_INFO,
action, callerPid, callerUid, polkit_result_to_string_representation(pkresult)); _("Policy allowed action %s from pid %d, uid %d, result %s"),
action, callerPid, callerUid,
polkit_result_to_string_representation(pkresult));
ret->complete = 1; ret->complete = 1;
client->auth = REMOTE_AUTH_NONE; client->auth = REMOTE_AUTH_NONE;
} }
@ -2676,7 +2692,7 @@ remoteDispatchAuthPolkit (struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED, void *args ATTRIBUTE_UNUSED,
remote_auth_polkit_ret *ret ATTRIBUTE_UNUSED) remote_auth_polkit_ret *ret ATTRIBUTE_UNUSED)
{ {
qemudLog(QEMUD_ERR, "client tried unsupported PolicyKit init request"); qemudLog(QEMUD_ERR, _("client tried unsupported PolicyKit init request"));
remoteDispatchFailAuth(client, req); remoteDispatchFailAuth(client, req);
return -1; return -1;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2007 Red Hat, Inc. * Copyright (C) 2007, 2008 Red Hat, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -100,8 +100,8 @@ notifyRulesUpdated(const char *table,
argv[3] = NULL; argv[3] = NULL;
if (virRun(NULL, argv, NULL) < 0) if (virRun(NULL, argv, NULL) < 0)
qemudLog(QEMUD_WARN, "Failed to run '" LOKKIT_PATH " %s' : %s", qemudLog(QEMUD_WARN, _("Failed to run '" LOKKIT_PATH
arg, strerror(errno)); " %s' : %s"), arg, strerror(errno));
} }
static int static int
@ -148,7 +148,8 @@ notifyRulesRemoved(const char *table,
len = virFileReadAll(SYSCONF_DIR "/sysconfig/system-config-firewall", len = virFileReadAll(SYSCONF_DIR "/sysconfig/system-config-firewall",
MAX_FILE_LEN, &content); MAX_FILE_LEN, &content);
if (len < 0) { if (len < 0) {
qemudLog(QEMUD_WARN, "Failed to read " SYSCONF_DIR "/sysconfig/system-config-firewall"); qemudLog(QEMUD_WARN, _("Failed to read " SYSCONF_DIR
"/sysconfig/system-config-firewall"));
return; return;
} }
@ -175,7 +176,8 @@ notifyRulesRemoved(const char *table,
return; return;
write_error: write_error:
qemudLog(QEMUD_WARN, "Failed to write to " SYSCONF_DIR "/sysconfig/system-config-firewall : %s", qemudLog(QEMUD_WARN, _("Failed to write to " SYSCONF_DIR
"/sysconfig/system-config-firewall : %s"),
strerror(errno)); strerror(errno));
if (f) if (f)
fclose(f); fclose(f);
@ -239,13 +241,13 @@ iptRulesSave(iptRules *rules)
int err; int err;
if ((err = virFileMakePath(rules->dir))) { if ((err = virFileMakePath(rules->dir))) {
qemudLog(QEMUD_WARN, "Failed to create directory %s : %s", qemudLog(QEMUD_WARN, _("Failed to create directory %s : %s"),
rules->dir, strerror(err)); rules->dir, strerror(err));
return; return;
} }
if ((err = writeRules(rules->path, rules->rules, rules->nrules))) { if ((err = writeRules(rules->path, rules->rules, rules->nrules))) {
qemudLog(QEMUD_WARN, "Failed to saves iptables rules to %s : %s", qemudLog(QEMUD_WARN, _("Failed to saves iptables rules to %s : %s"),
rules->path, strerror(err)); rules->path, strerror(err));
return; return;
} }
@ -583,7 +585,9 @@ iptRulesReload(iptRules *rules)
rule->argv[rule->command_idx] = (char *) "--delete"; rule->argv[rule->command_idx] = (char *) "--delete";
if (virRun(NULL, rule->argv, NULL) < 0) if (virRun(NULL, rule->argv, NULL) < 0)
qemudLog(QEMUD_WARN, "Failed to remove iptables rule '%s' from chain '%s' in table '%s': %s", qemudLog(QEMUD_WARN,
_("Failed to remove iptables rule '%s'"
" from chain '%s' in table '%s': %s"),
rule->rule, rules->chain, rules->table, strerror(errno)); rule->rule, rules->chain, rules->table, strerror(errno));
rule->argv[rule->command_idx] = orig; rule->argv[rule->command_idx] = orig;
@ -591,7 +595,8 @@ iptRulesReload(iptRules *rules)
for (i = 0; i < rules->nrules; i++) for (i = 0; i < rules->nrules; i++)
if (virRun(NULL, rules->rules[i].argv, NULL) < 0) if (virRun(NULL, rules->rules[i].argv, NULL) < 0)
qemudLog(QEMUD_WARN, "Failed to add iptables rule '%s' to chain '%s' in table '%s': %s", qemudLog(QEMUD_WARN, _("Failed to add iptables rule '%s'"
" to chain '%s' in table '%s': %s"),
rules->rules[i].rule, rules->chain, rules->table, strerror(errno)); rules->rules[i].rule, rules->chain, rules->table, strerror(errno));
} }

View File

@ -410,14 +410,18 @@ static int qemudExtractVersionInfo(const char *qemu, int *version, int *flags) {
if (errno == EINTR) { if (errno == EINTR) {
goto rewait; goto rewait;
} }
qemudLog(QEMUD_ERR, "Unexpected exit status from qemu %d pid %lu", got, (unsigned long)child); qemudLog(QEMUD_ERR,
_("Unexpected exit status from qemu %d pid %lu"),
got, (unsigned long)child);
ret = -1; ret = -1;
} }
/* Check & log unexpected exit status, but don't fail, /* Check & log unexpected exit status, but don't fail,
* as there's really no need to throw an error if we did * as there's really no need to throw an error if we did
* actually read a valid version number above */ * actually read a valid version number above */
if (WEXITSTATUS(got) != 1) { if (WEXITSTATUS(got) != 1) {
qemudLog(QEMUD_WARN, "Unexpected exit status '%d', qemu probably failed", got); qemudLog(QEMUD_WARN,
_("Unexpected exit status '%d', qemu probably failed"),
got);
} }
return ret; return ret;
@ -2510,21 +2514,25 @@ qemudLoadConfig(struct qemud_driver *driver,
if (!(def = qemudParseVMDef(NULL, driver, xml, file))) { if (!(def = qemudParseVMDef(NULL, driver, xml, file))) {
virErrorPtr err = virGetLastError(); virErrorPtr err = virGetLastError();
qemudLog(QEMUD_WARN, "Error parsing QEMU guest config '%s' : %s", qemudLog(QEMUD_WARN, _("Error parsing QEMU guest config '%s' : %s"),
path, err ? err->message : path, (err ? err->message :
"BUG: unknown error - please report it\n"); _("BUG: unknown error - please report it\n")));
return NULL; return NULL;
} }
if (!virFileMatchesNameSuffix(file, def->name, ".xml")) { if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
qemudLog(QEMUD_WARN, "QEMU guest config filename '%s' does not match guest name '%s'", qemudLog(QEMUD_WARN,
_("QEMU guest config filename '%s'"
" does not match guest name '%s'"),
path, def->name); path, def->name);
qemudFreeVMDef(def); qemudFreeVMDef(def);
return NULL; return NULL;
} }
if (!(vm = qemudAssignVMDef(NULL, driver, def))) { if (!(vm = qemudAssignVMDef(NULL, driver, def))) {
qemudLog(QEMUD_WARN, "Failed to load QEMU guest config '%s': out of memory", path); qemudLog(QEMUD_WARN,
_("Failed to load QEMU guest config '%s': out of memory"),
path);
qemudFreeVMDef(def); qemudFreeVMDef(def);
return NULL; return NULL;
} }
@ -2551,20 +2559,23 @@ qemudLoadNetworkConfig(struct qemud_driver *driver,
if (!(def = qemudParseNetworkDef(NULL, driver, xml, file))) { if (!(def = qemudParseNetworkDef(NULL, driver, xml, file))) {
virErrorPtr err = virGetLastError(); virErrorPtr err = virGetLastError();
qemudLog(QEMUD_WARN, "Error parsing network config '%s' : %s", qemudLog(QEMUD_WARN, _("Error parsing network config '%s' : %s"),
path, err->message); path, err->message);
return NULL; return NULL;
} }
if (!virFileMatchesNameSuffix(file, def->name, ".xml")) { if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
qemudLog(QEMUD_WARN, "Network config filename '%s' does not match network name '%s'", qemudLog(QEMUD_WARN,
_("Network config filename '%s'"
" does not match network name '%s'"),
path, def->name); path, def->name);
qemudFreeNetworkDef(def); qemudFreeNetworkDef(def);
return NULL; return NULL;
} }
if (!(network = qemudAssignNetworkDef(NULL, driver, def))) { if (!(network = qemudAssignNetworkDef(NULL, driver, def))) {
qemudLog(QEMUD_WARN, "Failed to load network config '%s': out of memory", path); qemudLog(QEMUD_WARN,
_("Failed to load network config '%s': out of memory"), path);
qemudFreeNetworkDef(def); qemudFreeNetworkDef(def);
return NULL; return NULL;
} }
@ -2591,7 +2602,7 @@ int qemudScanConfigDir(struct qemud_driver *driver,
if (!(dir = opendir(configDir))) { if (!(dir = opendir(configDir))) {
if (errno == ENOENT) if (errno == ENOENT)
return 0; return 0;
qemudLog(QEMUD_ERR, "Failed to open dir '%s': %s", qemudLog(QEMUD_ERR, _("Failed to open dir '%s': %s"),
configDir, strerror(errno)); configDir, strerror(errno));
return -1; return -1;
} }
@ -2608,13 +2619,14 @@ int qemudScanConfigDir(struct qemud_driver *driver,
continue; continue;
if (virFileBuildPath(configDir, entry->d_name, NULL, path, PATH_MAX) < 0) { if (virFileBuildPath(configDir, entry->d_name, NULL, path, PATH_MAX) < 0) {
qemudLog(QEMUD_WARN, "Config filename '%s/%s' is too long", qemudLog(QEMUD_WARN, _("Config filename '%s/%s' is too long"),
configDir, entry->d_name); configDir, entry->d_name);
continue; continue;
} }
if (virFileBuildPath(autostartDir, entry->d_name, NULL, autostartLink, PATH_MAX) < 0) { if (virFileBuildPath(autostartDir, entry->d_name, NULL,
qemudLog(QEMUD_WARN, "Autostart link path '%s/%s' is too long", autostartLink, PATH_MAX) < 0) {
qemudLog(QEMUD_WARN, _("Autostart link path '%s/%s' is too long"),
autostartDir, entry->d_name); autostartDir, entry->d_name);
continue; continue;
} }

View File

@ -71,7 +71,7 @@ static int qemudSetCloseExec(int fd) {
goto error; goto error;
return 0; return 0;
error: error:
qemudLog(QEMUD_ERR, "Failed to set close-on-exec file descriptor flag"); qemudLog(QEMUD_ERR, _("Failed to set close-on-exec file descriptor flag"));
return -1; return -1;
} }
@ -85,7 +85,7 @@ static int qemudSetNonBlock(int fd) {
goto error; goto error;
return 0; return 0;
error: error:
qemudLog(QEMUD_ERR, "Failed to set non-blocking file descriptor flag"); qemudLog(QEMUD_ERR, _("Failed to set non-blocking file descriptor flag"));
return -1; return -1;
} }
@ -123,7 +123,7 @@ void qemudAutostartConfigs(struct qemud_driver *driver) {
!qemudIsActiveNetwork(network) && !qemudIsActiveNetwork(network) &&
qemudStartNetworkDaemon(NULL, driver, network) < 0) { qemudStartNetworkDaemon(NULL, driver, network) < 0) {
virErrorPtr err = virGetLastError(); virErrorPtr err = virGetLastError();
qemudLog(QEMUD_ERR, "Failed to autostart network '%s': %s", qemudLog(QEMUD_ERR, _("Failed to autostart network '%s': %s"),
network->def->name, err->message); network->def->name, err->message);
} }
@ -138,7 +138,7 @@ void qemudAutostartConfigs(struct qemud_driver *driver) {
!qemudIsActiveVM(vm) && !qemudIsActiveVM(vm) &&
qemudStartVMDaemon(NULL, driver, vm) < 0) { qemudStartVMDaemon(NULL, driver, vm) < 0) {
virErrorPtr err = virGetLastError(); virErrorPtr err = virGetLastError();
qemudLog(QEMUD_ERR, "Failed to autostart VM '%s': %s", qemudLog(QEMUD_ERR, _("Failed to autostart VM '%s': %s"),
vm->def->name, err->message); vm->def->name, err->message);
} }
@ -173,7 +173,7 @@ qemudStartup(void) {
goto out_of_memory; goto out_of_memory;
} else { } else {
if (!(pw = getpwuid(uid))) { if (!(pw = getpwuid(uid))) {
qemudLog(QEMUD_ERR, "Failed to find user record for uid '%d': %s", qemudLog(QEMUD_ERR, _("Failed to find user record for uid '%d': %s"),
uid, strerror(errno)); uid, strerror(errno));
goto out_of_memory; goto out_of_memory;
} }
@ -182,7 +182,7 @@ qemudStartup(void) {
goto snprintf_error; goto snprintf_error;
if (asprintf (&base, "%s/.libvirt", pw->pw_dir) == -1) { if (asprintf (&base, "%s/.libvirt", pw->pw_dir) == -1) {
qemudLog (QEMUD_ERR, "out of memory in asprintf"); qemudLog (QEMUD_ERR, _("out of memory in asprintf"));
goto out_of_memory; goto out_of_memory;
} }
} }
@ -223,11 +223,12 @@ qemudStartup(void) {
return 0; return 0;
snprintf_error: snprintf_error:
qemudLog(QEMUD_ERR, "Resulting path to long for buffer in qemudInitPaths()"); qemudLog(QEMUD_ERR,
_("Resulting path to long for buffer in qemudInitPaths()"));
return -1; return -1;
out_of_memory: out_of_memory:
qemudLog (QEMUD_ERR, "qemudStartup: out of memory"); qemudLog (QEMUD_ERR, _("qemudStartup: out of memory"));
free (base); free (base);
free(qemu_driver); free(qemu_driver);
qemu_driver = NULL; qemu_driver = NULL;
@ -245,7 +246,7 @@ qemudReload(void) {
qemudScanConfigs(qemu_driver); qemudScanConfigs(qemu_driver);
if (qemu_driver->iptables) { if (qemu_driver->iptables) {
qemudLog(QEMUD_INFO, "Reloading iptables rules"); qemudLog(QEMUD_INFO, _("Reloading iptables rules"));
iptablesReloadRules(qemu_driver->iptables); iptablesReloadRules(qemu_driver->iptables);
} }
@ -543,7 +544,7 @@ static int qemudWaitForMonitor(virConnectPtr conn,
/* Log, but ignore failures to write logfile for VM */ /* Log, but ignore failures to write logfile for VM */
if (errno == EINTR) if (errno == EINTR)
goto retry; goto retry;
qemudLog(QEMUD_WARN, "Unable to log VM console data: %s", qemudLog(QEMUD_WARN, _("Unable to log VM console data: %s"),
strerror(errno)); strerror(errno));
} }
return ret; return ret;
@ -656,15 +657,15 @@ static int qemudStartVMDaemon(virConnectPtr conn,
tmp = argv; tmp = argv;
while (*tmp) { while (*tmp) {
if (write(vm->logfile, *tmp, strlen(*tmp)) < 0) if (write(vm->logfile, *tmp, strlen(*tmp)) < 0)
qemudLog(QEMUD_WARN, "Unable to write argv to logfile %d: %s", qemudLog(QEMUD_WARN, _("Unable to write argv to logfile %d: %s"),
errno, strerror(errno)); errno, strerror(errno));
if (write(vm->logfile, " ", 1) < 0) if (write(vm->logfile, " ", 1) < 0)
qemudLog(QEMUD_WARN, "Unable to write argv to logfile %d: %s", qemudLog(QEMUD_WARN, _("Unable to write argv to logfile %d: %s"),
errno, strerror(errno)); errno, strerror(errno));
tmp++; tmp++;
} }
if (write(vm->logfile, "\n", 1) < 0) if (write(vm->logfile, "\n", 1) < 0)
qemudLog(QEMUD_WARN, "Unable to write argv to logfile %d: %s", qemudLog(QEMUD_WARN, _("Unable to write argv to logfile %d: %s"),
errno, strerror(errno)); errno, strerror(errno));
if (virExecNonBlock(conn, argv, &vm->pid, if (virExecNonBlock(conn, argv, &vm->pid,
@ -737,7 +738,7 @@ static int qemudVMData(struct qemud_driver *driver ATTRIBUTE_UNUSED,
/* Log, but ignore failures to write logfile for VM */ /* Log, but ignore failures to write logfile for VM */
if (errno == EINTR) if (errno == EINTR)
goto retry; goto retry;
qemudLog(QEMUD_WARN, "Unable to log VM console data: %s", qemudLog(QEMUD_WARN, _("Unable to log VM console data: %s"),
strerror(errno)); strerror(errno));
} }
} }
@ -751,7 +752,7 @@ static void qemudShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
if (!qemudIsActiveVM(vm)) if (!qemudIsActiveVM(vm))
return; return;
qemudLog(QEMUD_INFO, "Shutting down VM '%s'", vm->def->name); qemudLog(QEMUD_INFO, _("Shutting down VM '%s'"), vm->def->name);
kill(vm->pid, SIGTERM); kill(vm->pid, SIGTERM);
@ -762,7 +763,8 @@ static void qemudShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
virEventRemoveHandle(vm->stderr); virEventRemoveHandle(vm->stderr);
if (close(vm->logfile) < 0) if (close(vm->logfile) < 0)
qemudLog(QEMUD_WARN, "Unable to close logfile %d: %s", errno, strerror(errno)); qemudLog(QEMUD_WARN, _("Unable to close logfile %d: %s"),
errno, strerror(errno));
close(vm->stdout); close(vm->stdout);
close(vm->stderr); close(vm->stderr);
if (vm->monitor != -1) if (vm->monitor != -1)
@ -775,7 +777,7 @@ static void qemudShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
if (waitpid(vm->pid, NULL, WNOHANG) != vm->pid) { if (waitpid(vm->pid, NULL, WNOHANG) != vm->pid) {
kill(vm->pid, SIGKILL); kill(vm->pid, SIGKILL);
if (waitpid(vm->pid, NULL, 0) != vm->pid) { if (waitpid(vm->pid, NULL, 0) != vm->pid) {
qemudLog(QEMUD_WARN, "Got unexpected pid, damn"); qemudLog(QEMUD_WARN, _("Got unexpected pid, damn"));
} }
} }
@ -1219,13 +1221,13 @@ static int qemudStartNetworkDaemon(virConnectPtr conn,
err_delbr1: err_delbr1:
if (network->def->ipAddress[0] && if (network->def->ipAddress[0] &&
(err = brSetInterfaceUp(driver->brctl, network->bridge, 0))) { (err = brSetInterfaceUp(driver->brctl, network->bridge, 0))) {
qemudLog(QEMUD_WARN, "Failed to bring down bridge '%s' : %s", qemudLog(QEMUD_WARN, _("Failed to bring down bridge '%s' : %s"),
network->bridge, strerror(err)); network->bridge, strerror(err));
} }
err_delbr: err_delbr:
if ((err = brDeleteBridge(driver->brctl, network->bridge))) { if ((err = brDeleteBridge(driver->brctl, network->bridge))) {
qemudLog(QEMUD_WARN, "Failed to delete bridge '%s' : %s\n", qemudLog(QEMUD_WARN, _("Failed to delete bridge '%s' : %s\n"),
network->bridge, strerror(err)); network->bridge, strerror(err));
} }
@ -1238,7 +1240,7 @@ static int qemudShutdownNetworkDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
struct qemud_network *network) { struct qemud_network *network) {
int err; int err;
qemudLog(QEMUD_INFO, "Shutting down network '%s'", network->def->name); qemudLog(QEMUD_INFO, _("Shutting down network '%s'"), network->def->name);
if (!qemudIsActiveNetwork(network)) if (!qemudIsActiveNetwork(network))
return 0; return 0;
@ -1250,12 +1252,12 @@ static int qemudShutdownNetworkDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
if (network->def->ipAddress[0] && if (network->def->ipAddress[0] &&
(err = brSetInterfaceUp(driver->brctl, network->bridge, 0))) { (err = brSetInterfaceUp(driver->brctl, network->bridge, 0))) {
qemudLog(QEMUD_WARN, "Failed to bring down bridge '%s' : %s\n", qemudLog(QEMUD_WARN, _("Failed to bring down bridge '%s' : %s\n"),
network->bridge, strerror(err)); network->bridge, strerror(err));
} }
if ((err = brDeleteBridge(driver->brctl, network->bridge))) { if ((err = brDeleteBridge(driver->brctl, network->bridge))) {
qemudLog(QEMUD_WARN, "Failed to delete bridge '%s' : %s\n", qemudLog(QEMUD_WARN, _("Failed to delete bridge '%s' : %s\n"),
network->bridge, strerror(err)); network->bridge, strerror(err));
} }
@ -1263,7 +1265,7 @@ static int qemudShutdownNetworkDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
waitpid(network->dnsmasqPid, NULL, WNOHANG) != network->dnsmasqPid) { waitpid(network->dnsmasqPid, NULL, WNOHANG) != network->dnsmasqPid) {
kill(network->dnsmasqPid, SIGKILL); kill(network->dnsmasqPid, SIGKILL);
if (waitpid(network->dnsmasqPid, NULL, 0) != network->dnsmasqPid) if (waitpid(network->dnsmasqPid, NULL, 0) != network->dnsmasqPid)
qemudLog(QEMUD_WARN, "Got unexpected pid for dnsmasq\n"); qemudLog(QEMUD_WARN, _("Got unexpected pid for dnsmasq\n"));
} }
network->bridge[0] = '\0'; network->bridge[0] = '\0';
@ -1367,7 +1369,7 @@ static int qemudMonitorCommand(struct qemud_driver *driver ATTRIBUTE_UNUSED,
/* Log, but ignore failures to write logfile for VM */ /* Log, but ignore failures to write logfile for VM */
if (safewrite(vm->logfile, buf, strlen(buf)) < 0) if (safewrite(vm->logfile, buf, strlen(buf)) < 0)
qemudLog(QEMUD_WARN, "Unable to log VM console data: %s", qemudLog(QEMUD_WARN, _("Unable to log VM console data: %s"),
strerror(errno)); strerror(errno));
*reply = buf; *reply = buf;
@ -1377,7 +1379,7 @@ static int qemudMonitorCommand(struct qemud_driver *driver ATTRIBUTE_UNUSED,
if (buf) { if (buf) {
/* Log, but ignore failures to write logfile for VM */ /* Log, but ignore failures to write logfile for VM */
if (safewrite(vm->logfile, buf, strlen(buf)) < 0) if (safewrite(vm->logfile, buf, strlen(buf)) < 0)
qemudLog(QEMUD_WARN, "Unable to log VM console data: %s", qemudLog(QEMUD_WARN, _("Unable to log VM console data: %s"),
strerror(errno)); strerror(errno));
free(buf); free(buf);
} }
@ -2345,7 +2347,7 @@ static int qemudDomainUndefine(virDomainPtr dom) {
return -1; return -1;
if (unlink(vm->autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) if (unlink(vm->autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR)
qemudLog(QEMUD_WARN, "Failed to delete autostart link '%s': %s", qemudLog(QEMUD_WARN, _("Failed to delete autostart link '%s': %s"),
vm->autostartLink, strerror(errno)); vm->autostartLink, strerror(errno));
vm->configFile[0] = '\0'; vm->configFile[0] = '\0';
@ -2721,7 +2723,7 @@ static int qemudNetworkUndefine(virNetworkPtr net) {
return -1; return -1;
if (unlink(network->autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) if (unlink(network->autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR)
qemudLog(QEMUD_WARN, "Failed to delete autostart link '%s': %s", qemudLog(QEMUD_WARN, _("Failed to delete autostart link '%s': %s"),
network->autostartLink, strerror(errno)); network->autostartLink, strerror(errno));
network->configFile[0] = '\0'; network->configFile[0] = '\0';

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2007 Red Hat, Inc. * Copyright (C) 2007, 2008 Red Hat, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -99,8 +99,8 @@ virUUIDGenerate(unsigned char *uuid)
if ((err = virUUIDGenerateRandomBytes(uuid, VIR_UUID_BUFLEN))) if ((err = virUUIDGenerateRandomBytes(uuid, VIR_UUID_BUFLEN)))
qemudLog(QEMUD_WARN, qemudLog(QEMUD_WARN,
"Falling back to pseudorandom UUID, " _("Falling back to pseudorandom UUID,"
"failed to generate random bytes: %s", strerror(err)); " failed to generate random bytes: %s"), strerror(err));
return virUUIDGeneratePseudoRandomBytes(uuid, VIR_UUID_BUFLEN); return virUUIDGeneratePseudoRandomBytes(uuid, VIR_UUID_BUFLEN);
} }
@ -197,4 +197,3 @@ void virUUIDFormat(const unsigned char *uuid, char *uuidstr)
* tab-width: 4 * tab-width: 4
* End: * End:
*/ */