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) {
logger(LOG_NOTICE, _("Got '%s' command"), "stop");
logger(LOG_NOTICE, "Got '%s' command", "stop");
event_loopexit(NULL);
goto respond;
}
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);
goto respond;
}
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);
goto respond;
}
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);
goto respond;
}
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);
goto respond;
}
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);
goto respond;
}
if(req.type == REQ_PURGE) {
logger(LOG_NOTICE, _("Got '%s' command"), "purge");
logger(LOG_NOTICE, "Got '%s' command", "purge");
purge();
goto respond;
}
@ -108,15 +108,15 @@ static void handle_control_data(struct bufferevent *event, void *data) {
if(req.type == REQ_SET_DEBUG) {
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)
res.res_errno = EINVAL;
else {
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);
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)
res.res_errno = errno;
debug_level = new_debug_level;
@ -125,18 +125,18 @@ static void handle_control_data(struct bufferevent *event, void *data) {
}
if(req.type == REQ_RETRY) {
logger(LOG_NOTICE, _("Got '%s' command"), "retry");
logger(LOG_NOTICE, "Got '%s' command", "retry");
retry();
goto respond;
}
if(req.type == REQ_RELOAD) {
logger(LOG_NOTICE, _("Got '%s' command"), "reload");
logger(LOG_NOTICE, "Got '%s' command", "reload");
res.res_errno = reload_configuration();
goto respond;
}
logger(LOG_DEBUG, _("Malformed control command received"));
logger(LOG_DEBUG, "Malformed control command received");
res.res_errno = EINVAL;
respond:
@ -153,7 +153,7 @@ respond:
return;
failure:
logger(LOG_INFO, _("Closing control socket on error"));
logger(LOG_INFO, "Closing control socket on error");
evbuffer_free(res_data);
close(event->ev_read.ev_fd);
splay_delete(control_socket_tree, event);
@ -161,9 +161,9 @@ failure:
static void handle_control_error(struct bufferevent *event, short what, void *data) {
if(what & EVBUFFER_EOF)
logger(LOG_DEBUG, _("Control socket connection closed by peer"));
logger(LOG_DEBUG, "Control socket connection closed by peer");
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);
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);
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);
return;
}
ev = bufferevent_new(newfd, handle_control_data, NULL, handle_control_error, NULL);
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);
return;
}
@ -194,7 +194,7 @@ static void handle_new_control_socket(int fd, short events, void *data) {
greeting.pid = getpid();
if(bufferevent_write(ev, &greeting, sizeof greeting) == -1) {
logger(LOG_ERR,
_("Cannot send greeting for new control connection: %s"),
"Cannot send greeting for new control connection: %s",
strerror(errno));
bufferevent_free(ev);
close(newfd);
@ -204,7 +204,7 @@ static void handle_new_control_socket(int fd, short events, void *data) {
bufferevent_enable(ev, EV_READ);
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) {
@ -217,7 +217,7 @@ bool init_control() {
char *lastslash;
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;
}
@ -228,7 +228,7 @@ bool init_control() {
control_socket = socket(PF_UNIX, SOCK_STREAM, 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;
}
@ -244,7 +244,7 @@ bool init_control() {
if(lastslash != NULL) {
*lastslash = 0; /* temporarily change controlsocketname to be dir */
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 = '/';
goto bail;
}
@ -255,12 +255,12 @@ bool init_control() {
result = stat(".", &statbuf);
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;
}
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;
}
@ -269,25 +269,25 @@ bool init_control() {
if(result < 0 && errno == EADDRINUSE) {
result = connect(control_socket, (struct sockaddr *)&addr, sizeof addr);
if(result < 0) {
logger(LOG_WARNING, _("Removing old control socket."));
logger(LOG_WARNING, "Removing old control socket.");
unlink(controlsocketname);
result = bind(control_socket, (struct sockaddr *)&addr, sizeof addr);
} else {
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
logger(LOG_ERR, _("Another tincd is already running."));
logger(LOG_ERR, "Another tincd is already running.");
goto bail;
}
}
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;
}
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;
}

View file

@ -99,12 +99,12 @@ static bool cipher_open(cipher_t *cipher, int algo, int mode) {
gcry_error_t err;
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;
}
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;
}
@ -122,7 +122,7 @@ bool cipher_open_by_name(cipher_t *cipher, const char *name) {
int 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;
}
@ -133,7 +133,7 @@ bool cipher_open_by_nid(cipher_t *cipher, int nid) {
int 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;
}
@ -233,7 +233,7 @@ bool cipher_encrypt(cipher_t *cipher, const void *indata, size_t inlen, void *ou
// To be fixed
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;
}
@ -246,7 +246,7 @@ bool cipher_decrypt(cipher_t *cipher, const void *indata, size_t inlen, void *ou
// To be fixed
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;
}

View file

@ -77,7 +77,7 @@ static bool digesttonid(int algo, int *nid) {
static bool digest_open(digest_t *digest, int algo) {
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;
}
@ -90,7 +90,7 @@ bool digest_open_by_name(digest_t *digest, const char *name) {
int algo;
if(!nametodigest(name, &algo)) {
logger(LOG_DEBUG, _("Unknown digest name '%s'!"), name);
logger(LOG_DEBUG, "Unknown digest name '%s'!", name);
return false;
}
@ -101,7 +101,7 @@ bool digest_open_by_nid(digest_t *digest, int nid) {
int algo;
if(!nidtodigest(nid, &algo)) {
logger(LOG_DEBUG, _("Unknown digest ID %d!"), nid);
logger(LOG_DEBUG, "Unknown digest ID %d!", nid);
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);
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;
}
@ -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);
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;
}
@ -218,7 +218,7 @@ bool rsa_read_pem_public_key(rsa_t *rsa, FILE *fp) {
size_t 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;
}
@ -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->e)
|| derlen) {
logger(LOG_ERR, _("Error while decoding RSA public key"));
logger(LOG_ERR, "Error while decoding RSA public key");
return NULL;
}
@ -238,7 +238,7 @@ bool rsa_read_pem_private_key(rsa_t *rsa, FILE *fp) {
size_t 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;
}
@ -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) // u
|| derlen) {
logger(LOG_ERR, _("Error while decoding RSA private key"));
logger(LOG_ERR, "Error while decoding RSA private key");
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)
|| !ber_write_mpi(&derp1, &derlen1, &rsa->e)
|| !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;
}
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;
}
@ -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, &exp2)
|| 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;
}
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;
}
@ -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) {
fprintf(stderr, _("Generating RSA keys with libgcrypt not implemented yet\n"));
fprintf(stderr, "Generating RSA keys with libgcrypt not implemented yet\n");
return false;
}

View file

@ -45,7 +45,7 @@ bool cipher_open_by_name(cipher_t *cipher, const char *name) {
if(cipher->cipher)
return cipher_open(cipher);
logger(LOG_DEBUG, _("Unknown cipher name '%s'!"), name);
logger(LOG_DEBUG, "Unknown cipher name '%s'!", name);
return false;
}
@ -55,7 +55,7 @@ bool cipher_open_by_nid(cipher_t *cipher, int nid) {
if(cipher->cipher)
return cipher_open(cipher);
logger(LOG_DEBUG, _("Unknown cipher nid %d!"), nid);
logger(LOG_DEBUG, "Unknown cipher nid %d!", nid);
return false;
}
@ -93,7 +93,7 @@ bool cipher_set_key(cipher_t *cipher, void *key, bool encrypt) {
if(result)
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;
}
@ -110,7 +110,7 @@ bool cipher_set_key_from_rsa(cipher_t *cipher, void *key, size_t len, bool encry
if(result)
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;
}
@ -127,7 +127,7 @@ bool cipher_regenerate_key(cipher_t *cipher, bool encrypt) {
if(result)
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;
}
@ -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;
}
@ -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;
}

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);
if(!digest->digest) {
logger(LOG_DEBUG, _("Unknown digest name '%s'!"), name);
logger(LOG_DEBUG, "Unknown digest name '%s'!", name);
return false;
}
@ -51,7 +51,7 @@ bool digest_open_by_nid(digest_t *digest, int nid, int maclength) {
digest->digest = EVP_get_digestbynid(nid);
if(!digest->digest) {
logger(LOG_DEBUG, _("Unknown digest nid %d!"), nid);
logger(LOG_DEBUG, "Unknown digest nid %d!", nid);
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)
|| !EVP_DigestUpdate(&ctx, indata, inlen)
|| !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;
}

View file

@ -57,7 +57,7 @@ bool rsa_read_pem_public_key(rsa_t *rsa, FILE *fp) {
if(*rsa)
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;
}
@ -67,7 +67,7 @@ bool rsa_read_pem_private_key(rsa_t *rsa, FILE *fp) {
if(*rsa)
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;
}
@ -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)
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;
}
@ -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)
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;
}

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 */
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;
}
@ -308,7 +308,7 @@ bool chal_reply_h(connection_t *c, char *request) {
/* Verify the hash */
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;
}

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});
}
static void learn_mac(mac_t *address)
{
static void learn_mac(mac_t *address) {
subnet_t *subnet;
splay_node_t *node;
connection_t *c;

View file

@ -1,6 +1,6 @@
/*
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
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) {
if(status)
fprintf(stderr, _("Try `%s --help\' for more information.\n"),
fprintf(stderr, "Try `%s --help\' for more information.\n",
program_name);
else {
printf(_("Usage: %s [options] command\n\n"), program_name);
printf(_("Valid options are:\n"
printf("Usage: %s [options] command\n\n", program_name);
printf("Valid options are:\n"
" -c, --config=DIR Read configuration options from DIR.\n"
" -n, --net=NETNAME Connect to net NETNAME.\n"
" --controlsocket=FILENAME Open control socket at FILENAME.\n"
@ -88,8 +88,8 @@ static void usage(bool status) {
" debug N Set debug level\n"
" retry Retry all outgoing connections\n"
" reload Partial reload of configuration\n"
"\n"));
printf(_("Report bugs to tinc@tinc-vpn.org.\n"));
"\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 */
if(isatty(0) && isatty(1)) {
/* 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);
fflush(stdout);
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));
return NULL;
}
@ -180,7 +180,7 @@ FILE *ask_and_open(const char *filename, const char *what, const char *mode) {
r = fopen(filename, mode);
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;
}
@ -197,16 +197,16 @@ static bool keygen(int bits) {
char *name = NULL;
char *filename;
fprintf(stderr, _("Generating %d bits keys:\n"), bits);
fprintf(stderr, "Generating %d bits keys:\n", bits);
if(!rsa_generate(&key, bits, 0x10001)) {
fprintf(stderr, _("Error during key generation!\n"));
fprintf(stderr, "Error during key generation!\n");
return false;
} else
fprintf(stderr, _("Done.\n"));
fprintf(stderr, "Done.\n");
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)
return false;
@ -217,7 +217,7 @@ static bool keygen(int bits) {
#endif
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);
@ -229,13 +229,13 @@ static bool keygen(int bits) {
else
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)
return false;
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);
@ -285,7 +285,7 @@ static void make_names(void) {
if(!confbase)
xasprintf(&confbase, CONFDIR "/tinc/%s", netname);
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 {
if(!confbase)
xasprintf(&confbase, CONFDIR "/tinc");
@ -371,16 +371,14 @@ static int send_ctl_request(int fd, enum request_type type,
/*
Send a request (with printfs)
*/
static int send_ctl_request_cooked(int fd, enum request_type type,
void const *outdata, size_t outdatalen)
{
static int send_ctl_request_cooked(int fd, enum request_type type, void const *outdata, size_t outdatalen) {
int res_errno = -1;
char *buf = NULL;
size_t buflen = 0;
if(send_ctl_request(fd, type, outdata, outdatalen, &res_errno,
(void**) &buf, &buflen)) {
fprintf(stderr, _("Error sending request: %s\n"), strerror(errno));
fprintf(stderr, "Error sending request: %s\n", strerror(errno));
return -1;
}
@ -390,7 +388,7 @@ static int send_ctl_request_cooked(int fd, enum request_type type,
}
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;
}
@ -405,23 +403,19 @@ int main(int argc, char *argv[], char *envp[]) {
program_name = argv[0];
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
if(!parse_options(argc, argv))
return 1;
make_names();
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);
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"
"tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\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;
}
@ -432,7 +426,7 @@ int main(int argc, char *argv[], char *envp[]) {
}
if(optind >= argc) {
fprintf(stderr, _("Not enough arguments.\n"));
fprintf(stderr, "Not enough arguments.\n");
usage(true);
return 1;
}
@ -446,7 +440,7 @@ int main(int argc, char *argv[], char *envp[]) {
if(!strcasecmp(argv[optind], "start")) {
argv[optind] = NULL;
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;
}
@ -468,23 +462,23 @@ int main(int argc, char *argv[], char *envp[]) {
result = stat(".", &statbuf);
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;
}
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;
}
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;
}
fd = socket(PF_UNIX, SOCK_STREAM, 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;
}
@ -493,18 +487,18 @@ int main(int argc, char *argv[], char *envp[]) {
strncpy(addr.sun_path, controlsocketname, sizeof addr.sun_path - 1);
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;
}
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));
return 1;
}
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);
return 1;
}
@ -528,7 +522,7 @@ int main(int argc, char *argv[], char *envp[]) {
if(!strcasecmp(argv[optind], "dump")) {
if(argc < optind + 2) {
fprintf(stderr, _("Not enough arguments.\n"));
fprintf(stderr, "Not enough arguments.\n");
usage(true);
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;
}
fprintf(stderr, _("Unknown dump type '%s'.\n"), argv[optind+1]);
fprintf(stderr, "Unknown dump type '%s'.\n", argv[optind+1]);
usage(true);
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;
}
fprintf(stderr, _("Unknown command `%s'.\n"), argv[optind]);
fprintf(stderr, "Unknown command `%s'.\n", argv[optind]);
usage(true);
close(fd);