summaryrefslogtreecommitdiffstats
path: root/src/global/int_filt.c
blob: 7c5f8b51f7b7aebd6f5a2a08ca5d5b0b0fbc96f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*++
/* NAME
/*	int_filt 3
/* SUMMARY
/*	internal mail filter control
/* SYNOPSIS
/*	#include <int_filt.h>
/*
/*	int	int_filt_flags(class)
/*	int	class;
/* DESCRIPTION
/*	int_filt_flags() determines the appropriate mail filtering
/*	flags for the cleanup server, depending on the setting of
/*	the internal_mail_filter_classes configuration parameter.
/*
/*	Specify one of the following:
/* .IP MAIL_SRC_MASK_NOTIFY
/*	Postmaster notifications from the smtpd(8) and smtp(8)
/*	protocol adapters.
/* .IP MAIL_SRC_MASK_BOUNCE
/*	Delivery status notifications from the bounce(8) server.
/* .PP
/*	Other MAIL_SRC_MASK_XXX arguments are permited but will
/*	have no effect.
/* DIAGNOSTICS
/*	Fatal: invalid mail category name.
/* LICENSE
/* .ad
/* .fi
/*	The Secure Mailer license must be distributed with this software.
/* AUTHOR(S)
/*	Wietse Venema
/*	IBM T.J. Watson Research
/*	P.O. Box 704
/*	Yorktown Heights, NY 10598, USA
/*--*/

/* System library. */

#include <sys_defs.h>

/* Utility library. */

#include <name_mask.h>
#include <msg.h>

/* Global library. */

#include <mail_params.h>
#include <cleanup_user.h>
#include <mail_proto.h>
#include <int_filt.h>

/* int_filt_flags - map mail class to submission flags */

int     int_filt_flags(int class)
{
    static const NAME_MASK table[] = {
	MAIL_SRC_NAME_NOTIFY, MAIL_SRC_MASK_NOTIFY,
	MAIL_SRC_NAME_BOUNCE, MAIL_SRC_MASK_BOUNCE,
	MAIL_SRC_NAME_SENDMAIL, 0,
	MAIL_SRC_NAME_SMTPD, 0,
	MAIL_SRC_NAME_QMQPD, 0,
	MAIL_SRC_NAME_FORWARD, 0,
	MAIL_SRC_NAME_VERIFY, 0,
	0,
    };
    int     filtered_classes = 0;

    if (class && *var_int_filt_classes) {
	filtered_classes =
	    name_mask(VAR_INT_FILT_CLASSES, table, var_int_filt_classes);
	if (filtered_classes == 0)
	    msg_warn("%s: bad input: %s", VAR_INT_FILT_CLASSES,
		     var_int_filt_classes);
	if (filtered_classes & class)
	    return (CLEANUP_FLAG_FILTER | CLEANUP_FLAG_MILTER);
    }
    return (0);
}