diff -dru qmail-1.03/qmail-remote.c qmail-1.03-fjo/qmail-remote.c --- qmail-1.03/qmail-remote.c Mon Jun 15 12:53:16 1998 +++ qmail-1.03-fjo/qmail-remote.c Sun Jul 6 00:46:58 2003 @@ -41,6 +41,10 @@ stralloc helohost = {0}; stralloc routes = {0}; struct constmap maproutes; +stralloc remoteauth = {0}; +struct constmap mapremoteauth; +char *envfrom = 0; +char *remotepass = 0; stralloc host = {0}; stralloc sender = {0}; @@ -230,8 +234,19 @@ substdio_flush(&smtpto); if (smtpcode() != 250) quit("ZConnected to "," but my name was rejected"); + if (remotepass) { + substdio_puts(&smtpto, "AUTH "); + substdio_puts(&smtpto, remotepass); + substdio_puts(&smtpto,"\r\n"); + substdio_flush(&smtpto); + if (smtpcode() != 235) quit("ZConnected to "," but auth failed"); + } + substdio_puts(&smtpto,"MAIL FROM:<"); - substdio_put(&smtpto,sender.s,sender.len); + + if (envfrom) substdio_puts(&smtpto, envfrom); + else substdio_put(&smtpto,sender.s,sender.len); + substdio_puts(&smtpto,">\r\n"); substdio_flush(&smtpto); code = smtpcode(); @@ -324,6 +339,16 @@ case 1: if (!constmap_init(&maproutes,routes.s,routes.len,1)) temp_nomem(); break; } + switch(control_readfile(&remoteauth,"control/remoteauth",0)) { + case -1: + temp_control(); + case 0: + if (!constmap_init(&mapremoteauth,"",0,1)) temp_nomem(); break; + case 1: + if (!constmap_init(&mapremoteauth,remoteauth.s,remoteauth.len,1)) + temp_nomem(); + break; + } } void main(argc,argv) @@ -363,6 +388,14 @@ if (!stralloc_copys(&host,relayhost)) temp_nomem(); } + envfrom = constmap(&mapremoteauth, host.s, host.len); + if (envfrom) { + i = str_chr(envfrom, ':'); + if (envfrom[i]) { + remotepass = &envfrom[i+1]; + envfrom[i] = 0; + } + } addrmangle(&sender,argv[2],&flagalias,0);