#include "mfapi.h" /* Milter-API */ #include /* for fprintf */ #include /* for getopt */ /* Cleanup function */ extern sfsistat mlfi_cleanup(SMFICTX *, sfsistat); /* End of message callback */ sfsistat mlfi_eom(SMFICTX *ctx) { /* Remove Header, ignore any errors */ smfi_chgheader(ctx, "Disposition-Notification-To", 1, NULL); /* Continue processing, accept mail in any case. */ return mlfi_cleanup(ctx, SMFIS_ACCEPT); } /* Do cleanup, if any. */ sfsistat mlfi_cleanup(SMFICTX *ctx, sfsistat rc) { return(rc); } /* Milter control block (1st three entries) and function table */ struct smfiDesc smfilter = { "HeaderBuster", /* filter name */ SMFI_VERSION, /* version code */ SMFIF_CHGHDRS, /* flags */ NULL, /* connection info filter */ NULL, /* SMTP HELO command filter */ NULL, /* envelope sender filter */ NULL, /* envelope recipient filter */ NULL, /* header filter */ NULL, /* end of header */ NULL, /* body block filter */ mlfi_eom, /* end of message */ NULL, /* message aborted */ NULL /* connection cleanup */ }; int main(int argc, char *argv[]) { int c; const char *args = "p:"; /* Process command line options */ while ((c = getopt(argc, argv, args)) != -1) { switch (c) { case 'p': if (optarg == NULL || *optarg == '\0') { fprintf(stderr, "Illegal connection string: %s\n", optarg); exit(0); } /* Set the protocol */ smfi_setconn(optarg); break; } } /* Register callbacks */ if (smfi_register(smfilter) == MI_FAILURE) { fprintf(stderr, "smfi_register failed\n"); exit(-1); } /* Become background process and hand over control * to milter by calling smfi_main() */ if (fork() == 0) { return smfi_main(); } /* Parent process exit */ return 0; }