13

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

3 Answers 3

19

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.

5
  • 1
    You don't have to end a line with dnl but you'll end up with extra blank lines in sendmail.cf. And yes, if you want something to take effect, it must actually be present in sendmail.cf... Feb 8, 2014 at 6:36
  • 1
    @MikeB m4 is case sensitive - DNL is not dnl. Sorry but I have seen a few stupid m4 bugs in answears with very high scores in Stack Exchange sites.
    – AnFi
    Feb 9, 2014 at 23:16
  • ... and so that means if I want an explicit configuration option to take effect it must NOT have dnl or dnl # in front of it...? and I'll want to always end it with dnl?
    – Mike B
    Feb 10, 2014 at 3:00
  • @AndrzejA.Filip Thanks. The site wouldn't let me edit the question so I re-added it.
    – Mike B
    Feb 10, 2014 at 3:01
  • I find that a line beginning with # does not get copied as-is to sendmail.cf. Instead, the line is copied with only the # removed. Thus, a # line does not end up as a comment. (I was processing using m4.)
    – Old Geezer
    May 28 at 3:55
4

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.

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.