* Cleanup and tuning of previous commit
authorArt Cancro <ajc@citadel.org>
Fri, 20 Aug 2010 01:57:00 +0000 (01:57 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 20 Aug 2010 01:57:00 +0000 (01:57 +0000)
citadel/clientsocket.c
citadel/modules/upgrade/serv_upgrade.c
citadel/textclient/tuiconfig.c
citadel/utillib/citadel_ipc.c
citadel/utils/setup.c

index a9325a2b3ebe3ccee2ceb61b28ec71f84db26ec1..67976f19fb6ddd8b453af9410fffceab821ef5af 100644 (file)
 int sock_connect(char *host, char *service)
 {
        struct in6_addr serveraddr;
-       struct addrinfo hints, *res = NULL;
-       int rc;
+       struct addrinfo hints;
+       struct addrinfo *res = NULL;
+       struct addrinfo *ai = NULL;
+       int rc = (-1);
        int sock = (-1);
 
        if ((host == NULL) || IsEmptyStr(host))
@@ -92,16 +94,12 @@ int sock_connect(char *host, char *service)
        /*
         * Try all available addresses until we connect to one or until we run out.
         */
-       struct addrinfo *ai;
        for (ai = res; ai != NULL; ai = ai->ai_next) {
-               /* FIXME display the address to which we are trying to connect */
-
                sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
                if (sock < 0) {
                        CtdlLogPrintf(CTDL_ERR, "socket() failed: %s\n", strerror(errno));
                        return(-1);
                }
-
                rc = connect(sock, res->ai_addr, res->ai_addrlen);
                if (rc >= 0) {
                        return(sock);
index 4b6079905587701e4c988e4ccac121cb7b32282b..20497ded7e97eaa86ef0a91b88cb1334d1407834 100644 (file)
@@ -251,7 +251,7 @@ void update_config(void) {
        }
 
        if (CitControl.version < 623) {
-               strcpy(config.c_ip_addr, "0.0.0.0");
+               strcpy(config.c_ip_addr, "*");
        }
 
        if (CitControl.version < 650) {
index 61f8e58371760e25b910db509231d5a59014ebdc..95596cd855303d15a9b544d5b14142fe90689c12 100644 (file)
@@ -165,7 +165,7 @@ void do_system_configuration(CtdlIPC *ipc)
                "Automatically delete committed database logs",
                atoi(&sc[43][0]))));
 
-       strprompt("Server IP address (0.0.0.0 for 'any')", &sc[37][0], 15);
+       strprompt("Server IP address (* for 'any')", &sc[37][0], 15);
        strprompt("POP3 server port (-1 to disable)", &sc[23][0], 5);
        strprompt("POP3S server port (-1 to disable)", &sc[40][0], 5);
        strprompt("IMAP server port (-1 to disable)", &sc[27][0], 5);
index 01e890241f00212b3ee048830c0bb4445f1e94c0..6ed0cf671565377ff41582860ea2d2f47d7b2f51 100644 (file)
@@ -2619,8 +2619,10 @@ int CtdlIPCGenericCommand(CtdlIPC *ipc,
 static int tcp_connectsock(char *host, char *service)
 {
        struct in6_addr serveraddr;
-       struct addrinfo hints, *res = NULL;
-       int rc;
+       struct addrinfo hints;
+       struct addrinfo *res = NULL;
+       struct addrinfo *ai = NULL;
+       int rc = (-1);
        int sock = (-1);
 
        if ((host == NULL) || IsEmptyStr(host)) {
@@ -2642,7 +2644,8 @@ static int tcp_connectsock(char *host, char *service)
        if (rc == 1) {                                          /* dotted quad */
                hints.ai_family = AF_INET;
                hints.ai_flags |= AI_NUMERICHOST;
-       } else {
+       }
+       else {
                rc = inet_pton(AF_INET6, host, &serveraddr);
                if (rc == 1) {                                  /* IPv6 address */
                        hints.ai_family = AF_INET6;
@@ -2654,30 +2657,22 @@ static int tcp_connectsock(char *host, char *service)
 
        rc = getaddrinfo(host, service, &hints, &res);
        if (rc != 0) {
-               //      CtdlLogPrintf(CTDL_ERR, "%s: %s\n", host, gai_strerror(rc));
                return(-1);
        }
 
        /*
         * Try all available addresses until we connect to one or until we run out.
         */
-       struct addrinfo *ai;
        for (ai = res; ai != NULL; ai = ai->ai_next) {
-               /* FIXME display the address to which we are trying to connect */
-fprintf(stderr, "TRYING...\n");
-
                sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
                if (sock < 0) return(-1);
 
                rc = connect(sock, ai->ai_addr, ai->ai_addrlen);
                if (rc >= 0) {
-fprintf(stderr, "CONNECTED\n");
-                       return(sock);
+                       return(sock);           /* Connected! */
                }
                else {
-fprintf(stderr, "FAILED: %s\n", strerror(errno));
-                       //      CtdlLogPrintf(CTDL_ERR, "connect() failed: %s\n", strerror(errno));
-                       close(sock);
+                       close(sock);            /* Failed.  Close the socket to avoid fd leak! */
                }
        }
 
index f69f52bebfd4b7bd4434744b65b21b92c45dead2..b7fc0f065bc9d1890ff013a199bc83024cfcc006 100644 (file)
@@ -173,9 +173,11 @@ char *setup_text[] = {
 "user ID here.  You may specify either a user name or a numeric\n"
 "UID.\n",
 
-"Specify the IP address on which your server will run.  If you\n"
-"leave this blank, or if you specify 0.0.0.0, Citadel will listen\n"
-"on all addresses.  You can usually skip this unless you are\n"
+"Specify the IP address on which your server will run.\n"
+"You can name a specific IPv4 or IPv6 address, or you can specify\n"
+"'*' for 'any address', '::' for 'any IPv6 address', or '0.0.0.0'\n"
+"for 'any IPv4 address'.  If you leave this blank, Citadel will\n"
+"listen on all addresses.  You can usually skip this unless you are\n"
 "running multiple instances of Citadel on the same computer.\n",
 
 "Specify the TCP port number on which your server will run.\n"
@@ -185,8 +187,6 @@ char *setup_text[] = {
 "of Citadel on the same computer and there is something else\n"
 "already using port 504.\n",
 
-
-
 "Specify which authentication mode you wish to use.\n"
 "\n"
 " 0. Self contained authentication\n"