MIMEDEFANG(8)

πŸ“¦
version 3.7.1 Β· 2 versions
, in debian trixie, epel 10, epel 9, fedora 43, fedora 44, ubuntu questing, ubuntu resolute, ubuntu stonking

🌸 MIMEDEFANG(8) 🌸

okay bestie, sit down, hydrate, because we're talking about mimedefang β€” the Sendmail MIME mail filter, from the System Manager's Manual. yes, section 8. yes, it's a whole thing. but it's a good thing. 🫢


✨ SYNOPSIS ✨

mimedefang prcap

mimedefang -p connection -m mx_socket_name -U user [options]

like, that's the whole vibe. two shapes. pick one. πŸ’…


πŸ’– DESCRIPTION πŸ’–

so mimedefang is a filter, right, and it's built around Sendmail 8.11's milter API β€” that's the API for mail filters, iykyk. what it does: it collects each incoming message and runs a filter on it. and why do we care? because this is genuinely useful for deleting attachments that could be a security risk on poorly-designed systems like Microsoft Windows. no shade, just facts. πŸ’€

here's the plot twist though β€” mimedefang does not actually run the Perl filter itself. nope. instead it talks to mimedefang-multiplexor(8), which manages a pool of persistent Perl processes. that's the whole relationship dynamic. go read the mimedefang-multiplexor man page for the extra tea. πŸŽ€


πŸŽ€ OPTIONS πŸŽ€

okay so if you invoke mimedefang with the single argument prcap, it prints info about the version of Milter it's linked against and then exits. slay. otherwise, you invoke it like the second line of the SYNOPSIS says. no other options, bestie.

  • -U user β€” runs mimedefang as user instead of root. ⚠️ and the user argument has to match the argument you gave to mimedefang-multiplexor's -U option too. they have to agree, they're a package deal.
  • -y β€” if you give this command-line option, MIMEDefang will call smfi_setsymlist to set the list of macros it wants. but heads up: this function leaked memory in versions of Sendmail prior to 8.14.4, so by default we do not call it. if you're running an older version of sendmail, you should explicitly set the list of macros you want in the Sendmail configuration file. ✨
  • -z spooldir β€” set the spool directory to spooldir. if you skip this option, the spool directory defaults to /var/spool/MIMEDefang.
  • -p connection β€” the -p switch is required and it specifies the milter connection type. typically you should run mimedefang on the same computer as sendmail, which means you should use a UNIX-domain socket for the connection type. the suggested value for -p is mimedefang.sock under the spool directory. πŸ”₯
  • -m mx_socket_name β€” specifies the socket for communicating with mimedefang-multiplexor(8). the mx_socket_name is the path of the UNIX-domain socket. see mimedefang-multiplexor(8) for the details.
  • -b backlog β€” sets the "backlog" argument to the listen(2) system call to backlog. if you omit this option, the operating-system default backlog gets used.
  • -G β€” normally mimedefang uses a umask of 077 when creating the milter socket and files. if you want the socket to be readable and writeable by the group, and files to be group-readable, supply -G. this causes the umask to be 007 whenever UNIX-domain sockets are created and 027 whenever files are created. note: if your milter library is too old to have the smfi_opensocket() function, the -G option causes mimedefang to use a umask of 007 throughout its execution.

also note that by default, /var/spool/MIMEDefang is created with mode 0700. if you use -G, you probably should change the mode to 0750.

  • -d β€” this switch causes mimedefang not to delete the temporary spool files it creates for incoming messages. > this is for debugging purposes only and should never be used on a production mail server. 🚨
  • -r β€” causes mimedefang to perform a relay check before processing any messages. it calls into a user-supplied Perl function called filter_relay with the IP address and host name of the sending relay. (see mimedefang-filter(5) for details.)
  • -H β€” causes mimedefang to perform a HELO check before processing any messages. it calls into a user-supplied Perl function called filter_helo with the IP address and host name of the sending relay, and the HELO argument. (see mimedefang-filter(5) for details.)
  • -s β€” causes mimedefang to perform a sender check before processing the message body. it calls into a user-supplied Perl function called filter_sender with the envelope address of the sender. (see mimedefang-filter(5) for details.)
  • -t β€” causes mimedefang to perform recipient checks before processing the message body. it calls into a user-supplied Perl function called filter_recipient with the envelope address of each recipient. (see mimedefang-filter(5) for details.)
  • -q β€” permits the multiplexor to queue new connections. see the section QUEUEING REQUESTS in the mimedefang-multiplexor man page. note that this option and the -R option are mutually-exclusive β€” if you supply -q, then -R is ignored. πŸ™ˆ
  • -k β€” causes mimedefang not to delete working directories if a filter fails. this lets you obtain the message which caused the filter to fail and figure out what went wrong. mimedefang logs the directory containing the failed message using syslog.
  • -P fileName β€” causes mimedefang to write its process-ID (after becoming a daemon) to the specified file. the file will be owned by root. πŸ‘‘
  • -o fileName β€” causes mimedefang to use fileName as a lock file to avoid multiple instances from running. if you supply -P but not -o, then mimedefang constructs a lock file by appending ".lock" to the pid file. however, that's less secure than having a root-owned pid file in a root-owned directory and a lock file writable by the user named by the -U option. (the lock file must be writable by the -U user.)
  • -R num β€” normally, mimedefang tempfails a new SMTP connection if there are no free workers. supplying -R num makes mimedefang tempfail new connections if there are fewer than num free workers, unless the connection is from the local host. this lets you favour connections from localhost so your clientmqueue doesn't build up. note that supplying -R 0 is subtly different from omitting the option; in this case, mimedefang permits new connections from localhost to queue, but not connections from other hosts (unless you also supply the -q option.)

the purpose of -R is to reserve resources for clientmqueue runs. otherwise, on a very busy mail server, clientmqueue runs can starve for a long time, leading to delays for locally-generated or streamed mail. we recommend using a small number for num; probably no more than 3 or 10% of the total number of workers (whichever is smaller.)

note that this option and the -q option are mutually-exclusive. if you supply -q, then -R is ignored. 🫢

  • -C β€” conserve file descriptors by opening and closing disk files more often. (disk files are never held open across Milter callbacks.) while this shortens the length of time a file descriptor is open, it also leaves more opportunities for the open to fail. we do not recommend this flag except on very busy systems that exhibit failures due to a shortage of file descriptors.
  • -T β€” causes mimedefang to log the run-time of the Perl filter using syslog. ⏱️
  • -x string β€” add string as the content of the X-Scanned-By: header. if you set string to the empty string (i.e. -x ""), then no X-Scanned-By: header will be added.
  • -X β€” do not add an X-Scanned-By: header. specifying -X is equivalent to specifying -x "".
  • -D β€” do not fork into the background and become a daemon. instead, stay in the foreground. useful mainly for debugging or if you have a supervisory process managing mimedefang.
  • -M β€” this option is obsolete; it's accepted for backward-compatibility, but it's ignored. it's giving legacy. πŸ’€
  • -N β€” normally mimedefang sees all envelope recipients, even ones that Sendmail knows to be invalid. if you don't want Sendmail to perform a milter callback for recipients it knows to be invalid, invoke mimedefang with the -N flag. > please note that this flag only works with Sendmail and Milter 8.14.0 and newer. it has no effect if you're running an older version of Sendmail or Milter.
  • -S facility β€” specifies the syslog facility for log messages. the default is mail. see openlog(3) for a list of valid facilities. you can use either the short name ("mail") or long name ("LOG_MAIL") for the facility name.
  • -a macro β€” pass the value of the specified Sendmail macro through to the Perl filter. you can repeat the -a option to write more macros than the built-in defaults. note that in addition to asking mimedefang to pass the macro value to the filter, you must configure Sendmail to pass the macro through to mimedefang using the confMILTER_MACROS_ENVFROM definition in Sendmail's m4 configuration file. ✨
  • -c β€” strip "bare" carriage-returns (CR) characters from the message body. a bare CR should never appear in an e-mail message. older versions of mimedefang used to strip them out automatically, but now they're left in by default. the -c option enables the older behavior.
  • -h β€” print usage information and exit. short, sweet, iconic. πŸŽ€

🌈 OPERATION 🌈

when mimedefang starts, it connects to sendmail using the milter API. (see the Sendmail 8.11 documentation.) for each incoming message, mimedefang creates a temporary directory and saves information in the directory. at various phases during the SMTP conversation, mimedefang communicates with mimedefang-multiplexor to perform various operations. mimedefang-multiplexor manages a pool of persistent Perl processes that actually perform the mail scanning operations.

when a Perl process scans an e-mail, the temporary spool directory contains certain files; details of the communication protocol between mimedefang and the Perl script are in mimedefang-protocol(7). πŸ¦‹


πŸ’€ WARNINGS πŸ’€

mimedefang does violence to the flow of e-mail.

no like, that's literally what it says and honestly? it's not wrong. the Perl filter is quite picky and assumes that MIME e-mail messages are well-formed. while I have tried to make the script safe, I take no responsibility for lost or mangled e-mail messages or any security holes this script may introduce. 😭 read that again. okay. now we can be friends.


πŸ‘‘ AUTHOR πŸ‘‘

mimedefang was written by Dianne Skoll <dfs@roaringpenguin.com>. the mimedefang home page is http://www.mimedefang.org/. absolute main character energy, we love her, no cap. πŸ’–


🧚 SEE ALSO 🧚


okay that's the whole page bestie, you ate it, periodt πŸ’…βœ¨

one last lil sign-off from the group chat: this was the 4th Berkeley Distribution version, dated 8 February 2005, and it lives in the MIMEDEFANG(8) manual slot. cute, iconic, historic. πŸŽ€πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from