From c04e92eb8bcd99f16a908e48e8bee1673488ccf8 Mon Sep 17 00:00:00 2001 From: Bruce Guenter Date: Tue, 9 Oct 2007 12:13:22 -0600 Subject: Do not canonicalize *@localhost addresses. --- NEWS | 3 +++ doc/nullmailer-inject.1 | 4 +++- lib/canonicalize.cc | 4 ++-- test/tests/inject/from | 4 ++++ test/tests/inject/sender | 4 ++++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index f5c9027..9f379b0 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ This file lists all the major user-visible changes to nullmailer. ------------------------------------------------------------------------------- Changes in version 1.04 +- Fixed rewriting mail to @localhost if defaultdomain is set by not + appending .defaultdomain to *@localhost. + - Added support for reporting the sender and recipients in mailq. - Added a send timeout in nullmailer-send, to kill sending messages that diff --git a/doc/nullmailer-inject.1 b/doc/nullmailer-inject.1 index f990d43..58c7fcd 100644 --- a/doc/nullmailer-inject.1 +++ b/doc/nullmailer-inject.1 @@ -220,7 +220,9 @@ of all leading and trailing whitespace characters. .TP .B defaultdomain The content of this file is appended to any host name that does not -contain a period, including +contain a period (except +.IR localhost ), +including .BR defaulthost and .BR idhost . diff --git a/lib/canonicalize.cc b/lib/canonicalize.cc index c70509b..b8f0e91 100644 --- a/lib/canonicalize.cc +++ b/lib/canonicalize.cc @@ -1,5 +1,5 @@ // nullmailer -- a simple relay-only MTA -// Copyright (C) 1999-2003 Bruce Guenter +// Copyright (C) 2007 Bruce Guenter // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ void canonicalize(mystring& domain) { if(!domain) domain = defaulthost; - if(domain.find_first('.') < 0) { + if(domain != "localhost" && domain.find_first('.') < 0) { if(!!defaultdomain) { if (!!domain) domain += "."; domain += defaultdomain; diff --git a/test/tests/inject/from b/test/tests/inject/from index fac0a7f..001b185 100644 --- a/test/tests/inject/from +++ b/test/tests/inject/from @@ -35,6 +35,10 @@ echo test >$SYSCONFDIR/defaulthost echo domain.org >$SYSCONFDIR/defaultdomain inj | grep -q '@test.domain.org>$' +echo "Checking that inject ignores config/defaultdomain for localhost" +echo localhost >$SYSCONFDIR/defaulthost +inj | grep -q '@localhost>$' + testvar HOSTNAME test1.org '@test1.org>$' testvar MAILHOST test2.org '@test2.org>$' diff --git a/test/tests/inject/sender b/test/tests/inject/sender index 20325d9..07da970 100644 --- a/test/tests/inject/sender +++ b/test/tests/inject/sender @@ -34,6 +34,10 @@ echo test >$SYSCONFDIR/defaulthost echo domain.org >$SYSCONFDIR/defaultdomain inj | grep -q '@test.domain.org$' +echo "Checking that inject ignores config/defaultdomain for localhost" +echo localhost >$SYSCONFDIR/defaulthost +inj | grep -q '@localhost$' + testvar HOSTNAME test1.org '@test1.org$' testcanon HOSTNAME test1 '@test1.domain.org$' -- cgit v1.2.3