cronie-crond / cronie

Cronie cron daemon project
Other
453 stars 77 forks source link

anacron: read SENDMAIL variable from anacrontab #135

Open corvus1 opened 1 year ago

corvus1 commented 1 year ago

Use alternative mailer command.

As briefly discussed in https://github.com/cronie-crond/cronie/issues/133 the change looks for SENDMAIL environment variable, and if it is set, uses it as an alternative mailer. It strips the command line arguments from the execl() call, and lets the mailer sort out the standard input. Perhaps it's not ideal, but I'd like to hear some comments.

For my personal use-case, logger very easily takes the standard input and sends it into syslog, eliminating any need for local mail setup. Which was my goal to begin with. :-) Full disclosure.

Another possible issue is that you can't specify command line parameters for the alternative mailer, it has to be just a path to the binary.

corvus1 commented 1 year ago

See the latest commit message. This thing is taking a toll on me. I think I reached the limit of my C programming capability. I managed to come up with a clever regex to split the command line into the path to binary and arguments, and it even works. However, execl() is acting weird, when passed "" as arguments. And for some reason, if the command line is longer than /usr/bin/logger -t anacronmai by one character, it seems like it overlaps with something in memory, which I imagine is a really bad condition to have. And then, for some bizarre reason I can't even compare mailer_args to NULL.

It's getting bad. Like really bad. I'd greatly appreciate if somebody, who knows C at least a little bit, could take a look at this mess I am about to make.

corvus1 commented 1 year ago

This isn't just ugly, this is desperate. Please send help. :'-(