$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.
Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Initial CVS import
-
/*
* 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; i<config_lines; ++i) {
extract_token(buf, inetcfg, i, '\n');
extract_token(host, buf, 0, '|');
extract_token(type, buf, 1, '|');
+
if ( (!strcasecmp(type, "localhost"))
- && (!strcasecmp(fqdn, host))) return(1);
+ && (!strcasecmp(fqdn, host)))
+ return(hostalias_localhost);
+
+ if ( (!strcasecmp(type, "gatewaydomain"))
+ && (!strcasecmp(&fqdn[strlen(fqdn)-strlen(host)], host)))
+ return(hostalias_gatewaydomain);
+
}
- return(0);
+ return(hostalias_nomatch);
}
/*
* Return 0 if a given string fuzzy-matches a Citadel user account
*
- * FIX ... this needs to be updated to match any and all address syntaxes.
+ * FIX ... this needs to be updated to handle aliases.
*/
int fuzzy_match(struct usersupp *us, char *matchstring) {
int a;
+ if ( (!strncasecmp(matchstring, "cit", 3))
+ && (atol(&matchstring[3]) == us->usernum)) {
+ return 0;
+ }
+
+
for (a=0; a<strlen(us->fullname); ++a) {
if (!strncasecmp(&us->fullname[a],
matchstring, strlen(matchstring))) {
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
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;
/*
- * 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 */
ma->did_print = 1;
- if (!strcasecmp(cbtype, "text/plain")) {
+ if ( (!strcasecmp(cbtype, "text/plain"))
+ || (strlen(cbtype)==0) ) {
wlen = length;
wptr = content;
while (wlen--) {
/* END NESTED FUNCTION fixed_output() */
+ lprintf(7, "CtdlOutputMsg() msgnum=%ld, mode=%d\n",
+ msg_num, mode);
TheMessage = NULL;
sprintf(mid, "%ld", msg_num);
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);
}
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) {
/* 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);
}
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];
*/
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");
}
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;
}
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);