{
    use esmith::AccountsDB;

    $OUT = '';

    # Generate qmail user assignments for mailing lists. These will be handled
    # by ~ezmlm/.qmail-listname and ~ezmlm/.qmail-listname-ext.

    my $adb = esmith::AccountsDB->open_ro;

    setpwent;
    my (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef)
	= getpwnam("ezmlm");

    # It is almost impossible to get Text::Template to output nothing
    # on failure. It can be done by removing the newline at the end of
    # this file but that is messy. Therefore, we'll simply return an
    # error message that will make qmail-newu fail. Also send a
    # warning message that will be captured in the logs.

    unless (defined $uid && defined $gid && defined $dir)
    {
	my $msg =
	    "Failed to obtain user details for \'ezmlm\' "
	    . "while processing group assignments.";

	warn "$msg\n";
	$OUT = $msg;
	return;
    }

    my $ezmlm_assign = "ezmlm:${uid}:${gid}:${dir}";

    foreach my $list ($adb->get_all_by_prop(type => "mailinglist"))
    {
	my $listname = $list->key;

	# Assign mail for listname@
	$OUT .= "=${listname}:${ezmlm_assign}:-:${listname}:\n";

	# Assign mail for listname-ext@
	$OUT .= "+${listname}-:${ezmlm_assign}:-${listname}-::\n";
    }
}
