1 /* $NetBSD: int_filt.c,v 1.2 2017/02/14 01:16:45 christos Exp $ */ 2 3 /*++ 4 /* NAME 5 /* int_filt 3 6 /* SUMMARY 7 /* internal mail filter control 8 /* SYNOPSIS 9 /* #include <int_filt.h> 10 /* 11 /* int int_filt_flags(class) 12 /* int class; 13 /* DESCRIPTION 14 /* int_filt_flags() determines the appropriate mail filtering 15 /* flags for the cleanup server, depending on the setting of 16 /* the internal_mail_filter_classes configuration parameter. 17 /* 18 /* Specify one of the following: 19 /* .IP MAIL_SRC_MASK_NOTIFY 20 /* Postmaster notifications from the smtpd(8) and smtp(8) 21 /* protocol adapters. 22 /* .IP MAIL_SRC_MASK_BOUNCE 23 /* Delivery status notifications from the bounce(8) server. 24 /* .PP 25 /* Other MAIL_SRC_MASK_XXX arguments are permited but will 26 /* have no effect. 27 /* DIAGNOSTICS 28 /* Fatal: invalid mail category name. 29 /* LICENSE 30 /* .ad 31 /* .fi 32 /* The Secure Mailer license must be distributed with this software. 33 /* AUTHOR(S) 34 /* Wietse Venema 35 /* IBM T.J. Watson Research 36 /* P.O. Box 704 37 /* Yorktown Heights, NY 10598, USA 38 /*--*/ 39 40 /* System library. */ 41 42 #include <sys_defs.h> 43 44 /* Utility library. */ 45 46 #include <name_mask.h> 47 #include <msg.h> 48 49 /* Global library. */ 50 51 #include <mail_params.h> 52 #include <cleanup_user.h> 53 #include <mail_proto.h> 54 #include <int_filt.h> 55 56 /* int_filt_flags - map mail class to submission flags */ 57 58 int int_filt_flags(int class) 59 { 60 static const NAME_MASK table[] = { 61 MAIL_SRC_NAME_NOTIFY, MAIL_SRC_MASK_NOTIFY, 62 MAIL_SRC_NAME_BOUNCE, MAIL_SRC_MASK_BOUNCE, 63 MAIL_SRC_NAME_SENDMAIL, 0, 64 MAIL_SRC_NAME_SMTPD, 0, 65 MAIL_SRC_NAME_QMQPD, 0, 66 MAIL_SRC_NAME_FORWARD, 0, 67 MAIL_SRC_NAME_VERIFY, 0, 68 0, 69 }; 70 int filtered_classes = 0; 71 72 if (class && *var_int_filt_classes) { 73 filtered_classes = 74 name_mask(VAR_INT_FILT_CLASSES, table, var_int_filt_classes); 75 if (filtered_classes == 0) 76 msg_warn("%s: bad input: %s", VAR_INT_FILT_CLASSES, 77 var_int_filt_classes); 78 if (filtered_classes & class) 79 return (CLEANUP_FLAG_FILTER | CLEANUP_FLAG_MILTER); 80 } 81 return (0); 82 } 83