[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Fwd: esmtp-run delivers mail from shell, but not from nagios



> Not entirely sure how esmtp-run works in conjunction with
> executing sendmail

Well it's a drop-in sendmail replacement, so we're actually invoking
esmtp-run directly which is masquerading as sendmail.

> I know, for a fact, that NRPE does not set $HOME, and that causes
> problems for mysql when it tries to find its .my.cnf file.

I see, yea this is nagios core and not the NRPE component, but I do
see the same behavior when testing for that. Process seems to drop
privileges from "root" to "nagios", and then while whoami returns
"nagios" the $USER and $HOME variables haven't changed from root.

I'm guessing this might be killing esmtp-run if it's looking for
.esmtprc files in user's home dir, and getting permission denied. :O

Alright, so I ought be able to work around this if I can force the
$HOME env variable to change while specifying my command. This is hard
to keyword search, so: does anyone know how to set an environment
variable and then run a command with that change active without using
a semicolon?

I've tried:
env HOME=/var/lib/nagios echo $HOME > /tmp/test

but even in the shell that does nothing. (leaving me confused what
"env" command is even supposed to do? xD)

I've tried:
export HOME=/var/lib/nagios; echo $HOME > /tmp/test

which works from shell (and permanently kinks the variable in that
shell instance, lol, but for nagios that should be harmless enough)
but Nagios' macro expansion algorithm just ignores everything after
the semicolon. D:  And it just feels wrong having to set a variable
and run a command in two pieces like that anyway; I suspect there must
be a one-shot solution similar to the "env" thing I tried above except
that it would actually work. ;3

- - Jesse


Reply to: