#ident "@(#)smail/contrib:RELEASE-3_2_0_121:patch.etrn,v 1.4 2000/01/31 17:17:13 woods Exp" From pi@complx.LF.net Sun Jan 30 14:25:58 2000 Message-Id: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="%--multipart-mixed-boundary-4.31517.949260351--%" Date: Sun, 30 Jan 2000 20:25:51 +0100 (CET) From: pi@LF.net (Kurt Jaeger) Subject: smail 3.2.0.109 ETRN patch (adapted from 3.2.103, plus mods) To: woods@planix.com Cc: pi@complx.LF.net (Kurt Jaeger) X-NCC-RegID: de.lfnet --%--multipart-mixed-boundary-4.31517.949260351--% Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi! Maybe you remember the ETRN patch for 3.2.0.103 ? Here's the same patch, a little worked over and adapted to 3.2.0.109... Greetings, -- MfG/Best regards, Kurt Jaeger 20 years to go ! LF.net GmbH pi@LF.net Oberon.net GmbH pi@oberon.net Vor dem Lauch 23 fon +49 711 90074-23 Friedrich-Ebert-Str.1 +49 171 3101372 D-70567 Stuttgart fax +49 711 7289041 40210 Duesseldorf fon +49 211 179253-11 For Redmond: "nuke the site from orbit -- it's the only way to be sure." --%--multipart-mixed-boundary-4.31517.949260351--% Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Description: 'diff' output text Content-Disposition: attachment; filename="smail-3.2.0.109-etrn-patch" diff -r -c ./src/Makefile ../src-109/src/Makefile *** ./src/Makefile Sun Jan 30 19:58:32 2000 --- ../src-109/src/Makefile Thu Sep 16 22:03:46 1999 *************** *** 254,262 **** case "$$STRIP" in \ ?*) s_flag=-s;; \ esac; \ ! ${XEXEC} ${SHELL} ${INST} $$s_flag $$l_flag \ -d $$SMAIL_BIN_DIR \ ! smail ${BIN_NAMES} # XXX I'm not so sure the "touch" commands are safe with TEST_BASE but # then they don't really do anything but update the last modify time... --- 254,263 ---- case "$$STRIP" in \ ?*) s_flag=-s;; \ esac; \ ! ${XEXEC} ${SHELL} ${INST} $$s_flag $$l_flag -u root -m 4555 \ -d $$SMAIL_BIN_DIR \ ! smail ${BIN_NAMES} -k $$NEWALIASES \ ! $$OTHER_SMAIL_NAMES # XXX I'm not so sure the "touch" commands are safe with TEST_BASE but # then they don't really do anything but update the last modify time... *************** *** 266,272 **** case "$$DONT_INSTALL" in \ ?*) echo Testing ... install-libs ignored; exit 0;; \ esac; \ ! ${XEXEC} ${SHELL} ${INSTM} -r -m 0644 $$LIB_DIR ../COPYING; \ if [ "X$$PATH_FORCE_PATHS_FILE" != "X" -a ! -f "$$PATH_FORCE_PATHS_FILE" ] ; then \ echo "touch $$PATH_FORCE_PATHS_FILE"; \ touch $$PATH_FORCE_PATHS_FILE; \ --- 267,273 ---- case "$$DONT_INSTALL" in \ ?*) echo Testing ... install-libs ignored; exit 0;; \ esac; \ ! ${XEXEC} ${SHELL} ${INSTM} -r -m 0444 $$LIB_DIR ../COPYING; \ if [ "X$$PATH_FORCE_PATHS_FILE" != "X" -a ! -f "$$PATH_FORCE_PATHS_FILE" ] ; then \ echo "touch $$PATH_FORCE_PATHS_FILE"; \ touch $$PATH_FORCE_PATHS_FILE; \ diff -r -c ./src/config.c ../src-109/src/config.c *** ./src/config.c Sun Jan 30 19:57:24 2000 --- ../src-109/src/config.c Sun Sep 19 22:02:33 1999 *************** *** 103,110 **** int smtp_allow_expn = SMTP_ALLOW_EXPN; /* allow EXPN commanda in SMTP */ char *smtp_recipient_no_verify = SMTP_RECIPIENT_NO_VERIFY; /* ip list for not verifying RCPT TO */ char *smtp_remote_allow = SMTP_REMOTE_ALLOW; /* ip list that can send remote smtp */ - char *smtp_dynamic_remote_db = NULL; /* database file for dynamic ip database */ - int smtp_dynamic_remote_interval = 1800; /* time interval in seconds since pop access */ int smtp_hello_verify = SMTP_HELLO_VERIFY; /* verify HELO/EHLO host has A RR matching sockaddr */ char *smtp_hello_broken_allow = SMTP_HELLO_BROKEN_ALLOW; /* ip list that can avoid hello verification */ int smtp_hello_verify_literal = SMTP_HELLO_VERIFY_LITERAL; /* verify HELO/EHLO domain literal has PTR RR */ --- 103,108 ---- Binary files ./src/config.o and ../src-109/src/config.o differ Binary files ./src/default.o and ../src-109/src/default.o differ diff -r -c ./src/extern.h ../src-109/src/extern.h *** ./src/extern.h Sun Jan 30 19:57:24 2000 --- ../src-109/src/extern.h Sun Sep 19 23:40:15 1999 *************** *** 97,104 **** extern int smtp_allow_expn; /* allow EXPN command in SMTP */ extern char *smtp_recipient_no_verify; /* ip list for not verifying RCPT TO */ extern char *smtp_remote_allow; /* ip list that can send remote smtp */ - extern char *smtp_dynamic_remote_db; /* database file for dynamic ip database */ - extern int smtp_dynamic_remote_interval; /* time interval in seconds since pop access */ extern char *smtp_local_net; /* the local network calculated from src. addr */ extern int smtp_hello_verify; /* verify HELO/EHLO host has A RR matching sockaddr */ extern char *smtp_hello_broken_allow; /* ip list that can avoid hello verification */ --- 97,102 ---- *************** *** 247,255 **** /* external variables defined in smtprecv.c */ extern char *sender_host_really; /* result of PTR lookup */ - #ifdef SMTP_ETRN - extern char *etrn_host; /* requested ETRN delivery domain */ - #endif /* --- 245,250 ---- *************** *** 368,376 **** extern void deliver_mail(); extern void daemon_mode(); extern void noop_mode(); - #ifdef SMTP_ETRN - extern void etrn_mode(); - #endif extern void verify_addresses(); extern void print_version(); extern void print_copying_file(); --- 363,368 ---- diff -r -c ./src/ldinfo.c ../src-109/src/ldinfo.c *** ./src/ldinfo.c Sun Jan 30 20:20:03 2000 --- ../src-109/src/ldinfo.c Fri Jan 28 21:02:47 2000 *************** *** 4,8 **** * expand.c to define the values for $compile_num and $compile_date. * To reset the compilation count, simply remove ldinfo.c. */ ! int compile_num = 2; ! char *compile_date = "2000-Jan-30"; --- 4,8 ---- * expand.c to define the values for $compile_num and $compile_date. * To reset the compilation count, simply remove ldinfo.c. */ ! int compile_num = 1; ! char *compile_date = "2000-Jan-28"; Binary files ./src/ldinfo.o and ../src-109/src/ldinfo.o differ diff -r -c ./src/lookup.c ../src-109/src/lookup.c *** ./src/lookup.c Sun Jan 30 20:06:44 2000 --- ../src-109/src/lookup.c Fri Sep 3 23:37:42 1999 *************** *** 54,66 **** #include "lookup.h" /* XXX only really needed with LIBWHOSON for now */ #include "exitcodes.h" - #define DHAP - #ifdef DHAP - #include - #include - #include "log.h" - #endif - #ifdef HAVE_NIALIAS # include #endif --- 54,59 ---- *************** *** 1824,1837 **** /* * match_ip - match an ip against an allowed list * - * Step 1: * Takes a list of IP:IP:IP and compares against an IP string. Allows * "*" star type wildcards at the end of IPs. * - * Step 2: - * checks dynamically updated database of ip/timestamp pairs - * whether remote site had retrieved some mail recently. Then, pass it. - * * WARNING: cannot diddle with pattern -- may be read-only string. * * Returns 1 if matched, else 0. --- 1817,1825 ---- *************** *** 1843,1858 **** { char *pat_p, *end_p, wild = 0; int len; - - #ifdef DHAP - int res; /* result code */ - unsigned long addr; /* ip address to write to database */ - time_t oldsec,sec, *secp; /* timestamp to compare to database */ - int retval = 0; /* return code at the end */ - - DB *iptime = NULL; /* database to write to */ - DBT key, data; - #endif DHAP /* run through the pattern list */ for (pat_p = patterns; /* NOTEST */ ; pat_p = end_p + 1, wild = 0) { --- 1831,1836 ---- *************** *** 1935,2010 **** DEBUG2(DBG_ADDR_HI, "ip '%s' not verified by any pattern in '%s'\n", ip, patterns); ! ! #ifdef DHAP ! /* dynamic check */ ! if ( smtp_dynamic_remote_db == NULL ) { ! #endif ! return 0; ! #ifdef DHAP ! } ! ! sec = time(NULL); ! if ( sec == -1 ) { ! write_log(WRITE_LOG_SYS, "DHAP: can not get time: %d", ! smtp_dynamic_remote_db,strerror(errno)); ! } ! if ( (res = ! db_open(smtp_dynamic_remote_db, DB_HASH, DB_RDONLY, 0666, ! NULL, NULL, &iptime ) ! ) != 0 ) ! { ! write_log(WRITE_LOG_SYS, "DHAP: can not db_open dyn database %s: %d", smtp_dynamic_remote_db,strerror(res)); ! return(0); ! } ! ! /* fetch record */ ! memset(&key, 0, sizeof(key)); ! memset(&data, 0, sizeof(data)); ! addr = inet_addr(ip); ! key.data = &addr; ! key.size = sizeof(addr); ! data.data = ""; ! data.size = sizeof(""); ! ! res = iptime->get(iptime, NULL, &key, &data, 0); ! ! switch (res) { ! case 0: ! secp = data.data; ! oldsec = *secp; ! if ( oldsec < sec - smtp_dynamic_remote_interval ) { ! write_log(WRITE_LOG_SYS, "DHAP: remote ip %s tried to send after %d seconds, later than allowed %d seconds delay", ip, sec-oldsec, smtp_dynamic_remote_interval); ! retval=0; ! } ! else { ! write_log(WRITE_LOG_SYS, "DHAP: remote ip %s send allowed, auth %d seconds ago", ip, sec - oldsec); ! retval=1; ! } ! break; ! case DB_NOTFOUND: ! write_log(WRITE_LOG_SYS, "DHAP: remote ip %s not found in dynamic db", ip); ! retval=0; ! break; ! default: ! write_log(WRITE_LOG_SYS, "DHAP: db_get: %s", strerror(errno)); ! retval=0; ! break; ! } ! ! res = iptime->close(iptime, 0); ! if ( res != 0 ) { ! write_log(WRITE_LOG_SYS, "DHAP: can not db_close %s: %d", ! smtp_dynamic_remote_db,strerror(res)); ! } ! ! DEBUG1(DBG_ADDR_HI, "ip '%s' not dynamically verified\n", ip); ! ! return retval; ! #endif /* DHAP */ ! } ! #ifdef STANDALONE int debug = 0; --- 1913,1922 ---- DEBUG2(DBG_ADDR_HI, "ip '%s' not verified by any pattern in '%s'\n", ip, patterns); ! ! return 0; } ! #ifdef STANDALONE int debug = 0; *************** *** 2091,2094 **** } #endif /* STANDALONE */ - --- 2003,2005 ---- Binary files ./src/lookup.o and ../src-109/src/lookup.o differ diff -r -c ./src/modes.c ../src-109/src/modes.c *** ./src/modes.c Sun Jan 30 19:57:25 2000 --- ../src-109/src/modes.c Wed Oct 27 22:00:37 1999 *************** *** 19,25 **** * input_signals, processing_signals, * delivery_signals, test_addresses, * perform_deliver_mail, deliver_mail, ! * daemon_mode, noop_mode, etrn_mode, verify_addresses, * print_version, print_copying_file, * print_variables, print_queue, smtp_mode, * fork_wait --- 19,25 ---- * input_signals, processing_signals, * delivery_signals, test_addresses, * perform_deliver_mail, deliver_mail, ! * daemon_mode, noop_mode, verify_addresses, * print_version, print_copying_file, * print_variables, print_queue, smtp_mode, * fork_wait *************** *** 1510,1553 **** } } } - - #ifdef SMTP_ETRN - /* - * etrn_mode - perform queue runs once in the background - * - * When the -q flag is specified, or smail is invoked as runq, but -bd - * is not specified, then noop_mode() is invoked, which does nothing but - * execute run_queue() in background at intervals. If no sleep interval - * is specified, run_queue() is called only once. - */ - void - etrn_mode() - { - X_PANIC_OKAY(); - - /* arrange signals */ - got_sighup = FALSE; - got_sigalrm = FALSE; - #ifdef SIGCHLD - /* NOTE: If there is no SIGCHLD we can't reap dead kids! lose */ - (void) signal(SIGCHLD, daemon_sigchld); - #endif - (void) signal(SIGHUP, daemon_sighup); - (void) signal(SIGALRM, daemon_sigalrm); - - /* - * we aren't interested in the old stdin or stdout, substitute - * /dev/null - */ - (void) close(0); - (void) close(1); - open("/dev/null", 0); - dup(0); - - bg_run_queue(-1); - - } - #endif /* * start_daemon - start a daemon smail process for noop_mode() or --- 1510,1515 ---- Binary files ./src/modes.o and ../src-109/src/modes.o differ diff -r -c ./src/retry.c ../src-109/src/retry.c *** ./src/retry.c Sun Jan 30 19:57:25 2000 --- ../src-109/src/retry.c Tue Oct 19 00:24:29 1999 *************** *** 566,577 **** /* notice if it's too soon to try delivery */ ret = allow_now(fd, tryname, spooled, started, r, error) ? SUCCEED : FAIL; - #ifdef SMTP_ETRN - if ( etrn_host != NULL && EQIC(etrn_host, host) ) { - ret = SUCCEED; - } - #endif - /* we can defer if further retries would be soon enough */ dfok = allow_later(spooled, started, r, error); --- 566,571 ---- Binary files ./src/retry.o and ../src-109/src/retry.o differ Binary files ./src/smail and ../src-109/src/smail differ diff -r -c ./src/smailconf.c ../src-109/src/smailconf.c *** ./src/smailconf.c Sun Jan 30 19:57:25 2000 --- ../src-109/src/smailconf.c Sun Sep 19 22:02:33 1999 *************** *** 145,153 **** (tup *)&smtp_receive_message_timeout, 0 }, { "smtp_recipient_no_verify", t_string, NULL, (tup *)&smtp_recipient_no_verify, 0 }, { "smtp_remote_allow", t_string, NULL, (tup *)&smtp_remote_allow, 0 }, - { "smtp_dynamic_remote_db", t_string, NULL, (tup *)&smtp_dynamic_remote_db, 0 }, - { "smtp_dynamic_remote_interval", t_interval, NULL, - (tup *)&smtp_dynamic_remote_interval, 0 }, { "smtp_hello_verify", t_boolean, NULL, (tup *)&smtp_hello_verify, 0 }, { "smtp_hello_broken_allow", t_string, NULL, (tup *)&smtp_hello_broken_allow, 0 }, { "smtp_hello_verify_literal", t_boolean, NULL, (tup *)&smtp_hello_verify_literal, 0 }, --- 145,150 ---- Binary files ./src/smailconf.o and ../src-109/src/smailconf.o differ diff -r -c ./src/smtprecv.c ../src-109/src/smtprecv.c *** ./src/smtprecv.c Sun Jan 30 20:19:57 2000 --- ../src-109/src/smtprecv.c Wed Oct 27 22:00:38 1999 *************** *** 95,103 **** enum e_smtp_commands { HELO_CMD, /* HELO domain */ EHLO_CMD, /* EHLO domain */ - #ifdef SMTP_ETRN - ETRN_CMD, /* ETRN domain */ - #endif MAIL_CMD, /* MAIL FROM: */ RCPT_CMD, /* RCPT TO: */ DATA_CMD, /* DATA */ --- 95,100 ---- *************** *** 172,180 **** "250-2.0.0", "250-2.0.0 HELO hostname - startup and give your hostname", "250-2.0.0 EHLO hostname - startup with extension info", - #ifdef SMTP_ETRN - "250-2.0.0 ETRN domain - start queue processing for this mailserver", - #endif "250-2.0.0 MAIL FROM: - start transaction from sender", "250-2.0.0 RCPT TO: - name recipient for message", #ifdef NO_SMTP_VRFY --- 169,174 ---- *************** *** 200,208 **** }; char *sender_host_really = NULL; /* result of PTR lookup */ - #ifdef SMTP_ETRN - char *etrn_host = NULL; /* requested ETRN delivery domain */ - #endif int num_smtp_recipients = 0; /* number of recipient addresses */ --- 194,199 ---- *************** *** 238,244 **** int ehlo_p = 0; /* using ESMTP? */ int c; char *p; /* just a pointer */ - int fatal; /* error code for fatal errors */ /* save important state to restore after initialize_state() */ enum er_proc save_error_proc = error_processing; int save_do_aliasing = do_aliasing; --- 229,234 ---- *************** *** 567,572 **** --- 557,563 ---- } if (out) { #ifdef HAVE_BSD_NETWORKING + int fatal; if (sender_host_addr && !shp) { /* we've been around once before and need to reset shp & sender_host_really */ *************** *** 674,682 **** #ifdef HAVE_ESMTP_PIPELINING /* defined in iobpeek.h if support is possible */ fprintf(out, "250-PIPELINING\r\n"); #endif - #ifdef SMTP_ETRN - fprintf(out, "250-ETRN\r\n"); - #endif #ifndef NO_SMTP_EXPN fprintf(out, "250-EXPN\r\n"); #endif --- 665,670 ---- *************** *** 687,811 **** reset_state(); /* HELO implies RSET */ break; - #ifdef SMTP_ETRN - case ETRN_CMD: - /* only if EHLO was used */ - /* done-pi-19990210: skip this test - if ( ! ehlo_p ) { - if ( out ) { - fprintf(out, "501 no EHLO given\r\n"); - fflush(out); - } - break; - } */ - orig_data = COPY_STRING(data); - strip_rfc822_comments(data); /* XXX not required by RFC 821 */ - if (out) { - if (!data[0]) { - fprintf(out, "501 ETRN requires a domain literal as operand\r\n"); - fflush(out); - break; - } - } - if (sender_host) { - xfree(sender_host); - sender_host = NULL; - } - if (out) { - #ifdef HAVE_BSD_NETWORKING - const char *error = NULL; - - if (sender_host_addr && !shp) { - /* we've been around once before and need to reset... */ - if (!(shp = gethostbyaddr((char *) &(from_sa.sin_addr), - sizeof(from_sa.sin_addr), AF_INET))) { - DEBUG2(DBG_REMOTE_LO, "gethostbyaddr(%s) failed: %s.\n", sender_host_addr, hstrerror(h_errno)); - sender_host_really = NULL; - } else { - sender_host_really = COPY_STRING(shp->h_name); - } - } - if (! (sender_host = verify_host(data, &from_sa, shp, shp ? NULL : hstrerror(h_errno), h_errno, &errstr, &fatal))) { - /* XXX how many MTAs will break if this is multi-lined??? */ - fprintf(out, "501 ETRN requires a valid host name as operand: '%s' rejected from %s%s%s%s%s%s%s%s.\r\n", - data, - ident_sender ? ident_sender : "", - ident_sender ? "@" : "", - sender_host_really ? sender_host_really : "", - sender_host_addr ? " remote address [" : "", - sender_host_addr ? sender_host_addr : "", - sender_host_addr ? "]" : "", - error ? ": " : "", error ? error : ""); - fflush(out); - } - if (!sender_host || error) { /* log even "hidden" errors as warnings */ - write_log(WRITE_LOG_SYS, "remote ETRN: %s operand: '%s': from %s%s%s%s%s%s%s%s%s%s%s.", - sender_host ? "questionable" : "invalid", - orig_data, - ident_sender ? ident_sender : "", - ident_sender ? "@" : "", - sender_host ? sender_host : "", - sender_host_really ? "(" : "", - sender_host_really ? sender_host_really : "", - sender_host_really ? ")" : "", - sender_host_addr ? " source [" : "", - sender_host_addr ? sender_host_addr : "", - sender_host_addr ? "]" : "", - error ? ": " : "", - error ? error : ""); - } - shp = NULL; /* make sure are reset if needed again */ - if (!sender_host) { - break; /* broken DNS or forger */ - } - #else - DEBUG1(DBG_REMOTE_LO, "receive_smtp(): no BSD networking, so not verifying sender host %s.\n", data); - #endif /* HAVE_BSD_NETWORKING */ - } else if (!sender_host && data[0] != '\0') { - sender_host = COPY_STRING(data); - } - /* data als etrn_host wegspeichern und dann bg_run_queue starten */ - /* In transports/tcpsmtp.c:tcpsmtp_internal wird das wieder abgefragt */ - etrn_host = COPY_STRING(data); - write_log(WRITE_LOG_SYS, "ETRN requested for '%s' from %s%s%s%s%s%s%s%s%s%s.", - etrn_host, - sender_host ? "questionable " : "invalid ", - ident_sender ? ident_sender : "", - ident_sender ? "@" : "", - sender_host ? sender_host : "", - sender_host_really ? "(" : "", - sender_host_really ? sender_host_really : "", - sender_host_really ? ")" : "", - sender_host_addr ? " source [" : "", - sender_host_addr ? sender_host_addr : "", - sender_host_addr ? "]" : "", - errstr ? ": " : "", - errstr ? errstr : ""); - - /* TODO-pi: Hier irgendwann auswertung einer magischen Tabelle */ - - etrn_mode(); - - /* if everything worked out, wonderful */ - if (out) { - /* XXX RFC 0821 says "The receiver-SMTP identifies itself to - * the sender-SMTP in [...] the response to this command - * [HELO]." - */ - fprintf(out, "250 %s queuing for %s (%s%s%s%s%s%s) started\r\n", - primary_name, data, - ident_sender ? ident_sender : "", - ident_sender ? "@" : "", - sender_host_really ? sender_host_really : (sender_host ? sender_host : "(UNKNOWN)"), - sender_host_addr ? " from address [" : "", - sender_host_addr ? sender_host_addr : "", - sender_host_addr ? "]" : "" ); - (void) fflush(out); - } - reset_state(); - break; - #endif - case MAIL_CMD: #ifdef HAVE_LIBWRAP if (smtp_session_denied) { --- 675,680 ---- *************** *** 1427,1435 **** } smtp_cmd_list[] = { { "HELO", HELO_CMD }, { "EHLO", EHLO_CMD }, - #ifdef SMTP_ETRN - { "ETRN", ETRN_CMD }, - #endif { "MAIL FROM:", MAIL_CMD }, { "RCPT TO:", RCPT_CMD }, { "DATA", DATA_CMD }, --- 1296,1301 ---- Binary files ./src/smtprecv.o and ../src-109/src/smtprecv.o differ diff -r -c ./src/transports/tcpsmtp.c ../src-109/src/transports/tcpsmtp.c *** ./src/transports/tcpsmtp.c Sun Jan 30 19:57:25 2000 --- ../src-109/src/transports/tcpsmtp.c Wed Oct 27 20:13:17 1999 *************** *** 351,367 **** priv = (struct tcpsmtp_private *)tp->private; - #ifdef SMTP_ETRN - if ( etrn_host != NULL ) { - DEBUG2(DBG_DRIVER_LO, "etrn: %s hostn: %s\n",etrn_host,hostname); - } - - /* Vergleich auf ETRN data, ggf. SMTP_AGAIN */ - if ( etrn_host != NULL && !EQIC(etrn_host, hostname) ) { - return SMTP_AGAIN; - } - #endif - DEBUG4(DBG_DRIVER_LO, "transport %s: connect to host %s [%s]/%s...", addr->transport->name, hostname, inet_ntoa(*ipaddr), service); --- 351,356 ---- Binary files ./src/transports/tcpsmtp.o and ../src-109/src/transports/tcpsmtp.o differ Binary files ./src/transports/tdrivlib.a and ../src-109/src/transports/tdrivlib.a differ --%--multipart-mixed-boundary-4.31517.949260351--%--