Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anacron: ignores -m command line parameter #133

Open
corvus1 opened this issue Jan 7, 2023 · 11 comments
Open

anacron: ignores -m command line parameter #133

corvus1 opened this issue Jan 7, 2023 · 11 comments

Comments

@corvus1
Copy link

corvus1 commented Jan 7, 2023

Not sure if intentional or not, but inconsistent. If you pass -m to the cron daemon, it's using alternative MTA command to mail the output of the cronjobs. Works fine with crond, and I think it's the standard for any crond implementation. Anacron, however, still calls /usr/sbin/sendmail.

Can it be corrected somehow?

@t8m t8m added the enhancement label Jan 9, 2023
@t8m
Copy link
Member

t8m commented Jan 9, 2023

Anacron does not have any way to change the mailer command. It would be a new feature.

@corvus1
Copy link
Author

corvus1 commented Jan 9, 2023

Can I humbly request it?

@t8m t8m added the help wanted label Jan 9, 2023
@t8m
Copy link
Member

t8m commented Jan 9, 2023

Can I humbly request it?

There is no active development of cronie going on right now. But I review and merge external contributions if there are any.

@corvus1
Copy link
Author

corvus1 commented Jan 9, 2023

Can I humbly request it?

There is no active development of cronie going on right now. But I review and merge external contributions if there are any.

So you're saying if I do it myself, there's a chance of getting a pull request merged?
I am... not great at C, but I might try...

@t8m
Copy link
Member

t8m commented Jan 9, 2023

So you're saying if I do it myself, there's a chance of getting a pull request merged?

Yes, I'd suggest first describing here the exact way how it would be configured before you start implementing.

@corvus1
Copy link
Author

corvus1 commented Jan 9, 2023

My first idea was to read a variable from anacrontab. It already has MAILTO and MAILFROM, I was thinking of adding something like MAILER. Or even just SENDMAIL. And stuffing it here:

#define SENDMAIL "/usr/sbin/sendmail"

Somehow it already has a variable defined. Says it's user-configurable... Or is it configurable at build-time?

@t8m
Copy link
Member

t8m commented Jan 9, 2023

Says it's user-configurable... Or is it configurable at build-time?

Yeah, it is meant to be configurable by editing the global.h file. Which is of course build-time and not particularly friendly way.

@corvus1
Copy link
Author

corvus1 commented Jan 9, 2023

Huh, but, being a gentoo-user, might be fine for me. :-) But okay.

Then if we look here:

cronie/anacron/runjob.c

Lines 316 to 328 in 5578503

/* Get the source email address if set, or current user otherwise */
mailfrom = getenv("MAILFROM");
if (mailfrom == NULL) {
mailfrom = username();
}
else {
if (expand_envvar(mailfrom, mailfrom_expanded, sizeof(mailfrom_expanded))) {
mailfrom = mailfrom_expanded;
}
else {
complain("The environment variable 'MAILFROM' could not be expanded. The non-expanded value will be used.");
}
}

We're reading variables from the environment. I'll read another one, SENDMAIL, in the same way as other 2. And if it's not defined in the environment, it'll be left as defined in global.h, right? Sounds pretty simple to implement. I might even be able to do it, without too much trouble. And then just to document it in the man page.

Does that sound sane? I'm asking all these questions, because I know how easy it is to make a horrible mess in C.

@t8m
Copy link
Member

t8m commented Jan 9, 2023

Does that sound sane? I'm asking all these questions, because I know how easy it is to make a horrible mess in C.

Yeah, that would be fine.

@corvus1
Copy link
Author

corvus1 commented Jan 11, 2023

Here's what I managed so far. #135

@corvus1
Copy link
Author

corvus1 commented Jan 20, 2023

@t8m Would you care to take a quick look at my draft?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants