]> git.meshlink.io Git - meshlink/blobdiff - src/tincctl.c
Fix warnings from Doxygen.
[meshlink] / src / tincctl.c
index c28c20ec8599fa4532ed3fb219ab92925c2fad31..33b26c2b9afac0c48bbe5ca8c77118b604cde0a5 100644 (file)
@@ -1,6 +1,6 @@
 /*
     tincctl.c -- Controlling a running tincd
-    Copyright (C) 2007-2014 Guus Sliepen <guus@tinc-vpn.org>
+    Copyright (C) 2014 Guus Sliepen <guus@meshlink.io>
 
     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
@@ -33,7 +33,6 @@
 #include "ecdsagen.h"
 #include "info.h"
 #include "invitation.h"
-#include "names.h"
 #include "rsagen.h"
 #include "utils.h"
 #include "tincctl.h"
@@ -144,7 +143,7 @@ static void usage(bool status) {
                                "  join INVITATION            Join a VPN using an INVITIATION\n"
                                "  network [NETNAME]          List all known networks, or switch to the one named NETNAME.\n"
                                "\n");
-               printf("Report bugs to tinc@tinc-vpn.org.\n");
+               printf("Report bugs to bugs@meshlink.io.\n");
        }
 }
 
@@ -358,10 +357,10 @@ static FILE *ask_and_open(const char *filename, const char *what, const char *mo
   Generate a public/private ECDSA keypair, and ask for a file to store
   them in.
 */
-bool ecdsa_keygen(bool ask) {
+static bool ecdsa_keygen(bool ask) {
        ecdsa_t *key;
        FILE *f;
-       char *pubname, *privname;
+       char pubname[PATH_MAX], privname[PATH_MAX];
 
        fprintf(stderr, "Generating ECDSA keypair:\n");
 
@@ -371,9 +370,8 @@ bool ecdsa_keygen(bool ask) {
        } else
                fprintf(stderr, "Done.\n");
 
-       xasprintf(&privname, "%s" SLASH "ecdsa_key.priv", confbase);
+       snprintf(privname,PATH_MAX, "%s" SLASH "ecdsa_key.priv", confbase);
        f = ask_and_open(privname, "private ECDSA key", "a", ask, 0600);
-       free(privname);
 
        if(!f)
                return false;
@@ -388,19 +386,17 @@ bool ecdsa_keygen(bool ask) {
        fclose(f);
 
        if(name)
-               xasprintf(&pubname, "%s" SLASH "hosts" SLASH "%s", confbase, name);
+               snprintf(pubname, PATH_MAX,"%s" SLASH "hosts" SLASH "%s", confbase, name);
        else
-               xasprintf(&pubname, "%s" SLASH "ecdsa_key.pub", confbase);
+               snprintf(pubname, PATH_MAX,"%s" SLASH "ecdsa_key.pub", confbase);
 
        f = ask_and_open(pubname, "public ECDSA key", "a", ask, 0666);
-       free(pubname);
 
        if(!f)
                return false;
 
        char *pubkey = ecdsa_get_base64_public_key(key);
        fprintf(f, "ECDSAPublicKey = %s\n", pubkey);
-       free(pubkey);
 
        fclose(f);
        ecdsa_free(key);
@@ -412,10 +408,10 @@ bool ecdsa_keygen(bool ask) {
   Generate a public/private RSA keypair, and ask for a file to store
   them in.
 */
-bool rsa_keygen(int bits, bool ask) {
+static bool rsa_keygen(int bits, bool ask) {
        rsa_t *key;
        FILE *f;
-       char *pubname, *privname;
+       char pubname[PATH_MAX], privname[PATH_MAX];
 
        fprintf(stderr, "Generating %d bits keys:\n", bits);
 
@@ -425,9 +421,8 @@ bool rsa_keygen(int bits, bool ask) {
        } else
                fprintf(stderr, "Done.\n");
 
-       xasprintf(&privname, "%s" SLASH "rsa_key.priv", confbase);
+       snprintf(privname,PATH_MAX, "%s" SLASH "rsa_key.priv", confbase);
        f = ask_and_open(privname, "private RSA key", "a", ask, 0600);
-       free(privname);
 
        if(!f)
                return false;
@@ -442,12 +437,11 @@ bool rsa_keygen(int bits, bool ask) {
        fclose(f);
 
        if(name)
-               xasprintf(&pubname, "%s" SLASH "hosts" SLASH "%s", confbase, name);
+               snprintf(pubname,PATH_MAX,"%s" SLASH "hosts" SLASH "%s", confbase, name);
        else
-               xasprintf(&pubname, "%s" SLASH "rsa_key.pub", confbase);
+               snprintf(pubname,PATH_MAX,"%s" SLASH "rsa_key.pub", confbase);
 
        f = ask_and_open(pubname, "public RSA key", "a", ask, 0666);
-       free(pubname);
 
        if(!f)
                return false;
@@ -1322,8 +1316,6 @@ const var_t variables[] = {
        {"ScriptsInterpreter", VAR_SERVER},
        {"StrictSubnets", VAR_SERVER},
        {"TunnelServer", VAR_SERVER},
-       {"UDPRcvBuf", VAR_SERVER},
-       {"UDPSndBuf", VAR_SERVER},
        {"VDEGroup", VAR_SERVER},
        {"VDEPort", VAR_SERVER},
        /* Host configuration */
@@ -1483,9 +1475,9 @@ static int cmd_config(int argc, char *argv[]) {
        }
 
        // Open the right configuration file.
-       char *filename;
+       char filename[PATH_MAX];
        if(node)
-               xasprintf(&filename, "%s" SLASH "%s", hosts_dir, node);
+               snprintf(filename,PATH_MAX "%s" SLASH "%s", hosts_dir, node);
        else
                filename = tinc_conf;
 
@@ -1495,11 +1487,11 @@ static int cmd_config(int argc, char *argv[]) {
                return 1;
        }
 
-       char *tmpfile = NULL;
+       char tmpfile[PATH_MAX];
        FILE *tf = NULL;
 
        if(action >= -1) {
-               xasprintf(&tmpfile, "%s.config.tmp", filename);
+               snprintf(tmpfile,PATH_MAX, "%s.config.tmp", filename);
                tf = fopen(tmpfile, "w");
                if(!tf) {
                        fprintf(stderr, "Could not open temporary file %s: %s\n", tmpfile, strerror(errno));
@@ -1689,10 +1681,9 @@ int check_port(char *name) {
        for(int i = 0; i < 100; i++) {
                int port = 0x1000 + (rand() & 0x7fff);
                if(try_bind(port)) {
-                       char *filename;
-                       xasprintf(&filename, "%s" SLASH "hosts" SLASH "%s", confbase, name);
+                       char filename[PATH_MAX];
+                       snprintf(filename,PATH_MAX "%s" SLASH "hosts" SLASH "%s", confbase, name);
                        FILE *f = fopen(filename, "a");
-                       free(filename);
                        if(!f) {
                                fprintf(stderr, "Please change tinc's Port manually.\n");
                                return 0;
@@ -2098,7 +2089,6 @@ static int switch_network(char *name) {
        free(netname);
        netname = strcmp(name, ".") ? xstrdup(name) : NULL;
 
-       make_names();
         xasprintf(&tinc_conf, "%s" SLASH "tinc.conf", confbase);
         xasprintf(&hosts_dir, "%s" SLASH "hosts", confbase);
        xasprintf(&prompt, "%s> ", identname);
@@ -2414,7 +2404,6 @@ int main(int argc, char *argv[]) {
        if(!parse_options(argc, argv))
                return 1;
 
-       make_names();
        xasprintf(&tinc_conf, "%s" SLASH "tinc.conf", confbase);
        xasprintf(&hosts_dir, "%s" SLASH "hosts", confbase);