Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 1
    The sendmail path is hardcoded: strings /usr/sbin/cron | grep sendmail. That's usually a symbolic link to the actual mta. Commented Oct 16, 2021 at 15:36
  • It's trivial to point it to a script which invokes logger or whatever. There probably already are ready-made debian packages which do just that. Commented Oct 16, 2021 at 15:38
  • Your additional question: It's hardcoded. That's why I suggested recompiling. In short: In config.h (cron sources) you have #define MAILARG _PATH_SENDMAIL. In pathnames.h (cron sources), you have a #define which sets _PATH_SENDMAIL, but this is not relevant because _PATH_SENDMAIL already is defined here by the inclusion of <paths.h> (glibc sources), and there you finally have #define _PATH_SENDMAIL "/usr/sbin/sendmail". To change the script's location, you could write #define MAILARG "/your/own/path/to/script" in config.h and recompile cron. Commented Oct 18, 2021 at 20:54
  • @CocaineMitch In Debian Buster, it's not even a symbolic link ... What did you mean by "It's trivial to point it to ..."? Did you speak about making /usr/sbin/sendmail a symbolic link pointing to the custom script? Then you'll have the same problem as my solution: What if the "real" program expected there is needed? I fear that there is no other way than recompiling to solve this problem ... Commented Oct 18, 2021 at 21:10
  • @400 the cat As another and last idea, you could put your script as /usr/sbin/sendmail, and make it figure out who has called it when it is executed. If cron has called it, make it behave as described in my solution; if not, let it just call the "real" sendmail binary (wherever you have moved it to) with the same arguments and stdin (that is, just let the script "relay" the arguments and stdin to sendmail). Commented Oct 20, 2021 at 10:22