#!/usr/bin/perl
#
# subscreen - perl script called by SmartList to determine if an
#	      email address should be allowed to subscribe.
#             This version allows those from our local domain.
#
# Usage: (by SmartList)
#   subscreen email-address
# Returns exit code 0 if the address is ok, 1 if not.
#

$address = $ARGV[0];
exit 1 unless $address;

# Set $nameprog to the full path to your "hostname" program.
# If you don't have one, read on.
$nameprog='/bin/hostname';

# What's my local domain? If the "hostname" command on your system
# doesn't return your fully-qualified host name, uncomment the line
# below and set it to your local domain name.
#$domain='berkeley.edu';

unless ($domain) {
  $domain = `$nameprog`;
  $domain =~ s/^.*([^\.]+\.[^\.]+)$/$1/;
}

exit ($address !~ /$domain$/ ? 1 : 0);
