Mailing List Archive

Conditional startup panic condition
Hi folks,

I have an Exim configuration file that depends on a macro being defined
on the Exim command-line. If it's not defined (e.g. forgetful admin),
I'd like an immediage Exim panic on startup, to ensure no unexpected
side-effects.

Any ideas on how to implement such a panic? It's obviously just a
simple expansion involving string comparison, but what option can I hook
the expansion into?

I'm still using exim-3.36, and probably won't have time to upgrade for
another couple of weeks.

Ciao,
Sheldon.
Re: Conditional startup panic condition [ In reply to ]
On Mon, 22 Jul 2002, Sheldon Hearn wrote:

> I have an Exim configuration file that depends on a macro being defined
> on the Exim command-line. If it's not defined (e.g. forgetful admin),
> I'd like an immediage Exim panic on startup, to ensure no unexpected
> side-effects.
>
> Any ideas on how to implement such a panic? It's obviously just a
> simple expansion involving string comparison, but what option can I hook
> the expansion into?

commandline overrides the definitions in the conffile -> think the
other way around:

cffile: FOOBAR = default-value-lazy-admin

and just before you'd use the macro, check whethet it's the above
default (so no commandline definition has been given). no idea though
on how to make exim panic forcibly. i'd assume you are creative enough
to get it to :)


--
[-]
Re: Conditional startup panic condition [ In reply to ]
On (2002/07/22 14:48), Tamas TEVESZ wrote:

> commandline overrides the definitions in the conffile -> think the
> other way around:
>
> cffile: FOOBAR = default-value-lazy-admin

I know how macros work. :-)

> and just before you'd use the macro, check whethet it's the above
> default (so no commandline definition has been given). no idea though
> on how to make exim panic forcibly. i'd assume you are creative enough
> to get it to :)

Exactly. How do I test the value of the macro, given that it's used as
a component of a path (to the spool directory, for example)? The only
thing I can think of is to use expansion in the value for spool_directory,
and to expand to a syntactically invalid pathname if the default value
of the macro hasn't been overridden. Syntactically invalid pathnames
are quite hard to produce. :-)

Ciao,
Sheldon.
Re: Conditional startup panic condition [ In reply to ]
On Mon, 22 Jul 2002, Sheldon Hearn wrote:

> I know how macros work. :-)

i didn't mean to.. :)

> Exactly. How do I test the value of the macro, given that it's used as
> a component of a path (to the spool directory, for example)? The only
> thing I can think of is to use expansion in the value for spool_directory,
> and to expand to a syntactically invalid pathname if the default value
> of the macro hasn't been overridden. Syntactically invalid pathnames
> are quite hard to produce. :-)

indeed; but what if you set it to some really non-existent dir (whose
parent doesn't, and would never, exist) ? i've just tried it, and exim
seems only to create the last component if the directory doesn't
exist. if the last component's parent doesn't exist, exim panics off.

(is this spool_directory thing the actual problem, or was that only a
dramatization ? :)

--
[-]
Re: Conditional startup panic condition [ In reply to ]
On Mon, 22 Jul 2002, Sheldon Hearn wrote:

> Exactly. How do I test the value of the macro, given that it's used as
> a component of a path (to the spool directory, for example)? The only
> thing I can think of is to use expansion in the value for spool_directory,
> and to expand to a syntactically invalid pathname if the default value
> of the macro hasn't been overridden. Syntactically invalid pathnames
> are quite hard to produce. :-)

Here's how to solve your problem:

FOOBAR = unset
pid_file_path = ${if ! eq{FOOBAR}{unset}{}fail}

An empty value = "unset", so it will revert to the default.

Don't use spool_directory. If the expansion fails, Exim will try to
write to the log. Where will it put the log if you haven't set
log_file_path? Er, in the spool directory...

--
Philip Hazel University of Cambridge Computing Service,
ph10@cus.cam.ac.uk Cambridge, England. Phone: +44 1223 334714.
Re: Conditional startup panic condition [ In reply to ]
On (2002/07/22 14:35), Philip Hazel wrote:

> > Exactly. How do I test the value of the macro, given that it's used as
> > a component of a path (to the spool directory, for example)?
>
> Here's how to solve your problem:
>
> FOOBAR = unset
> pid_file_path = ${if ! eq{FOOBAR}{unset}{}fail}
>
> An empty value = "unset", so it will revert to the default.
>
> Don't use spool_directory. If the expansion fails, Exim will try to
> write to the log. Where will it put the log if you haven't set
> log_file_path? Er, in the spool directory...

Ha! That's what I'm looking for. I have a macro called SPOOL_NAME
which callers are expected to define as either 'std' or 'slow' on the
command-line, so I used this:

FOOBAR=unset

pid_file_path = ${if \
match {SPOOL_NAME} {^(std|slow)\$} \
{/var/run/exim-massmail-deliver-SPOOL_NAME%s.pid} \
fail \
}

spool_directory = /var/spool/exim-massmail-deliver/SPOOL_NAME

Works beautifully, thanks. Now I can add the rest of the macros I've
been wanting to, but haven't for fear of pilot errors.

Ciao,
Sheldon.