Drop localisation and checkpoint tracing in files not covered by the merge.

This commit is contained in:
Guus Sliepen 2009-09-29 15:19:55 +02:00
parent 7ea85043ac
commit 07a560eab6
11 changed files with 102 additions and 109 deletions

View file

@ -64,43 +64,43 @@ static void handle_control_data(struct bufferevent *event, void *data) {
} }
if(req.type == REQ_STOP) { if(req.type == REQ_STOP) {
logger(LOG_NOTICE, _("Got '%s' command"), "stop"); logger(LOG_NOTICE, "Got '%s' command", "stop");
event_loopexit(NULL); event_loopexit(NULL);
goto respond; goto respond;
} }
if(req.type == REQ_DUMP_NODES) { if(req.type == REQ_DUMP_NODES) {
logger(LOG_NOTICE, _("Got '%s' command"), "dump nodes"); logger(LOG_NOTICE, "Got '%s' command", "dump nodes");
res.res_errno = dump_nodes(res_data); res.res_errno = dump_nodes(res_data);
goto respond; goto respond;
} }
if(req.type == REQ_DUMP_EDGES) { if(req.type == REQ_DUMP_EDGES) {
logger(LOG_NOTICE, _("Got '%s' command"), "dump edges"); logger(LOG_NOTICE, "Got '%s' command", "dump edges");
res.res_errno = dump_edges(res_data); res.res_errno = dump_edges(res_data);
goto respond; goto respond;
} }
if(req.type == REQ_DUMP_SUBNETS) { if(req.type == REQ_DUMP_SUBNETS) {
logger(LOG_NOTICE, _("Got '%s' command"), "dump subnets"); logger(LOG_NOTICE, "Got '%s' command", "dump subnets");
res.res_errno = dump_subnets(res_data); res.res_errno = dump_subnets(res_data);
goto respond; goto respond;
} }
if(req.type == REQ_DUMP_CONNECTIONS) { if(req.type == REQ_DUMP_CONNECTIONS) {
logger(LOG_NOTICE, _("Got '%s' command"), "dump connections"); logger(LOG_NOTICE, "Got '%s' command", "dump connections");
res.res_errno = dump_connections(res_data); res.res_errno = dump_connections(res_data);
goto respond; goto respond;
} }
if(req.type == REQ_DUMP_GRAPH) { if(req.type == REQ_DUMP_GRAPH) {
logger(LOG_NOTICE, _("Got '%s' command"), "dump graph"); logger(LOG_NOTICE, "Got '%s' command", "dump graph");
res.res_errno = dump_graph(res_data); res.res_errno = dump_graph(res_data);
goto respond; goto respond;
} }
if(req.type == REQ_PURGE) { if(req.type == REQ_PURGE) {
logger(LOG_NOTICE, _("Got '%s' command"), "purge"); logger(LOG_NOTICE, "Got '%s' command", "purge");
purge(); purge();
goto respond; goto respond;
} }
@ -108,15 +108,15 @@ static void handle_control_data(struct bufferevent *event, void *data) {
if(req.type == REQ_SET_DEBUG) { if(req.type == REQ_SET_DEBUG) {
debug_t new_debug_level; debug_t new_debug_level;
logger(LOG_NOTICE, _("Got '%s' command"), "debug"); logger(LOG_NOTICE, "Got '%s' command", "debug");
if(req.length != sizeof req + sizeof debug_level) if(req.length != sizeof req + sizeof debug_level)
res.res_errno = EINVAL; res.res_errno = EINVAL;
else { else {
memcpy(&new_debug_level, req_data, sizeof new_debug_level); memcpy(&new_debug_level, req_data, sizeof new_debug_level);
logger(LOG_NOTICE, _("Changing debug level from %d to %d"), logger(LOG_NOTICE, "Changing debug level from %d to %d",
debug_level, new_debug_level); debug_level, new_debug_level);
if(evbuffer_add_printf(res_data, if(evbuffer_add_printf(res_data,
_("Changing debug level from %d to %d\n"), "Changing debug level from %d to %d\n",
debug_level, new_debug_level) == -1) debug_level, new_debug_level) == -1)
res.res_errno = errno; res.res_errno = errno;
debug_level = new_debug_level; debug_level = new_debug_level;
@ -125,18 +125,18 @@ static void handle_control_data(struct bufferevent *event, void *data) {
} }
if(req.type == REQ_RETRY) { if(req.type == REQ_RETRY) {
logger(LOG_NOTICE, _("Got '%s' command"), "retry"); logger(LOG_NOTICE, "Got '%s' command", "retry");
retry(); retry();
goto respond; goto respond;
} }
if(req.type == REQ_RELOAD) { if(req.type == REQ_RELOAD) {
logger(LOG_NOTICE, _("Got '%s' command"), "reload"); logger(LOG_NOTICE, "Got '%s' command", "reload");
res.res_errno = reload_configuration(); res.res_errno = reload_configuration();
goto respond; goto respond;
} }
logger(LOG_DEBUG, _("Malformed control command received")); logger(LOG_DEBUG, "Malformed control command received");
res.res_errno = EINVAL; res.res_errno = EINVAL;
respond: respond:
@ -153,7 +153,7 @@ respond:
return; return;
failure: failure:
logger(LOG_INFO, _("Closing control socket on error")); logger(LOG_INFO, "Closing control socket on error");
evbuffer_free(res_data); evbuffer_free(res_data);
close(event->ev_read.ev_fd); close(event->ev_read.ev_fd);
splay_delete(control_socket_tree, event); splay_delete(control_socket_tree, event);
@ -161,9 +161,9 @@ failure:
static void handle_control_error(struct bufferevent *event, short what, void *data) { static void handle_control_error(struct bufferevent *event, short what, void *data) {
if(what & EVBUFFER_EOF) if(what & EVBUFFER_EOF)
logger(LOG_DEBUG, _("Control socket connection closed by peer")); logger(LOG_DEBUG, "Control socket connection closed by peer");
else else
logger(LOG_DEBUG, _("Error while reading from control socket: %s"), strerror(errno)); logger(LOG_DEBUG, "Error while reading from control socket: %s", strerror(errno));
close(event->ev_read.ev_fd); close(event->ev_read.ev_fd);
splay_delete(control_socket_tree, event); splay_delete(control_socket_tree, event);
@ -177,14 +177,14 @@ static void handle_new_control_socket(int fd, short events, void *data) {
newfd = accept(fd, NULL, NULL); newfd = accept(fd, NULL, NULL);
if(newfd < 0) { if(newfd < 0) {
logger(LOG_ERR, _("Accepting a new connection failed: %s"), strerror(errno)); logger(LOG_ERR, "Accepting a new connection failed: %s", strerror(errno));
event_del(&control_event); event_del(&control_event);
return; return;
} }
ev = bufferevent_new(newfd, handle_control_data, NULL, handle_control_error, NULL); ev = bufferevent_new(newfd, handle_control_data, NULL, handle_control_error, NULL);
if(!ev) { if(!ev) {
logger(LOG_ERR, _("Could not create bufferevent for new control connection: %s"), strerror(errno)); logger(LOG_ERR, "Could not create bufferevent for new control connection: %s", strerror(errno));
close(newfd); close(newfd);
return; return;
} }
@ -194,7 +194,7 @@ static void handle_new_control_socket(int fd, short events, void *data) {
greeting.pid = getpid(); greeting.pid = getpid();
if(bufferevent_write(ev, &greeting, sizeof greeting) == -1) { if(bufferevent_write(ev, &greeting, sizeof greeting) == -1) {
logger(LOG_ERR, logger(LOG_ERR,
_("Cannot send greeting for new control connection: %s"), "Cannot send greeting for new control connection: %s",
strerror(errno)); strerror(errno));
bufferevent_free(ev); bufferevent_free(ev);
close(newfd); close(newfd);
@ -204,7 +204,7 @@ static void handle_new_control_socket(int fd, short events, void *data) {
bufferevent_enable(ev, EV_READ); bufferevent_enable(ev, EV_READ);
splay_insert(control_socket_tree, ev); splay_insert(control_socket_tree, ev);
logger(LOG_DEBUG, _("Control socket connection accepted")); logger(LOG_DEBUG, "Control socket connection accepted");
} }
static int control_compare(const struct event *a, const struct event *b) { static int control_compare(const struct event *a, const struct event *b) {
@ -217,7 +217,7 @@ bool init_control() {
char *lastslash; char *lastslash;
if(strlen(controlsocketname) >= sizeof addr.sun_path) { if(strlen(controlsocketname) >= sizeof addr.sun_path) {
logger(LOG_ERR, _("Control socket filename too long!")); logger(LOG_ERR, "Control socket filename too long!");
goto bail; goto bail;
} }
@ -228,7 +228,7 @@ bool init_control() {
control_socket = socket(PF_UNIX, SOCK_STREAM, 0); control_socket = socket(PF_UNIX, SOCK_STREAM, 0);
if(control_socket < 0) { if(control_socket < 0) {
logger(LOG_ERR, _("Creating UNIX socket failed: %s"), strerror(errno)); logger(LOG_ERR, "Creating UNIX socket failed: %s", strerror(errno));
goto bail; goto bail;
} }
@ -244,7 +244,7 @@ bool init_control() {
if(lastslash != NULL) { if(lastslash != NULL) {
*lastslash = 0; /* temporarily change controlsocketname to be dir */ *lastslash = 0; /* temporarily change controlsocketname to be dir */
if(mkdir(controlsocketname, 0700) < 0 && errno != EEXIST) { if(mkdir(controlsocketname, 0700) < 0 && errno != EEXIST) {
logger(LOG_ERR, _("Unable to create control socket directory %s: %s"), controlsocketname, strerror(errno)); logger(LOG_ERR, "Unable to create control socket directory %s: %s", controlsocketname, strerror(errno));
*lastslash = '/'; *lastslash = '/';
goto bail; goto bail;
} }
@ -255,12 +255,12 @@ bool init_control() {
result = stat(".", &statbuf); result = stat(".", &statbuf);
if(result < 0) { if(result < 0) {
logger(LOG_ERR, _("Examining control socket directory failed: %s"), strerror(errno)); logger(LOG_ERR, "Examining control socket directory failed: %s", strerror(errno));
goto bail; goto bail;
} }
if(statbuf.st_uid != 0 || (statbuf.st_mode & S_IXOTH) != 0 || (statbuf.st_gid != 0 && (statbuf.st_mode & S_IXGRP)) != 0) { if(statbuf.st_uid != 0 || (statbuf.st_mode & S_IXOTH) != 0 || (statbuf.st_gid != 0 && (statbuf.st_mode & S_IXGRP)) != 0) {
logger(LOG_ERR, _("Control socket directory ownership/permissions insecure.")); logger(LOG_ERR, "Control socket directory ownership/permissions insecure.");
goto bail; goto bail;
} }
@ -269,25 +269,25 @@ bool init_control() {
if(result < 0 && errno == EADDRINUSE) { if(result < 0 && errno == EADDRINUSE) {
result = connect(control_socket, (struct sockaddr *)&addr, sizeof addr); result = connect(control_socket, (struct sockaddr *)&addr, sizeof addr);
if(result < 0) { if(result < 0) {
logger(LOG_WARNING, _("Removing old control socket.")); logger(LOG_WARNING, "Removing old control socket.");
unlink(controlsocketname); unlink(controlsocketname);
result = bind(control_socket, (struct sockaddr *)&addr, sizeof addr); result = bind(control_socket, (struct sockaddr *)&addr, sizeof addr);
} else { } else {
if(netname) if(netname)
logger(LOG_ERR, _("Another tincd is already running for net `%s'."), netname); logger(LOG_ERR, "Another tincd is already running for net `%s'.", netname);
else else
logger(LOG_ERR, _("Another tincd is already running.")); logger(LOG_ERR, "Another tincd is already running.");
goto bail; goto bail;
} }
} }
if(result < 0) { if(result < 0) {
logger(LOG_ERR, _("Can't bind to %s: %s"), controlsocketname, strerror(errno)); logger(LOG_ERR, "Can't bind to %s: %s", controlsocketname, strerror(errno));
goto bail; goto bail;
} }
if(listen(control_socket, 3) < 0) { if(listen(control_socket, 3) < 0) {
logger(LOG_ERR, _("Can't listen on %s: %s"), controlsocketname, strerror(errno)); logger(LOG_ERR, "Can't listen on %s: %s", controlsocketname, strerror(errno));
goto bail; goto bail;
} }

View file

@ -99,12 +99,12 @@ static bool cipher_open(cipher_t *cipher, int algo, int mode) {
gcry_error_t err; gcry_error_t err;
if(!ciphertonid(algo, mode, &cipher->nid)) { if(!ciphertonid(algo, mode, &cipher->nid)) {
logger(LOG_DEBUG, _("Cipher %d mode %d has no corresponding nid!"), algo, mode); logger(LOG_DEBUG, "Cipher %d mode %d has no corresponding nid!", algo, mode);
return false; return false;
} }
if((err = gcry_cipher_open(&cipher->handle, algo, mode, 0))) { if((err = gcry_cipher_open(&cipher->handle, algo, mode, 0))) {
logger(LOG_DEBUG, _("Unable to intialise cipher %d mode %d: %s"), algo, mode, gcry_strerror(err)); logger(LOG_DEBUG, "Unable to intialise cipher %d mode %d: %s", algo, mode, gcry_strerror(err));
return false; return false;
} }
@ -122,7 +122,7 @@ bool cipher_open_by_name(cipher_t *cipher, const char *name) {
int algo, mode; int algo, mode;
if(!nametocipher(name, &algo, &mode)) { if(!nametocipher(name, &algo, &mode)) {
logger(LOG_DEBUG, _("Unknown cipher name '%s'!"), name); logger(LOG_DEBUG, "Unknown cipher name '%s'!", name);
return false; return false;
} }
@ -133,7 +133,7 @@ bool cipher_open_by_nid(cipher_t *cipher, int nid) {
int algo, mode; int algo, mode;
if(!nidtocipher(nid, &algo, &mode)) { if(!nidtocipher(nid, &algo, &mode)) {
logger(LOG_DEBUG, _("Unknown cipher ID %d!"), nid); logger(LOG_DEBUG, "Unknown cipher ID %d!", nid);
return false; return false;
} }
@ -233,7 +233,7 @@ bool cipher_encrypt(cipher_t *cipher, const void *indata, size_t inlen, void *ou
// To be fixed // To be fixed
if((err = gcry_cipher_encrypt(cipher->handle, outdata, inlen, indata, inlen))) { if((err = gcry_cipher_encrypt(cipher->handle, outdata, inlen, indata, inlen))) {
logger(LOG_ERR, _("Error while encrypting: %s"), gcry_strerror(err)); logger(LOG_ERR, "Error while encrypting: %s", gcry_strerror(err));
return false; return false;
} }
@ -246,7 +246,7 @@ bool cipher_decrypt(cipher_t *cipher, const void *indata, size_t inlen, void *ou
// To be fixed // To be fixed
if((err = gcry_cipher_decrypt(cipher->handle, outdata, inlen, indata, inlen))) { if((err = gcry_cipher_decrypt(cipher->handle, outdata, inlen, indata, inlen))) {
logger(LOG_ERR, _("Error while decrypting: %s"), gcry_strerror(err)); logger(LOG_ERR, "Error while decrypting: %s", gcry_strerror(err));
return false; return false;
} }

View file

@ -77,7 +77,7 @@ static bool digesttonid(int algo, int *nid) {
static bool digest_open(digest_t *digest, int algo) { static bool digest_open(digest_t *digest, int algo) {
if(!digesttonid(algo, &digest->nid)) { if(!digesttonid(algo, &digest->nid)) {
logger(LOG_DEBUG, _("Digest %d has no corresponding nid!"), algo); logger(LOG_DEBUG, "Digest %d has no corresponding nid!", algo);
return false; return false;
} }
@ -90,7 +90,7 @@ bool digest_open_by_name(digest_t *digest, const char *name) {
int algo; int algo;
if(!nametodigest(name, &algo)) { if(!nametodigest(name, &algo)) {
logger(LOG_DEBUG, _("Unknown digest name '%s'!"), name); logger(LOG_DEBUG, "Unknown digest name '%s'!", name);
return false; return false;
} }
@ -101,7 +101,7 @@ bool digest_open_by_nid(digest_t *digest, int nid) {
int algo; int algo;
if(!nidtodigest(nid, &algo)) { if(!nidtodigest(nid, &algo)) {
logger(LOG_DEBUG, _("Unknown digest ID %d!"), nid); logger(LOG_DEBUG, "Unknown digest ID %d!", nid);
return false; return false;
} }

View file

@ -189,7 +189,7 @@ bool rsa_set_hex_public_key(rsa_t *rsa, char *n, char *e) {
?: gcry_mpi_scan(&rsa->e, GCRYMPI_FMT_HEX, n, 0, NULL); ?: gcry_mpi_scan(&rsa->e, GCRYMPI_FMT_HEX, n, 0, NULL);
if(err) { if(err) {
logger(LOG_ERR, _("Error while reading RSA public key: %s"), gcry_strerror(errno)); logger(LOG_ERR, "Error while reading RSA public key: %s", gcry_strerror(errno));
return false; return false;
} }
@ -204,7 +204,7 @@ bool rsa_set_hex_private_key(rsa_t *rsa, char *n, char *e, char *d) {
?: gcry_mpi_scan(&rsa->d, GCRYMPI_FMT_HEX, n, 0, NULL); ?: gcry_mpi_scan(&rsa->d, GCRYMPI_FMT_HEX, n, 0, NULL);
if(err) { if(err) {
logger(LOG_ERR, _("Error while reading RSA public key: %s"), gcry_strerror(errno)); logger(LOG_ERR, "Error while reading RSA public key: %s", gcry_strerror(errno));
return false; return false;
} }
@ -218,7 +218,7 @@ bool rsa_read_pem_public_key(rsa_t *rsa, FILE *fp) {
size_t derlen; size_t derlen;
if(!pem_decode(fp, "RSA PUBLIC KEY", derbuf, sizeof derbuf, &derlen)) { if(!pem_decode(fp, "RSA PUBLIC KEY", derbuf, sizeof derbuf, &derlen)) {
logger(LOG_ERR, _("Unable to read RSA public key: %s"), strerror(errno)); logger(LOG_ERR, "Unable to read RSA public key: %s", strerror(errno));
return NULL; return NULL;
} }
@ -226,7 +226,7 @@ bool rsa_read_pem_public_key(rsa_t *rsa, FILE *fp) {
|| !ber_read_mpi(&derp, &derlen, &rsa->n) || !ber_read_mpi(&derp, &derlen, &rsa->n)
|| !ber_read_mpi(&derp, &derlen, &rsa->e) || !ber_read_mpi(&derp, &derlen, &rsa->e)
|| derlen) { || derlen) {
logger(LOG_ERR, _("Error while decoding RSA public key")); logger(LOG_ERR, "Error while decoding RSA public key");
return NULL; return NULL;
} }
@ -238,7 +238,7 @@ bool rsa_read_pem_private_key(rsa_t *rsa, FILE *fp) {
size_t derlen; size_t derlen;
if(!pem_decode(fp, "RSA PRIVATE KEY", derbuf, sizeof derbuf, &derlen)) { if(!pem_decode(fp, "RSA PRIVATE KEY", derbuf, sizeof derbuf, &derlen)) {
logger(LOG_ERR, _("Unable to read RSA private key: %s"), strerror(errno)); logger(LOG_ERR, "Unable to read RSA private key: %s", strerror(errno));
return NULL; return NULL;
} }
@ -253,7 +253,7 @@ bool rsa_read_pem_private_key(rsa_t *rsa, FILE *fp) {
|| !ber_read_mpi(&derp, &derlen, NULL) || !ber_read_mpi(&derp, &derlen, NULL)
|| !ber_read_mpi(&derp, &derlen, NULL) // u || !ber_read_mpi(&derp, &derlen, NULL) // u
|| derlen) { || derlen) {
logger(LOG_ERR, _("Error while decoding RSA private key")); logger(LOG_ERR, "Error while decoding RSA private key");
return NULL; return NULL;
} }

View file

@ -166,12 +166,12 @@ bool rsa_write_pem_public_key(rsa_t *rsa, FILE *fp) {
if(!ber_write_mpi(&derp1, &derlen1, &rsa->n) if(!ber_write_mpi(&derp1, &derlen1, &rsa->n)
|| !ber_write_mpi(&derp1, &derlen1, &rsa->e) || !ber_write_mpi(&derp1, &derlen1, &rsa->e)
|| !ber_write_sequence(&derp2, &derlen2, derbuf1, derlen1)) { || !ber_write_sequence(&derp2, &derlen2, derbuf1, derlen1)) {
logger(LOG_ERR, _("Error while encoding RSA public key")); logger(LOG_ERR, "Error while encoding RSA public key");
return false; return false;
} }
if(!pem_encode(fp, "RSA PUBLIC KEY", derbuf2, derlen2)) { if(!pem_encode(fp, "RSA PUBLIC KEY", derbuf2, derlen2)) {
logger(LOG_ERR, _("Unable to write RSA public key: %s"), strerror(errno)); logger(LOG_ERR, "Unable to write RSA public key: %s", strerror(errno));
return false; return false;
} }
@ -195,12 +195,12 @@ bool rsa_write_pem_private_key(rsa_t *rsa, FILE *fp) {
|| ber_write_mpi(&derp1, &derlen1, &exp1) || ber_write_mpi(&derp1, &derlen1, &exp1)
|| ber_write_mpi(&derp1, &derlen1, &exp2) || ber_write_mpi(&derp1, &derlen1, &exp2)
|| ber_write_mpi(&derp1, &derlen1, &coeff)) || ber_write_mpi(&derp1, &derlen1, &coeff))
logger(LOG_ERR, _("Error while encoding RSA private key")); logger(LOG_ERR, "Error while encoding RSA private key");
return false; return false;
} }
if(!pem_encode(fp, "RSA PRIVATE KEY", derbuf2, derlen2)) { if(!pem_encode(fp, "RSA PRIVATE KEY", derbuf2, derlen2)) {
logger(LOG_ERR, _("Unable to write RSA private key: %s"), strerror(errno)); logger(LOG_ERR, "Unable to write RSA private key: %s", strerror(errno));
return false; return false;
} }
@ -217,6 +217,6 @@ bool rsa_write_pem_private_key(rsa_t *rsa, FILE *fp) {
} }
bool rsa_generate(rsa_t *rsa, size_t bits, unsigned long exponent) { bool rsa_generate(rsa_t *rsa, size_t bits, unsigned long exponent) {
fprintf(stderr, _("Generating RSA keys with libgcrypt not implemented yet\n")); fprintf(stderr, "Generating RSA keys with libgcrypt not implemented yet\n");
return false; return false;
} }

View file

@ -45,7 +45,7 @@ bool cipher_open_by_name(cipher_t *cipher, const char *name) {
if(cipher->cipher) if(cipher->cipher)
return cipher_open(cipher); return cipher_open(cipher);
logger(LOG_DEBUG, _("Unknown cipher name '%s'!"), name); logger(LOG_DEBUG, "Unknown cipher name '%s'!", name);
return false; return false;
} }
@ -55,7 +55,7 @@ bool cipher_open_by_nid(cipher_t *cipher, int nid) {
if(cipher->cipher) if(cipher->cipher)
return cipher_open(cipher); return cipher_open(cipher);
logger(LOG_DEBUG, _("Unknown cipher nid %d!"), nid); logger(LOG_DEBUG, "Unknown cipher nid %d!", nid);
return false; return false;
} }
@ -93,7 +93,7 @@ bool cipher_set_key(cipher_t *cipher, void *key, bool encrypt) {
if(result) if(result)
return true; return true;
logger(LOG_ERR, _("Error while setting key: %s"), ERR_error_string(ERR_get_error(), NULL)); logger(LOG_ERR, "Error while setting key: %s", ERR_error_string(ERR_get_error(), NULL));
return false; return false;
} }
@ -110,7 +110,7 @@ bool cipher_set_key_from_rsa(cipher_t *cipher, void *key, size_t len, bool encry
if(result) if(result)
return true; return true;
logger(LOG_ERR, _("Error while setting key: %s"), ERR_error_string(ERR_get_error(), NULL)); logger(LOG_ERR, "Error while setting key: %s", ERR_error_string(ERR_get_error(), NULL));
return false; return false;
} }
@ -127,7 +127,7 @@ bool cipher_regenerate_key(cipher_t *cipher, bool encrypt) {
if(result) if(result)
return true; return true;
logger(LOG_ERR, _("Error while regenerating key: %s"), ERR_error_string(ERR_get_error(), NULL)); logger(LOG_ERR, "Error while regenerating key: %s", ERR_error_string(ERR_get_error(), NULL));
return false; return false;
} }
@ -148,7 +148,7 @@ bool cipher_encrypt(cipher_t *cipher, const void *indata, size_t inlen, void *ou
} }
} }
logger(LOG_ERR, _("Error while encrypting: %s"), ERR_error_string(ERR_get_error(), NULL)); logger(LOG_ERR, "Error while encrypting: %s", ERR_error_string(ERR_get_error(), NULL));
return false; return false;
} }
@ -169,7 +169,7 @@ bool cipher_decrypt(cipher_t *cipher, const void *indata, size_t inlen, void *ou
} }
} }
logger(LOG_ERR, _("Error while encrypting: %s"), ERR_error_string(ERR_get_error(), NULL)); logger(LOG_ERR, "Error while encrypting: %s", ERR_error_string(ERR_get_error(), NULL));
return false; return false;
} }

View file

@ -39,7 +39,7 @@ bool digest_open_by_name(digest_t *digest, const char *name, int maclength) {
digest->digest = EVP_get_digestbyname(name); digest->digest = EVP_get_digestbyname(name);
if(!digest->digest) { if(!digest->digest) {
logger(LOG_DEBUG, _("Unknown digest name '%s'!"), name); logger(LOG_DEBUG, "Unknown digest name '%s'!", name);
return false; return false;
} }
@ -51,7 +51,7 @@ bool digest_open_by_nid(digest_t *digest, int nid, int maclength) {
digest->digest = EVP_get_digestbynid(nid); digest->digest = EVP_get_digestbynid(nid);
if(!digest->digest) { if(!digest->digest) {
logger(LOG_DEBUG, _("Unknown digest nid %d!"), nid); logger(LOG_DEBUG, "Unknown digest nid %d!", nid);
return false; return false;
} }
@ -78,7 +78,7 @@ bool digest_create(digest_t *digest, const void *indata, size_t inlen, void *out
if(!EVP_DigestInit(&ctx, digest->digest) if(!EVP_DigestInit(&ctx, digest->digest)
|| !EVP_DigestUpdate(&ctx, indata, inlen) || !EVP_DigestUpdate(&ctx, indata, inlen)
|| !EVP_DigestFinal(&ctx, tmpdata, NULL)) { || !EVP_DigestFinal(&ctx, tmpdata, NULL)) {
logger(LOG_DEBUG, _("Error creating digest: %s"), ERR_error_string(ERR_get_error(), NULL)); logger(LOG_DEBUG, "Error creating digest: %s", ERR_error_string(ERR_get_error(), NULL));
return false; return false;
} }

View file

@ -57,7 +57,7 @@ bool rsa_read_pem_public_key(rsa_t *rsa, FILE *fp) {
if(*rsa) if(*rsa)
return true; return true;
logger(LOG_ERR, _("Unable to read RSA public key: %s"), ERR_error_string(ERR_get_error(), NULL)); logger(LOG_ERR, "Unable to read RSA public key: %s", ERR_error_string(ERR_get_error(), NULL));
return false; return false;
} }
@ -67,7 +67,7 @@ bool rsa_read_pem_private_key(rsa_t *rsa, FILE *fp) {
if(*rsa) if(*rsa)
return true; return true;
logger(LOG_ERR, _("Unable to read RSA private key: %s"), ERR_error_string(ERR_get_error(), NULL)); logger(LOG_ERR, "Unable to read RSA private key: %s", ERR_error_string(ERR_get_error(), NULL));
return false; return false;
} }
@ -79,7 +79,7 @@ bool rsa_public_encrypt(rsa_t *rsa, void *in, size_t len, void *out) {
if(RSA_public_encrypt(len, in, out, *rsa, RSA_NO_PADDING) == len) if(RSA_public_encrypt(len, in, out, *rsa, RSA_NO_PADDING) == len)
return true; return true;
logger(LOG_ERR, _("Unable to perform RSA encryption: %s"), ERR_error_string(ERR_get_error(), NULL)); logger(LOG_ERR, "Unable to perform RSA encryption: %s", ERR_error_string(ERR_get_error(), NULL));
return false; return false;
} }
@ -87,6 +87,6 @@ bool rsa_private_decrypt(rsa_t *rsa, void *in, size_t len, void *out) {
if(RSA_private_decrypt(len, in, out, *rsa, RSA_NO_PADDING) == len) if(RSA_private_decrypt(len, in, out, *rsa, RSA_NO_PADDING) == len)
return true; return true;
logger(LOG_ERR, _("Unable to perform RSA decryption: %s"), ERR_error_string(ERR_get_error(), NULL)); logger(LOG_ERR, "Unable to perform RSA decryption: %s", ERR_error_string(ERR_get_error(), NULL));
return false; return false;
} }

View file

@ -297,7 +297,7 @@ bool chal_reply_h(connection_t *c, char *request) {
/* Check if the length of the hash is all right */ /* Check if the length of the hash is all right */
if(strlen(hishash) != digest_length(&c->outdigest) * 2) { if(strlen(hishash) != digest_length(&c->outdigest) * 2) {
logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, _("wrong challenge reply length")); logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "wrong challenge reply length");
return false; return false;
} }
@ -308,7 +308,7 @@ bool chal_reply_h(connection_t *c, char *request) {
/* Verify the hash */ /* Verify the hash */
if(!digest_verify(&c->outdigest, c->hischallenge, rsa_size(&c->rsa), hishash)) { if(!digest_verify(&c->outdigest, c->hischallenge, rsa_size(&c->rsa), hishash)) {
logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, _("wrong challenge reply")); logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "wrong challenge reply");
return false; return false;
} }

View file

@ -136,8 +136,7 @@ static void age_subnets(int fd, short events, void *data) {
event_add(&age_subnets_event, &(struct timeval){10, 0}); event_add(&age_subnets_event, &(struct timeval){10, 0});
} }
static void learn_mac(mac_t *address) static void learn_mac(mac_t *address) {
{
subnet_t *subnet; subnet_t *subnet;
splay_node_t *node; splay_node_t *node;
connection_t *c; connection_t *c;

View file

@ -1,6 +1,6 @@
/* /*
tincctl.c -- Controlling a running tincd tincctl.c -- Controlling a running tincd
Copyright (C) 2007 Guus Sliepen <guus@tinc-vpn.org> Copyright (C) 2007-2009 Guus Sliepen <guus@tinc-vpn.org>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -60,11 +60,11 @@ static struct option const long_options[] = {
static void usage(bool status) { static void usage(bool status) {
if(status) if(status)
fprintf(stderr, _("Try `%s --help\' for more information.\n"), fprintf(stderr, "Try `%s --help\' for more information.\n",
program_name); program_name);
else { else {
printf(_("Usage: %s [options] command\n\n"), program_name); printf("Usage: %s [options] command\n\n", program_name);
printf(_("Valid options are:\n" printf("Valid options are:\n"
" -c, --config=DIR Read configuration options from DIR.\n" " -c, --config=DIR Read configuration options from DIR.\n"
" -n, --net=NETNAME Connect to net NETNAME.\n" " -n, --net=NETNAME Connect to net NETNAME.\n"
" --controlsocket=FILENAME Open control socket at FILENAME.\n" " --controlsocket=FILENAME Open control socket at FILENAME.\n"
@ -88,8 +88,8 @@ static void usage(bool status) {
" debug N Set debug level\n" " debug N Set debug level\n"
" retry Retry all outgoing connections\n" " retry Retry all outgoing connections\n"
" reload Partial reload of configuration\n" " reload Partial reload of configuration\n"
"\n")); "\n");
printf(_("Report bugs to tinc@tinc-vpn.org.\n")); printf("Report bugs to tinc@tinc-vpn.org.\n");
} }
} }
@ -144,12 +144,12 @@ FILE *ask_and_open(const char *filename, const char *what, const char *mode) {
/* Check stdin and stdout */ /* Check stdin and stdout */
if(isatty(0) && isatty(1)) { if(isatty(0) && isatty(1)) {
/* Ask for a file and/or directory name. */ /* Ask for a file and/or directory name. */
fprintf(stdout, _("Please enter a file to save %s to [%s]: "), fprintf(stdout, "Please enter a file to save %s to [%s]: ",
what, filename); what, filename);
fflush(stdout); fflush(stdout);
if(fgets(buf, sizeof buf, stdin) < 0) { if(fgets(buf, sizeof buf, stdin) < 0) {
fprintf(stderr, _("Error while reading stdin: %s\n"), fprintf(stderr, "Error while reading stdin: %s\n",
strerror(errno)); strerror(errno));
return NULL; return NULL;
} }
@ -180,7 +180,7 @@ FILE *ask_and_open(const char *filename, const char *what, const char *mode) {
r = fopen(filename, mode); r = fopen(filename, mode);
if(!r) { if(!r) {
fprintf(stderr, _("Error opening file `%s': %s\n"), filename, strerror(errno)); fprintf(stderr, "Error opening file `%s': %s\n", filename, strerror(errno));
return NULL; return NULL;
} }
@ -197,16 +197,16 @@ static bool keygen(int bits) {
char *name = NULL; char *name = NULL;
char *filename; char *filename;
fprintf(stderr, _("Generating %d bits keys:\n"), bits); fprintf(stderr, "Generating %d bits keys:\n", bits);
if(!rsa_generate(&key, bits, 0x10001)) { if(!rsa_generate(&key, bits, 0x10001)) {
fprintf(stderr, _("Error during key generation!\n")); fprintf(stderr, "Error during key generation!\n");
return false; return false;
} else } else
fprintf(stderr, _("Done.\n")); fprintf(stderr, "Done.\n");
xasprintf(&filename, "%s/rsa_key.priv", confbase); xasprintf(&filename, "%s/rsa_key.priv", confbase);
f = ask_and_open(filename, _("private RSA key"), "a"); f = ask_and_open(filename, "private RSA key", "a");
if(!f) if(!f)
return false; return false;
@ -217,7 +217,7 @@ static bool keygen(int bits) {
#endif #endif
if(ftell(f)) if(ftell(f))
fprintf(stderr, _("Appending key to existing contents.\nMake sure only one key is stored in the file.\n")); fprintf(stderr, "Appending key to existing contents.\nMake sure only one key is stored in the file.\n");
rsa_write_pem_private_key(&key, f); rsa_write_pem_private_key(&key, f);
@ -229,13 +229,13 @@ static bool keygen(int bits) {
else else
xasprintf(&filename, "%s/rsa_key.pub", confbase); xasprintf(&filename, "%s/rsa_key.pub", confbase);
f = ask_and_open(filename, _("public RSA key"), "a"); f = ask_and_open(filename, "public RSA key", "a");
if(!f) if(!f)
return false; return false;
if(ftell(f)) if(ftell(f))
fprintf(stderr, _("Appending key to existing contents.\nMake sure only one key is stored in the file.\n")); fprintf(stderr, "Appending key to existing contents.\nMake sure only one key is stored in the file.\n");
rsa_write_pem_public_key(&key, f); rsa_write_pem_public_key(&key, f);
@ -285,7 +285,7 @@ static void make_names(void) {
if(!confbase) if(!confbase)
xasprintf(&confbase, CONFDIR "/tinc/%s", netname); xasprintf(&confbase, CONFDIR "/tinc/%s", netname);
else else
fprintf(stderr, _("Both netname and configuration directory given, using the latter...\n")); fprintf(stderr, "Both netname and configuration directory given, using the latter...\n");
} else { } else {
if(!confbase) if(!confbase)
xasprintf(&confbase, CONFDIR "/tinc"); xasprintf(&confbase, CONFDIR "/tinc");
@ -371,16 +371,14 @@ static int send_ctl_request(int fd, enum request_type type,
/* /*
Send a request (with printfs) Send a request (with printfs)
*/ */
static int send_ctl_request_cooked(int fd, enum request_type type, static int send_ctl_request_cooked(int fd, enum request_type type, void const *outdata, size_t outdatalen) {
void const *outdata, size_t outdatalen)
{
int res_errno = -1; int res_errno = -1;
char *buf = NULL; char *buf = NULL;
size_t buflen = 0; size_t buflen = 0;
if(send_ctl_request(fd, type, outdata, outdatalen, &res_errno, if(send_ctl_request(fd, type, outdata, outdatalen, &res_errno,
(void**) &buf, &buflen)) { (void**) &buf, &buflen)) {
fprintf(stderr, _("Error sending request: %s\n"), strerror(errno)); fprintf(stderr, "Error sending request: %s\n", strerror(errno));
return -1; return -1;
} }
@ -390,7 +388,7 @@ static int send_ctl_request_cooked(int fd, enum request_type type,
} }
if(res_errno != 0) { if(res_errno != 0) {
fprintf(stderr, _("Server reported error: %s\n"), strerror(res_errno)); fprintf(stderr, "Server reported error: %s\n", strerror(res_errno));
return -1; return -1;
} }
@ -405,23 +403,19 @@ int main(int argc, char *argv[], char *envp[]) {
program_name = argv[0]; program_name = argv[0];
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
if(!parse_options(argc, argv)) if(!parse_options(argc, argv))
return 1; return 1;
make_names(); make_names();
if(show_version) { if(show_version) {
printf(_("%s version %s (built %s %s, protocol %d)\n"), PACKAGE, printf("%s version %s (built %s %s, protocol %d)\n", PACKAGE,
VERSION, __DATE__, __TIME__, PROT_CURRENT); VERSION, __DATE__, __TIME__, PROT_CURRENT);
printf(_("Copyright (C) 1998-2007 Ivo Timmermans, Guus Sliepen and others.\n" printf("Copyright (C) 1998-2009 Ivo Timmermans, Guus Sliepen and others.\n"
"See the AUTHORS file for a complete list.\n\n" "See the AUTHORS file for a complete list.\n\n"
"tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
"and you are welcome to redistribute it under certain conditions;\n" "and you are welcome to redistribute it under certain conditions;\n"
"see the file COPYING for details.\n")); "see the file COPYING for details.\n");
return 0; return 0;
} }
@ -432,7 +426,7 @@ int main(int argc, char *argv[], char *envp[]) {
} }
if(optind >= argc) { if(optind >= argc) {
fprintf(stderr, _("Not enough arguments.\n")); fprintf(stderr, "Not enough arguments.\n");
usage(true); usage(true);
return 1; return 1;
} }
@ -446,7 +440,7 @@ int main(int argc, char *argv[], char *envp[]) {
if(!strcasecmp(argv[optind], "start")) { if(!strcasecmp(argv[optind], "start")) {
argv[optind] = NULL; argv[optind] = NULL;
execve(SBINDIR "/tincd", argv, envp); execve(SBINDIR "/tincd", argv, envp);
fprintf(stderr, _("Could not start tincd: %s"), strerror(errno)); fprintf(stderr, "Could not start tincd: %s", strerror(errno));
return 1; return 1;
} }
@ -468,23 +462,23 @@ int main(int argc, char *argv[], char *envp[]) {
result = stat(".", &statbuf); result = stat(".", &statbuf);
if(result < 0) { if(result < 0) {
fprintf(stderr, _("Unable to check control socket directory permissions: %s\n"), strerror(errno)); fprintf(stderr, "Unable to check control socket directory permissions: %s\n", strerror(errno));
return 1; return 1;
} }
if(statbuf.st_uid != 0 || (statbuf.st_mode & S_IXOTH) != 0 || (statbuf.st_gid != 0 && (statbuf.st_mode & S_IXGRP)) != 0) { if(statbuf.st_uid != 0 || (statbuf.st_mode & S_IXOTH) != 0 || (statbuf.st_gid != 0 && (statbuf.st_mode & S_IXGRP)) != 0) {
fprintf(stderr, _("Insecure permissions on control socket directory\n")); fprintf(stderr, "Insecure permissions on control socket directory\n");
return 1; return 1;
} }
if(strlen(controlsocketname) >= sizeof addr.sun_path) { if(strlen(controlsocketname) >= sizeof addr.sun_path) {
fprintf(stderr, _("Control socket filename too long!\n")); fprintf(stderr, "Control socket filename too long!\n");
return 1; return 1;
} }
fd = socket(PF_UNIX, SOCK_STREAM, 0); fd = socket(PF_UNIX, SOCK_STREAM, 0);
if(fd < 0) { if(fd < 0) {
fprintf(stderr, _("Cannot create UNIX socket: %s\n"), strerror(errno)); fprintf(stderr, "Cannot create UNIX socket: %s\n", strerror(errno));
return 1; return 1;
} }
@ -493,18 +487,18 @@ int main(int argc, char *argv[], char *envp[]) {
strncpy(addr.sun_path, controlsocketname, sizeof addr.sun_path - 1); strncpy(addr.sun_path, controlsocketname, sizeof addr.sun_path - 1);
if(connect(fd, (struct sockaddr *)&addr, sizeof addr) < 0) { if(connect(fd, (struct sockaddr *)&addr, sizeof addr) < 0) {
fprintf(stderr, _("Cannot connect to %s: %s\n"), controlsocketname, strerror(errno)); fprintf(stderr, "Cannot connect to %s: %s\n", controlsocketname, strerror(errno));
return 1; return 1;
} }
if(fullread(fd, &greeting, sizeof greeting) == -1) { if(fullread(fd, &greeting, sizeof greeting) == -1) {
fprintf(stderr, _("Cannot read greeting from control socket: %s\n"), fprintf(stderr, "Cannot read greeting from control socket: %s\n",
strerror(errno)); strerror(errno));
return 1; return 1;
} }
if(greeting.version != TINC_CTL_VERSION_CURRENT) { if(greeting.version != TINC_CTL_VERSION_CURRENT) {
fprintf(stderr, _("Version mismatch: server %d, client %d\n"), fprintf(stderr, "Version mismatch: server %d, client %d\n",
greeting.version, TINC_CTL_VERSION_CURRENT); greeting.version, TINC_CTL_VERSION_CURRENT);
return 1; return 1;
} }
@ -528,7 +522,7 @@ int main(int argc, char *argv[], char *envp[]) {
if(!strcasecmp(argv[optind], "dump")) { if(!strcasecmp(argv[optind], "dump")) {
if(argc < optind + 2) { if(argc < optind + 2) {
fprintf(stderr, _("Not enough arguments.\n")); fprintf(stderr, "Not enough arguments.\n");
usage(true); usage(true);
return 1; return 1;
} }
@ -553,7 +547,7 @@ int main(int argc, char *argv[], char *envp[]) {
return send_ctl_request_cooked(fd, REQ_DUMP_GRAPH, NULL, 0) != -1; return send_ctl_request_cooked(fd, REQ_DUMP_GRAPH, NULL, 0) != -1;
} }
fprintf(stderr, _("Unknown dump type '%s'.\n"), argv[optind+1]); fprintf(stderr, "Unknown dump type '%s'.\n", argv[optind+1]);
usage(true); usage(true);
return 1; return 1;
} }
@ -582,7 +576,7 @@ int main(int argc, char *argv[], char *envp[]) {
return send_ctl_request_cooked(fd, REQ_RELOAD, NULL, 0) != -1; return send_ctl_request_cooked(fd, REQ_RELOAD, NULL, 0) != -1;
} }
fprintf(stderr, _("Unknown command `%s'.\n"), argv[optind]); fprintf(stderr, "Unknown command `%s'.\n", argv[optind]);
usage(true); usage(true);
close(fd); close(fd);