From: Art Cancro Date: Wed, 8 Mar 2000 03:36:41 +0000 (+0000) Subject: * Shut off hostname resolution when dealing with Unix domain sockets X-Git-Tag: v7.86~7271 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=9dc7bcd39e5c317b6ca3f4f84f458c9cfccb878d * 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 --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 6a199495c..158d33f41 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -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 Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/citadel.h b/citadel/citadel.h index 46a55e8cf..a4d264ae8 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -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 diff --git a/citadel/citmail.c b/citadel/citmail.c index 5a41f2d5a..b4c919230 100644 --- a/citadel/citmail.c +++ b/citadel/citmail.c @@ -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); diff --git a/citadel/citserver.c b/citadel/citserver.c index 5ebd5e44c..5aafb8a51 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -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; diff --git a/citadel/control.c b/citadel/control.c index 7a354cc6f..da1040268 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -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; } diff --git a/citadel/network/mail.sysinfo b/citadel/network/mail.sysinfo index 0b5946d3f..6f937b7ef 100644 --- a/citadel/network/mail.sysinfo +++ b/citadel/network/mail.sysinfo @@ -1,72 +1,70 @@ -future +ctestsys use uncnsrd -phonenum netproc[4026]: Adding non-neighbor system to map -gdom or system 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 to map -gdom or system to map -humannode 'Cat Chat -lastcontact 952138915 Fri Mar 3 22:01:55 2000 +phonenum netproc[7145]: Adding non-neighbor system to map +gdom or system 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 to map -gdom or system 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 to map -gdom or system 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 to map +gdom or system to map +humannode PixelBBS +lastcontact 952454224 Tue Mar 7 13:37:04 2000 -charis +barbaria use uncnsrd -phonenum netproc[4026]: Adding non-neighbor system to map -gdom or system to map -humannode MascotSpeak -lastcontact 952138904 Fri Mar 3 22:01:44 2000 +phonenum netproc[4026]: Adding non-neighbor system to map +gdom or system 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 to map +gdom or system 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 to map -gdom or system 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 to map -gdom or system to map -humannode Barbaria -lastcontact 952138915 Fri Mar 3 22:01:55 2000 +phonenum netproc[4026]: Adding non-neighbor system to map +gdom or system to map +humannode MascotSpeak +lastcontact 952138904 Fri Mar 3 22:01:44 2000 -pixel +feathers use uncnsrd -phonenum netproc[4026]: Adding non-neighbor system to map -gdom or system 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 to map +gdom or system 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 to map +gdom or system 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 to map -gdom or system to map -humannode BCCS -lastcontact 952418225 Tue Mar 7 03:37:05 2000 +phonenum netproc[4026]: Adding non-neighbor system to map +gdom or system 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 to map +gdom or system to map +humannode The Future BBS +lastcontact 952138911 Fri Mar 3 22:01:51 2000 diff --git a/citadel/routines2.c b/citadel/routines2.c index d2629cd36..d4e07c929 100644 --- a/citadel/routines2.c +++ b/citadel/routines2.c @@ -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"); } diff --git a/citadel/serv_pop3.c b/citadel/serv_pop3.c index 3112c3ea1..59c7a2ca7 100644 --- a/citadel/serv_pop3.c +++ b/citadel/serv_pop3.c @@ -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); diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index cda7c3d71..b9457afe1 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -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); diff --git a/citadel/server.h b/citadel/server.h index 9f69f19bf..9b105bf85 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -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; diff --git a/citadel/setup.c b/citadel/setup.c index 1dccd12f0..15a859396 100644 --- a/citadel/setup.c +++ b/citadel/setup.c @@ -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) { diff --git a/citadel/sysconfig.h b/citadel/sysconfig.h index 70f6d01d0..98095fa70 100644 --- a/citadel/sysconfig.h +++ b/citadel/sysconfig.h @@ -82,18 +82,6 @@ #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 @@ -102,12 +90,6 @@ #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 */ diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 42feb6650..b258c03b2 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -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;