From ca624125bb93500dbc777dc57796f5ab8e906dd8 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 7 Feb 2000 05:15:01 +0000 Subject: [PATCH] * Renamed CtdlLocalHost() to CtdlHostAlias() and worked it a little deeper into the message routing logic. Still needs some work on the gateway-domain stuff. * Twiddled CtdlOutputMsg() a bit for 'all Internet' situations. Still needs some work to avoid printing dual headers when both Cit and RFC822 exist. --- citadel/ChangeLog | 8 ++++++- citadel/internet_addressing.c | 39 +++++++++++++++++++++++++++-------- citadel/internet_addressing.h | 12 ++++++++++- citadel/msgbase.c | 25 ++++++++++++++++++---- citadel/serv_smtp.c | 10 ++++++--- 5 files changed, 76 insertions(+), 18 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 27fcd2024..03de74fef 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,11 @@ $Log$ +Revision 1.456 2000/02/07 05:15:00 ajc +* Renamed CtdlLocalHost() to CtdlHostAlias() and worked it a little deeper into + the message routing logic. Still needs some work on the gateway-domain + stuff. +* Twiddled CtdlOutputMsg() a bit for 'all Internet' situations. Still needs + some work to avoid printing dual headers when both Cit and RFC822 exist. + Revision 1.455 2000/02/03 03:57:35 ajc * Formalized the 'Internet Configuration' logistics. Added new API call CtdlLocalHost() to detect aliases for the local host. Used in SMTP listener. @@ -1600,4 +1607,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index 16e242333..ed19a0cc0 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -45,25 +45,32 @@ char *inetcfg = NULL; /* * Return nonzero if the supplied name is an alias for this host. */ -int CtdlLocalHost(char *fqdn) { +int CtdlHostAlias(char *fqdn) { int config_lines; int i; char buf[256]; char host[256], type[256]; - if (!strcasecmp(fqdn, config.c_fqdn)) return(1); - if (inetcfg == NULL) return(0); + if (!strcasecmp(fqdn, config.c_fqdn)) return(hostalias_localhost); + if (inetcfg == NULL) return(hostalias_nomatch); config_lines = num_tokens(inetcfg, '\n'); for (i=0; iusernum)) { + return 0; + } + + for (a=0; afullname); ++a) { if (!strncasecmp(&us->fullname[a], matchstring, strlen(matchstring))) { @@ -283,16 +296,24 @@ int convert_internet_address(char *destuser, char *desthost, char *source) char name[256]; struct quickroom qrbuf; int i; + int hostalias; struct trynamebuf tnb; + char buf[256]; /* Split it up */ process_rfc822_addr(source, user, node, name); /* Map the FQDN to a Citadel node name - * FIX ... we have to check for gateway domains */ - if (CtdlLocalHost(node)) { - strcpy(node, config.c_nodename); + hostalias = CtdlHostAlias(node); + switch(hostalias) { + case hostalias_localhost: + strcpy(node, config.c_nodename); + break; + + case hostalias_gatewaydomain: + extract_token(buf, node, 0, '.'); + safestrncpy(node, buf, sizeof buf); } /* Now try to resolve the name diff --git a/citadel/internet_addressing.h b/citadel/internet_addressing.h index 86aa0d019..7f08de119 100644 --- a/citadel/internet_addressing.h +++ b/citadel/internet_addressing.h @@ -13,6 +13,16 @@ enum { struct CtdlMessage *convert_internet_message(char *rfc822); -int CtdlLocalHost(char *fqdn); + +int CtdlHostAlias(char *fqdn); + +/* + * Values that can be returned by CtdlHostAlias() + */ +enum { + hostalias_nomatch, + hostalias_localhost, + hostalias_gatewaydomain +}; extern char *inetcfg; diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 867ff964a..47664be6d 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -680,7 +680,7 @@ void CtdlFreeMessage(struct CtdlMessage *msg) /* - * Get a message off disk. (return value is the message's timestamp) + * Get a message off disk. (returns om_* values found in msgbase.h) * */ int CtdlOutputMsg(long msg_num, /* message number (local) to fetch */ @@ -821,7 +821,8 @@ FMTEND: omprintf("%s%s", aaa, nl); ma->did_print = 1; - if (!strcasecmp(cbtype, "text/plain")) { + if ( (!strcasecmp(cbtype, "text/plain")) + || (strlen(cbtype)==0) ) { wlen = length; wptr = content; while (wlen--) { @@ -849,6 +850,8 @@ FMTEND: omprintf("%s%s", aaa, nl); /* END NESTED FUNCTION fixed_output() */ + lprintf(7, "CtdlOutputMsg() msgnum=%ld, mode=%d\n", + msg_num, mode); TheMessage = NULL; sprintf(mid, "%ld", msg_num); @@ -1034,7 +1037,7 @@ FMTEND: omprintf("%s%s", aaa, nl); mptr = TheMessage->cm_fields['M']; /* Tell the client about the MIME parts in this message */ - if (TheMessage->cm_format_type == FMT_RFC822) { /* legacy text dump */ + if (TheMessage->cm_format_type == FMT_RFC822) { if (mode == MT_CITADEL) { mime_parser(mptr, NULL, *list_this_part); } @@ -1044,6 +1047,21 @@ FMTEND: omprintf("%s%s", aaa, nl); CtdlFreeMessage(TheMessage); return(om_ok); } + else if (mode == MT_RFC822) { /* unparsed RFC822 dump */ + /* FIX ... we have to put some code in here to avoid + * printing duplicate header information when both + * Citadel and RFC822 headers exist. Preference should + * probably be given to the RFC822 headers. + */ + while (ch=*(mptr++), ch!=0) { + if (ch==13) ; + else if (ch==10) omprintf("%s", nl); + else omprintf("%c", ch); + } + if (do_proto) cprintf("000\n"); + CtdlFreeMessage(TheMessage); + return(om_ok); + } } if (headers_only) { @@ -1055,7 +1073,6 @@ FMTEND: omprintf("%s%s", aaa, nl); /* signify start of msg text */ if (mode == MT_CITADEL) if (do_proto) cprintf("text\n"); - /* if ((mode == MT_RFC822) && (TheMessage->cm_format_type != FMT_RFC822)) { */ if (mode == MT_RFC822) { omprintf("%s", nl); } diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index 287a993bf..b90f7f45f 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -35,6 +35,7 @@ struct citsmtp { /* Information about the current session */ int command_state; + char helo_node[256]; struct usersupp vrfy_buffer; int vrfy_count; char vrfy_match[256]; @@ -91,6 +92,8 @@ void smtp_greeting(void) { */ void smtp_hello(char *argbuf, int is_esmtp) { + safestrncpy(SMTP->helo_node, argbuf, sizeof SMTP->helo_node); + if (!is_esmtp) { cprintf("250 Greetings and joyous salutations.\r\n"); } @@ -328,9 +331,9 @@ void smtp_mail(char *argbuf) { else { cvt = convert_internet_address(user, node, SMTP->from); lprintf(9, "cvt=%d, citaddr=<%s@%s>\n", cvt, user, node); - if (!strcasecmp(node, config.c_nodename)) { /* FIX use fcn */ + if (CtdlHostAlias(node) == hostalias_localhost) { cprintf("550 You must log in to send mail from %s\r\n", - config.c_fqdn); + node); strcpy(SMTP->from, ""); return; } @@ -541,11 +544,12 @@ void smtp_data(void) { generate_rfc822_datestamp(nowstamp, time(NULL)); body = mallok(4096); + if (body != NULL) sprintf(body, "Received: from %s\n" " by %s;\n" " %s\n", - "FIX.FIX.com", + SMTP->helo_node, config.c_fqdn, nowstamp); -- 2.30.2