What is the difference between "dnl" and "dnl #" in a sendmail.mc file?

What is the difference between dnl and dnl # in a /etc/mail/sendmail.mc file? If I want to enable something what needs to be in front? Likewise, if I want to "comment out" something, what prefix do I need?

For example:

dnl # masquerade not just @mydomainalias.com, but @*.mydomainalias.com as well
dnl #
dnl FEATURE(masquerade_entire_domain)dnl
dnl #
dnl MASQUERADE_DOMAIN(localhost)dnl
dnl MASQUERADE_DOMAIN(localhost.localdomain)dnl
dnl MASQUERADE_DOMAIN(foo.com)dnl
dnl MASQUERADE_DOMAIN(foo2.lan)dnl
MAILER(smtp)dnl
MAILER(procmail)dnl
dnl MAILER(cyrusv2)dnl

Solution 1:

There's a subtle but important difference between dnl and # here.

dnl means "delete through newline". When you process your sendmail.mc into a sendmail.cf using m4 (or possibly some frontend), the characters dnl and everything following them, including the next newline, will be dropped. (And all of those lines end with dnl to suppress extra blank lines in the sendmail.cf output.)

Nothing beginning with dnl through end of line will make it out of sendmail.mc and into sendmail.cf.

Anything that remains in the output, of course, will either be sendmail configuration, or a comment that begins with #, which will be copied as-is into sendmail.cf, where they will be ignored.

Anything beginning with # and not deleted above will make it into sendmail.cf unmolested as a comment.

In your example, someone meant for all of the commented features to be removed from sendmail.cf, as well as the comments, since the comments would be meaningless without the features present.

Solution 2:

DNL means "delete through newline" which really means "ignore everything after 'dnl' until the next line".

The "dnl #" is just artificial nomenclature. When the sendmail.mc file was first developed they wanted you to know that anything that was "dnl ..." was a command/setting that was commented out and anything that was "dnl #..." was really a descriptive comment that was not a command/setting that could be uncommented because '#' is often used at the beginning of a line to indicate "what follows until end of line" is a comment.

Solution 3:

Yes, 8 years old, and no-one's ever going to read this, but I just wanted to point out that putting two dnls on a line is completely pointless. It doesn't "suppress extra blank lines in the sendmail.cf output", as suggested above.

Since a picture is worth a thousand words:

$ m4 <<EOF 
Line 1
dnl Line 2 
Line 3
dnl Line 4 dnl
Line 5
# Line 6
Line 7
dnl # Line 8
Line 9
EOF

Produces this output:

Line 1
Line 3
Line 5
# Line 6
Line 7
Line 9