cp();
- asprintf(&fname, "%s/tinc.conf", confbase);
+ xasprintf(&fname, "%s/tinc.conf", confbase);
x = read_config_file(config_tree, fname);
if(x == -1) { /* System error: complain */
char *p;
directory = get_current_dir_name();
- asprintf(&p, "%s/%s", directory, fn);
+ xasprintf(&p, "%s/%s", directory, fn);
free(fn);
free(directory);
fn = p;
cp();
- asprintf(&fname, "%s/hosts/%s", confbase, c->name);
+ xasprintf(&fname, "%s/hosts/%s", confbase, c->name);
x = read_config_file(c->config_tree, fname);
free(fname);
#include "process.h"
#include "subnet.h"
#include "utils.h"
+#include "xalloc.h"
static bool graph_changed = true;
n->mtuevent = NULL;
}
- asprintf(&envp[0], "NETNAME=%s", netname ? : "");
- asprintf(&envp[1], "DEVICE=%s", device ? : "");
- asprintf(&envp[2], "INTERFACE=%s", iface ? : "");
- asprintf(&envp[3], "NODE=%s", n->name);
+ xasprintf(&envp[0], "NETNAME=%s", netname ? : "");
+ xasprintf(&envp[1], "DEVICE=%s", device ? : "");
+ xasprintf(&envp[2], "INTERFACE=%s", iface ? : "");
+ xasprintf(&envp[3], "NODE=%s", n->name);
sockaddr2str(&n->address, &address, &port);
- asprintf(&envp[4], "REMOTEADDRESS=%s", address);
- asprintf(&envp[5], "REMOTEPORT=%s", port);
+ xasprintf(&envp[4], "REMOTEADDRESS=%s", address);
+ xasprintf(&envp[5], "REMOTEPORT=%s", port);
envp[6] = NULL;
execute_script(n->status.reachable ? "host-up" : "host-down", envp);
- asprintf(&name,
+ xasprintf(&name,
n->status.reachable ? "hosts/%s-up" : "hosts/%s-down",
n->name);
execute_script(name, envp);
if(filename[0] == '|') {
file = popen(filename + 1, "w");
} else {
- asprintf(&tmpname, "%s.new", filename);
+ xasprintf(&tmpname, "%s.new", filename);
file = fopen(tmpname, "w");
}
for(node = connection_tree->head; node; node = node->next) {
c = node->data;
- asprintf(&fname, "%s/hosts/%s", confbase, c->name);
+ xasprintf(&fname, "%s/hosts/%s", confbase, c->name);
if(stat(fname, &s) || s.st_mtime > last_config_check)
terminate_connection(c, c->status.active);
free(fname);
/* Else, check if a harnessed public key is in the config file */
- asprintf(&fname, "%s/hosts/%s", confbase, c->name);
+ xasprintf(&fname, "%s/hosts/%s", confbase, c->name);
fp = fopen(fname, "r");
if(fp) {
/* Try again with PEM_read_RSA_PUBKEY. */
- asprintf(&fname, "%s/hosts/%s", confbase, c->name);
+ xasprintf(&fname, "%s/hosts/%s", confbase, c->name);
fp = fopen(fname, "r");
if(fp) {
}
if(!get_config_string(lookup_config(config_tree, "PrivateKeyFile"), &fname))
- asprintf(&fname, "%s/rsa_key.priv", confbase);
+ xasprintf(&fname, "%s/rsa_key.priv", confbase);
fp = fopen(fname, "r");
myself->connection = new_connection();
init_configuration(&myself->connection->config_tree);
- asprintf(&myself->hostname, _("MYSELF"));
- asprintf(&myself->connection->hostname, _("MYSELF"));
+ xasprintf(&myself->hostname, _("MYSELF"));
+ xasprintf(&myself->connection->hostname, _("MYSELF"));
myself->connection->options = 0;
myself->connection->protocol_version = PROT_CURRENT;
return false;
if(!get_config_string(lookup_config(myself->connection->config_tree, "Port"), &myport))
- asprintf(&myport, "655");
+ xasprintf(&myport, "655");
/* Read in all the subnets specified in the host configuration file */
return false;
/* Run tinc-up script to further initialize the tap interface */
- asprintf(&envp[0], "NETNAME=%s", netname ? : "");
- asprintf(&envp[1], "DEVICE=%s", device ? : "");
- asprintf(&envp[2], "INTERFACE=%s", iface ? : "");
- asprintf(&envp[3], "NAME=%s", myself->name);
+ xasprintf(&envp[0], "NETNAME=%s", netname ? : "");
+ xasprintf(&envp[1], "DEVICE=%s", device ? : "");
+ xasprintf(&envp[2], "INTERFACE=%s", iface ? : "");
+ xasprintf(&envp[3], "NAME=%s", myself->name);
envp[4] = NULL;
execute_script("tinc-up", envp);
close(listen_socket[i].udp);
}
- asprintf(&envp[0], "NETNAME=%s", netname ? : "");
- asprintf(&envp[1], "DEVICE=%s", device ? : "");
- asprintf(&envp[2], "INTERFACE=%s", iface ? : "");
- asprintf(&envp[3], "NAME=%s", myself->name);
+ xasprintf(&envp[0], "NETNAME=%s", netname ? : "");
+ xasprintf(&envp[1], "DEVICE=%s", device ? : "");
+ xasprintf(&envp[2], "INTERFACE=%s", iface ? : "");
+ xasprintf(&envp[3], "NAME=%s", myself->name);
envp[4] = NULL;
exit_requests();
get_config_string(c->outgoing->cfg, &address);
if(!get_config_string(lookup_config(c->config_tree, "Port"), &port))
- asprintf(&port, "655");
+ xasprintf(&port, "655");
c->outgoing->ai = str2addrinfo(address, port, SOCK_STREAM);
free(address);
cp();
if(sa->sa.sa_family == AF_UNKNOWN) {
- asprintf(&str, _("%s port %s"), sa->unknown.address, sa->unknown.port);
+ xasprintf(&str, _("%s port %s"), sa->unknown.address, sa->unknown.port);
return str;
}
gai_strerror(err));
}
- asprintf(&str, _("%s port %s"), address, port);
+ xasprintf(&str, _("%s port %s"), address, port);
return str;
}
cp();
#ifndef HAVE_MINGW
- len = asprintf(&scriptname, "\"%s/%s\"", confbase, name);
+ len = xasprintf(&scriptname, "\"%s/%s\"", confbase, name);
#else
- len = asprintf(&scriptname, "\"%s/%s.bat\"", confbase, name);
+ len = xasprintf(&scriptname, "\"%s/%s.bat\"", confbase, name);
#endif
if(len < 0)
return false;
cp();
- /* Use vsnprintf instead of vasprintf: faster, no memory
+ /* Use vsnprintf instead of vxasprintf: faster, no memory
fragmentation, cleanup is automatic, and there is a limit on the
input buffer anyway */
}
if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
- asprintf(&iface, "tun%d", ppa);
+ xasprintf(&iface, "tun%d", ppa);
device_info = _("Solaris tun device");
char netstr[MAXNETSTR + 7] = "SUBNET=";
char *name, *address, *port;
- asprintf(&envp[0], "NETNAME=%s", netname ? : "");
- asprintf(&envp[1], "DEVICE=%s", device ? : "");
- asprintf(&envp[2], "INTERFACE=%s", iface ? : "");
- asprintf(&envp[3], "NODE=%s", owner->name);
+ xasprintf(&envp[0], "NETNAME=%s", netname ? : "");
+ xasprintf(&envp[1], "DEVICE=%s", device ? : "");
+ xasprintf(&envp[2], "INTERFACE=%s", iface ? : "");
+ xasprintf(&envp[3], "NODE=%s", owner->name);
if(owner != myself) {
sockaddr2str(&owner->address, &address, &port);
- asprintf(&envp[4], "REMOTEADDRESS=%s", address);
- asprintf(&envp[5], "REMOTEPORT=%s", port);
+ xasprintf(&envp[4], "REMOTEADDRESS=%s", address);
+ xasprintf(&envp[5], "REMOTEPORT=%s", port);
envp[6] = netstr;
envp[7] = NULL;
} else {
} else
fprintf(stderr, _("Done.\n"));
- asprintf(&filename, "%s/rsa_key.priv", confbase);
+ xasprintf(&filename, "%s/rsa_key.priv", confbase);
f = ask_and_open(filename, _("private RSA key"));
if(!f)
free(filename);
if(name)
- asprintf(&filename, "%s/hosts/%s", confbase, name);
+ xasprintf(&filename, "%s/hosts/%s", confbase, name);
else
- asprintf(&filename, "%s/rsa_key.pub", confbase);
+ xasprintf(&filename, "%s/rsa_key.pub", confbase);
f = ask_and_open(filename, _("public RSA key"));
#endif
if(netname)
- asprintf(&identname, "tinc.%s", netname);
+ xasprintf(&identname, "tinc.%s", netname);
else
identname = xstrdup("tinc");
if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\tinc", 0, KEY_READ, &key)) {
if(!RegQueryValueEx(key, NULL, 0, 0, installdir, &len)) {
if(!logfilename)
- asprintf(&logfilename, "%s/log/%s.log", identname);
+ xasprintf(&logfilename, "%s/log/%s.log", identname);
if(!confbase) {
if(netname)
- asprintf(&confbase, "%s/%s", installdir, netname);
+ xasprintf(&confbase, "%s/%s", installdir, netname);
else
- asprintf(&confbase, "%s", installdir);
+ xasprintf(&confbase, "%s", installdir);
}
}
RegCloseKey(key);
#endif
if(!pidfilename)
- asprintf(&pidfilename, LOCALSTATEDIR "/run/%s.pid", identname);
+ xasprintf(&pidfilename, LOCALSTATEDIR "/run/%s.pid", identname);
if(!logfilename)
- asprintf(&logfilename, LOCALSTATEDIR "/log/%s.log", identname);
+ xasprintf(&logfilename, LOCALSTATEDIR "/log/%s.log", identname);
if(netname) {
if(!confbase)
- asprintf(&confbase, CONFDIR "/tinc/%s", netname);
+ xasprintf(&confbase, CONFDIR "/tinc/%s", netname);
else
logger(LOG_INFO, _("Both netname and configuration directory given, using the latter..."));
} else {
if(!confbase)
- asprintf(&confbase, CONFDIR "/tinc");
+ xasprintf(&confbase, CONFDIR "/tinc");
}
}
cp();
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
- asprintf(&device, LOCALSTATEDIR "/run/%s.umlsocket", identname);
+ xasprintf(&device, LOCALSTATEDIR "/run/%s.umlsocket", identname);
get_config_string(lookup_config(config_tree, "Interface"), &iface);