* Shut off hostname resolution when dealing with Unix domain sockets
authorArt Cancro <ajc@citadel.org>
Wed, 8 Mar 2000 03:36:41 +0000 (03:36 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 8 Mar 2000 03:36:41 +0000 (03:36 +0000)
* Cleaned up the 'citmail' MDA tool
* Added POP3 and SMTP port numbers to global system configuration

13 files changed:
citadel/ChangeLog
citadel/citadel.h
citadel/citmail.c
citadel/citserver.c
citadel/control.c
citadel/network/mail.sysinfo
citadel/routines2.c
citadel/serv_pop3.c
citadel/serv_smtp.c
citadel/server.h
citadel/setup.c
citadel/sysconfig.h
citadel/sysdep.c

index 6a199495cc0e3c35b93f6c3dbe1e9453331e60df..158d33f41f0a1d6463ec5a62313befffacc5f66b 100644 (file)
@@ -1,4 +1,9 @@
 $Log$
+Revision 1.480  2000/03/08 03:36:37  ajc
+* Shut off hostname resolution when dealing with Unix domain sockets
+* Cleaned up the 'citmail' MDA tool
+* Added POP3 and SMTP port numbers to global system configuration
+
 Revision 1.479  2000/03/07 21:54:58  ajc
 * Fixed the naming conventions and permissions for unix domain sockets.
 
@@ -1702,4 +1707,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import 
-
index 46a55e8cf496eece7f110d0074f3fa6b5e579190..a4d264ae88ddb1a28b28ef37deca224412458bf3 100644 (file)
@@ -78,6 +78,8 @@ struct config {
        long c_maxmsglen;               /* Maximum message length           */
        int c_min_workers;              /* Lower limit on number of threads */
        int c_max_workers;              /* Upper limit on number of threads */
+       int c_pop3_port;                /* POP3 listener port (usually 110) */
+       int c_smtp_port;                /* SMTP listener port (usually 25)  */
 };
 
 #define NODENAME               config.c_nodename
index 5a41f2d5a35340d46022943fff0784d8c5eeb702..b4c919230caa3a0ce2d01cf7ad8e63fd711082b7 100644 (file)
@@ -30,6 +30,8 @@
 #include "snprintf.h"
 #endif
 
+/* #define DEBUG  */   /* uncomment to get protocol traces */
+
 int serv_sock;
 
 
@@ -134,6 +136,9 @@ void serv_gets(char *buf)
         */
        buf[i] = 0;
        strip_trailing_nonprint(buf);
+#ifdef DEBUG
+       printf("> %s\n", buf);
+#endif
 }
 
 
@@ -142,7 +147,9 @@ void serv_gets(char *buf)
  */
 void serv_puts(char *buf)
 {
-       /* printf("< %s\n", buf); */
+#ifdef DEBUG
+       printf("< %s\n", buf);
+#endif
        serv_write(buf, strlen(buf));
        serv_write("\n", 1);
 }
@@ -156,7 +163,6 @@ void cleanup(int exitcode) {
 
        serv_puts("QUIT");
        serv_gets(buf);
-       fprintf(stderr, "%s\n", buf);
        exit(exitcode);
 }
 
@@ -176,32 +182,26 @@ int main(int argc, char **argv) {
        }
        strip_trailing_nonprint(fromline);
 
-       sprintf(buf, "%d", SMTP_PORT);
        serv_sock = uds_connectsock("smtp.socket");
        serv_gets(buf);
-       fprintf(stderr, "%s\n", buf);
        if (buf[0]!='2') cleanup(1);
 
        serv_puts("HELO localhost");
        serv_gets(buf);
-       fprintf(stderr, "%s\n", buf);
        if (buf[0]!='2') cleanup(1);
 
        sprintf(buf, "MAIL %s", fromline);
        serv_puts(buf);
        serv_gets(buf);
-       fprintf(stderr, "%s\n", buf);
        if (buf[0]!='2') cleanup(1);
 
        sprintf(buf, "RCPT To: %s", argv[1]);
        serv_puts(buf);
        serv_gets(buf);
-       fprintf(stderr, "%s\n", buf);
        if (buf[0]!='2') cleanup(1);
 
        serv_puts("DATA");
        serv_gets(buf);
-       fprintf(stderr, "%s\n", buf);
        if (buf[0]!='3') cleanup(1);
 
        rewind(fp);
@@ -211,7 +211,6 @@ int main(int argc, char **argv) {
        }
        serv_puts(".");
        serv_gets(buf);
-       fprintf(stderr, "%s\n", buf);
        if (buf[0]!='2') cleanup(1);
        else cleanup(0);
        return(0);
index 5ebd5e44cf7a01d4ecebc51e3c1a8e87f0c5e9e1..5aafb8a518a399a3253e7bcef46e277d1d7735fe 100644 (file)
@@ -401,7 +401,7 @@ void cmd_iden(char *argbuf)
        if (num_parms(argbuf)<4) {
                cprintf("%d usage error\n",ERROR);
                return;
-               }
+       }
 
        dev_code = extract_int(argbuf,0);
        cli_code = extract_int(argbuf,1);
@@ -419,15 +419,15 @@ void cmd_iden(char *argbuf)
        CC->cs_clientname[31] = 0;
 
        lprintf(9, "Looking up hostname '%s'\n", from_host);
-       if ((strlen(from_host)>0) && 
-          (is_public_client(CC->cs_host))) {
+       if ((strlen(from_host)>0)
+         && ( (CC->is_local_socket) || (is_public_client(CC->cs_host)))) {
                if ((addr.s_addr = inet_addr(from_host)) != INADDR_NONE)
                        locate_host(CC->cs_host, &addr);
                else {
                        safestrncpy(CC->cs_host, from_host, sizeof CC->cs_host);
                        CC->cs_host[24] = 0;
-                       }
                }
+       }
 
        syslog(LOG_NOTICE,"client %d/%d/%01d.%02d (%s)\n",
                dev_code,
@@ -436,7 +436,7 @@ void cmd_iden(char *argbuf)
                (rev_level % 100),
                desc);
                cprintf("%d Ok\n",OK);
-       }
+}
 
 
 /*
@@ -721,8 +721,14 @@ void begin_session(struct CitContext *con)
        safestrncpy(con->cs_host, config.c_fqdn, sizeof con->cs_host);
        con->cs_host[sizeof con->cs_host - 1] = 0;
        len = sizeof sin;
-       if (!getpeername(con->client_socket, (struct sockaddr *) &sin, &len))
-               locate_host(con->cs_host, &sin.sin_addr);
+       if (!CC->is_local_socket) {
+               if (!getpeername(con->client_socket,
+                  (struct sockaddr *) &sin, &len))
+                       locate_host(con->cs_host, &sin.sin_addr);
+       }
+       else {
+               strcpy(con->cs_host, "");
+       }
        con->cs_flags = 0;
        con->upload_type = UPL_FILE;
        con->dl_is_net = 0;
index 7a354cc6f4b02eb83de19f2e9a3a2ae70139d244..da104026899e722724547a1add38ef94b70afc9a 100644 (file)
@@ -165,6 +165,8 @@ void cmd_conf(char *argbuf) {
                cprintf("%d\n", config.c_maxmsglen);
                cprintf("%d\n", config.c_min_workers);
                cprintf("%d\n", config.c_max_workers);
+               cprintf("%d\n", config.c_pop3_port);
+               cprintf("%d\n", config.c_smtp_port);
                cprintf("000\n");
                }
 
@@ -244,6 +246,10 @@ void cmd_conf(char *argbuf) {
                                        config.c_min_workers = atoi(buf);
                        case 22: if (atoi(buf) >= config.c_min_workers)
                                        config.c_max_workers = atoi(buf);
+                       case 23: config.c_pop3_port = atoi(buf);
+                               break;
+                       case 24: config.c_smtp_port = atoi(buf);
+                               break;
                        }
                    ++a;
                    }
index 0b5946d3f7b95be574b34bf69d53ddbb142b31a7..6f937b7ef6f94991da3026329e9842c80f28ff5a 100644 (file)
@@ -1,72 +1,70 @@
-future
+ctestsys
 use uncnsrd
-phonenum netproc[4026]: Adding non-neighbor system <catchat> to map
-gdom or system <catchat> to map
-humannode The Future BBS
-lastcontact 952138911 Fri Mar  3 22:01:51 2000
+phonenum US 612 470 9635
+gdom MN
+humannode C-86 Test System
+lastcontact 952375033 Mon Mar  6 15:37:13 2000
 
-catchat
+bccs
 use uncnsrd
-phonenum netproc[4026]: Adding non-neighbor system <rundale> to map
-gdom or system <rundale> to map
-humannode 'Cat Chat
-lastcontact 952138915 Fri Mar  3 22:01:55 2000
+phonenum netproc[7145]: Adding non-neighbor system <internet> to map
+gdom or system <internet> to map
+humannode BCCS
+lastcontact 952418225 Tue Mar  7 03:37:05 2000
 
-rundale
-use uncnsrd
-phonenum US 609 854 9135
-gdom NJ
-humannode Rundale
-lastcontact 952138909 Fri Mar  3 22:01:49 2000
+internet
+uum %s
+humannode Internet Gateway
+lastcontact 952485943 Tue Mar  7 22:25:43 2000
 
-jacs
-use uncnsrd
-phonenum US6093461224
-gdom NJ
-humannode JACS
-lastcontact 952138912 Fri Mar  3 22:01:52 2000
+uncnsrd
+bin Mail
+phonenum US 914 244 3252
+humannode Uncensored
+lastcontact 952485944 Tue Mar  7 22:25:44 2000
 
-dogpound2
-use uncnsrd
-phonenum netproc[4026]: Adding non-neighbor system <sbn> to map
-gdom or system <sbn> to map
-humannode Dog Pound BBS II
-lastcontact 952349824 Mon Mar  6 08:37:04 2000
+test
+bin Mail
 
-sbn
-use uncnsrd
-phonenum netproc[4026]: Adding non-neighbor system <feathers> to map
-gdom or system <feathers> to map
-humannode Super BBS Network
-lastcontact 952138908 Fri Mar  3 22:01:48 2000
+tux
+bin Mail
+phonenum US 800 555 1212
+humannode My System
+lastcontact 951540103 Fri Feb 25 23:41:43 2000
 
-feathers
+tesseract
+bin Mail
+phonenum US 800 555 1212
+humannode Tesseract Project
+lastcontact 952468624 Tue Mar  7 17:37:04 2000
+
+pixel
 use uncnsrd
-phonenum CA (604) 589-8539
-gdom BC
-humannode Feathers & Furballs
-lastcontact 952138915 Fri Mar  3 22:01:55 2000
+phonenum netproc[4026]: Adding non-neighbor system <tesseract> to map
+gdom or system <tesseract> to map
+humannode PixelBBS
+lastcontact 952454224 Tue Mar  7 13:37:04 2000
 
-charis
+barbaria
 use uncnsrd
-phonenum netproc[4026]: Adding non-neighbor system <gateway> to map
-gdom or system <gateway> to map
-humannode MascotSpeak
-lastcontact 952138904 Fri Mar  3 22:01:44 2000
+phonenum netproc[4026]: Adding non-neighbor system <pixel> to map
+gdom or system <pixel> to map
+humannode Barbaria
+lastcontact 952138915 Fri Mar  3 22:01:55 2000
 
-gateway
+haven
 use uncnsrd
-phonenum US (609) 931-3014
-gdom NJ
-humannode Gateway
-lastcontact 952138913 Fri Mar  3 22:01:53 2000
+phonenum netproc[4026]: Adding non-neighbor system <barbaria> to map
+gdom or system <barbaria> to map
+humannode Haven BBS
+lastcontact 952138910 Fri Mar  3 22:01:50 2000
 
-amigazon
+mnmensa
 use uncnsrd
-phonenum US (609) 953 8159
-gdom NJ
-humannode The Amiga Zone
-lastcontact 952138913 Fri Mar  3 22:01:53 2000
+phonenum US (612) 757-7307
+gdom MN
+humannode MN-Mensa
+lastcontact 952138905 Fri Mar  3 22:01:45 2000
 
 cbbs
 use uncnsrd
@@ -75,71 +73,73 @@ gdom Cinci
 humannode The CBBS
 lastcontact 952138903 Fri Mar  3 22:01:43 2000
 
-mnmensa
+amigazon
 use uncnsrd
-phonenum US (612) 757-7307
-gdom MN
-humannode MN-Mensa
-lastcontact 952138905 Fri Mar  3 22:01:45 2000
+phonenum US (609) 953 8159
+gdom NJ
+humannode The Amiga Zone
+lastcontact 952138913 Fri Mar  3 22:01:53 2000
 
-haven
+gateway
 use uncnsrd
-phonenum netproc[4026]: Adding non-neighbor system <barbaria> to map
-gdom or system <barbaria> to map
-humannode Haven BBS
-lastcontact 952138910 Fri Mar  3 22:01:50 2000
+phonenum US (609) 931-3014
+gdom NJ
+humannode Gateway
+lastcontact 952138913 Fri Mar  3 22:01:53 2000
 
-barbaria
+charis
 use uncnsrd
-phonenum netproc[4026]: Adding non-neighbor system <pixel> to map
-gdom or system <pixel> to map
-humannode Barbaria
-lastcontact 952138915 Fri Mar  3 22:01:55 2000
+phonenum netproc[4026]: Adding non-neighbor system <gateway> to map
+gdom or system <gateway> to map
+humannode MascotSpeak
+lastcontact 952138904 Fri Mar  3 22:01:44 2000
 
-pixel
+feathers
 use uncnsrd
-phonenum netproc[4026]: Adding non-neighbor system <tesseract> to map
-gdom or system <tesseract> to map
-humannode PixelBBS
-lastcontact 952454224 Tue Mar  7 13:37:04 2000
-
-tesseract
-bin Mail
-phonenum US 800 555 1212
-humannode Tesseract Project
-lastcontact 952468624 Tue Mar  7 17:37:04 2000
+phonenum CA (604) 589-8539
+gdom BC
+humannode Feathers & Furballs
+lastcontact 952138915 Fri Mar  3 22:01:55 2000
 
-tux
-bin Mail
-phonenum US 800 555 1212
-humannode My System
-lastcontact 951540103 Fri Feb 25 23:41:43 2000
+sbn
+use uncnsrd
+phonenum netproc[4026]: Adding non-neighbor system <feathers> to map
+gdom or system <feathers> to map
+humannode Super BBS Network
+lastcontact 952138908 Fri Mar  3 22:01:48 2000
 
-test
-bin Mail
+dogpound2
+use uncnsrd
+phonenum netproc[4026]: Adding non-neighbor system <sbn> to map
+gdom or system <sbn> to map
+humannode Dog Pound BBS II
+lastcontact 952349824 Mon Mar  6 08:37:04 2000
 
-uncnsrd
-bin Mail
-phonenum US 914 244 3252
-humannode Uncensored
-lastcontact 952439824 Tue Mar  7 09:37:04 2000
+jacs
+use uncnsrd
+phonenum US6093461224
+gdom NJ
+humannode JACS
+lastcontact 952138912 Fri Mar  3 22:01:52 2000
 
-internet
-uum %s
-humannode Internet Gateway
-lastcontact 952468623 Tue Mar  7 17:37:03 2000
+rundale
+use uncnsrd
+phonenum US 609 854 9135
+gdom NJ
+humannode Rundale
+lastcontact 952138909 Fri Mar  3 22:01:49 2000
 
-bccs
+catchat
 use uncnsrd
-phonenum netproc[7145]: Adding non-neighbor system <internet> to map
-gdom or system <internet> to map
-humannode BCCS
-lastcontact 952418225 Tue Mar  7 03:37:05 2000
+phonenum netproc[4026]: Adding non-neighbor system <rundale> to map
+gdom or system <rundale> to map
+humannode 'Cat Chat
+lastcontact 952138915 Fri Mar  3 22:01:55 2000
 
-ctestsys
+future
 use uncnsrd
-phonenum US 612 470 9635
-gdom MN
-humannode C-86 Test System
-lastcontact 952375033 Mon Mar  6 15:37:13 2000
+phonenum netproc[4026]: Adding non-neighbor system <catchat> to map
+gdom or system <catchat> to map
+humannode The Future BBS
+lastcontact 952138911 Fri Mar  3 22:01:51 2000
 
index d2629cd36efcd300fc2d6f3a0c4ecb452766e5ec..d4e07c9292291e75c1eb6eb69ff50c53bb732e7f 100644 (file)
@@ -623,7 +623,7 @@ void read_bio(void)
 void do_system_configuration(void)
 {
        char buf[256];
-       char sc[23][256];
+       char sc[25][256];
        int expire_mode = 0;
        int expire_value = 0;
        int a;
@@ -637,7 +637,7 @@ void do_system_configuration(void)
        if (buf[0] == '1') {
                a = 0;
                while (serv_gets(buf), strcmp(buf, "000")) {
-                       if (a < 23)
+                       if (a < 25)
                                strcpy(&sc[a][0], buf);
                        ++a;
                }
@@ -695,6 +695,8 @@ void do_system_configuration(void)
        strprompt("Minimum number of worker threads", &sc[21][0], 3);
        strprompt("Maximum number of worker threads", &sc[22][0], 3);
        strprompt("Server-to-server networking password", &sc[15][0], 19);
+       strprompt("POP3 server port (-1 to disable)", &sc[23][0], 5);
+       strprompt("SMTP server port (-1 to disable)", &sc[24][0], 5);
 
 
        /* Expiry settings */
@@ -733,7 +735,7 @@ void do_system_configuration(void)
                serv_puts("CONF set");
                serv_gets(buf);
                if (buf[0] == '4') {
-                       for (a = 0; a < 23; ++a)
+                       for (a = 0; a < 25; ++a)
                                serv_puts(&sc[a][0]);
                        serv_puts("000");
                }
index 3112c3ea1a899d6f6025c60472d2f9c2f7f00db5..59c7a2ca74c0282321826fd1b3fb900d907331ab 100644 (file)
@@ -538,7 +538,7 @@ void pop3_command_loop(void) {
 char *Dynamic_Module_Init(void)
 {
        SYM_POP3 = CtdlGetDynamicSymbol();
-       CtdlRegisterServiceHook(POP3_PORT,
+       CtdlRegisterServiceHook(config.c_pop3_port,
                                NULL,
                                pop3_greeting,
                                pop3_command_loop);
index cda7c3d711a401aaac578881b9b1d7dcdcf5d8d9..b9457afe171e61c83f769afd60186c4f0b996e85 100644 (file)
@@ -1426,7 +1426,7 @@ char *Dynamic_Module_Init(void)
        SYM_SMTP = CtdlGetDynamicSymbol();
        SYM_SMTP_RECP = CtdlGetDynamicSymbol();
 
-       CtdlRegisterServiceHook(SMTP_PORT,              /* On the net... */
+       CtdlRegisterServiceHook(config.c_smtp_port,     /* On the net... */
                                NULL,
                                smtp_greeting,
                                smtp_command_loop);
index 9f69f19bf05c9d378f32636245a7c79074fdbc9f..9b105bf85db544ba70bd8254680c72cdc723ad83 100644 (file)
@@ -63,6 +63,7 @@ struct CitContext {
        int internal_pgm;       /* authenticated as internal program */
        char temp[32];          /* temp file name */
        int nologin;            /* not allowed to log in */
+       int is_local_socket;    /* set to 1 if client is on unix domain sock */
 
        char net_node[32];      /* Is the client another Citadel server? */
        int client_socket;
index 1dccd12f0cceedad621eeb3e4b60504f521fd941..15a859396dd03f799c865797909ccae8c465e86a 100644 (file)
@@ -843,6 +843,12 @@ int main(int argc, char *argv[])
                config.c_ep.expire_value = 150;
        }
 
+       /*
+        * Default port numbers for various services
+        */
+       if (config.c_pop3_port == 0) config.c_pop3_port = 110;
+       if (config.c_smtp_port == 0) config.c_smtp_port = 25;
+
 
        /* Go through a series of dialogs prompting for config info */
        for (curr = 1; curr <= MAXSETUP; ++curr) {
index 70f6d01d0c94d076d0294bb838f9237c02958598..98095fa70ca4bee5819af0da813a26f79c35b9a0 100644 (file)
 #define MAXFLOORS      16
 
 
-/* 
- * These define what port to listen on for various services.
- * If you don't want to run these services on the network, you can specify
- * a negative port number to create Unix domain sockets.  This will allow,
- * for example, the "citmail" utility to connect to the Citadel SMTP server
- * to import email, without having to actually run Citadel SMTP on the network.
- *
- * FIXME ... put this in a programmable config somewhere
- */
-#define POP3_PORT              110
-#define SMTP_PORT              25
-
 /*
  * SMTP delivery retry and give-up times
  * FIXME ... put this in a programmable config somewhere
 #define SMTP_GIVE_UP           259200  /* give up after 3 days */
 
 
-/* 
- * Pathname template to use for Unix domain sockets
- */
-#define USOCKPATH              "/tmp/citadel%04x"
-
-
 /*
  * The names of rooms which are automatically created by the system
  */
index 42feb6650ab7bdf4ef6c4b97645b84605fe88f3c..b258c03b2628272def49c3b99ed5d5347886e1e6 100644 (file)
@@ -1044,7 +1044,7 @@ SETUP_FD: memcpy(&readfds, &masterfds, sizeof(fd_set) );
                }
 
                /* Next, check to see if it's a new client connecting
-                * on the master socket.
+                * on a master socket.
                 */
                else for (serviceptr = ServiceHookTable; serviceptr != NULL;
                     serviceptr = serviceptr->next ) {
@@ -1071,6 +1071,10 @@ SETUP_FD:        memcpy(&readfds, &masterfds, sizeof(fd_set) );
                                        con->client_socket = ssock;
                                        con->h_command_function =
                                                serviceptr->h_command_function;
+
+                                       /* Determine whether local socket */
+                                       if (serviceptr->sockpath != NULL)
+                                               con->is_local_socket = 1;
        
                                        /* Set the SO_REUSEADDR socket option */
                                        i = 1;