# $DUH: helo_unqualified,v 1.7 2002/12/16 05:14:33 tv Exp $
#
# Copyright (c) 2002 Todd Vierling <tv@pobox.com> <tv@duh.org>.
# All rights reserved.
# Please see the COPYRIGHT file, part of the PMilter distribution,
# for full copyright and license terms.

##### helo_unqualified #####
#
# Rejects HELO commands of an unqualified, non-IP-literal name.
# In short, rejects any domain name without a dot (.).

my $errmsg = shift_errmsg(@_, 'Domain "%1" is not fully qualified');

+{
	helo => sub {
		my $ctx = shift;
		my $helo = shift;

		if (($helo !~ /\./) && ($helo !~ /^\[.*\]$/)) {
			my $err = $errmsg;
			$err =~ s/%1/$helo/g; # interpolate HELO arg

			return $ctx->reject("554 HELO/EHLO command rejected: $err");
		}

		return SMFIS_ACCEPT;
	}
};
