Inadequate error reporting from nnrpd Perl loader
Julien ÉLIE
julien at trigofacile.com
Mon Feb 13 14:41:01 UTC 2012
Hi River,
>>> At no point does it indicate there was any error loading the script, or
>>> what the error might be.
>>
>> Isn't the following line what you were looking for?
>> Feb 3 17:39:00 isis nnrpd[2481]: Perl function authenticate not defined
>
> That doesn't really tell me anything -- I already knew that
> authenticate() wasn't working, because no clients were able to
> authenticate. But before I found the actual problem I spent about 20
> minutes looking at other things (like syntax errors in the script, nnrpd
> configuration, ...). For a simple case like 'unable to open file', an
> error saying so would be quite nice.
OK, I understand your point.
The code should take care of it but apparently does not.
nnrpd/perl.c
------------
PERLsetup(NULL, script_path, "authenticate");
lib/perl.c
----------
PERLsetup() calls PERLreadfilter() because the first argument is NULL.
We have:
/* The Perl expression which will be evaluated. */
xasprintf(&evalfile, "do '%s'", filterfile);
PerlSilence();
perl_eval_pv(evalfile, TRUE);
PerlUnSilence();
SPAGAIN;
free(evalfile);
evalfile = NULL;
/* Check $@. */
if (SvTRUE(ERRSV)) {
failure = true;
syslog (L_ERROR,"SERVER perl loading %s failed: %s",
filterfile, SvPV(ERRSV, PL_na));
} else {
failure = false;
}
$@ contains nothing whereas it would be expected that it contains an error.
According to the Perl documentation:
"If do can read the file but cannot compile it, it returns undef and
sets an error message in $@ . If do cannot read the file, it returns
undef and sets $! to the error. Always check $@ first, as compilation
could fail in a way that also sets $! ."
% perl -e 'do "/pouet"; print $!;'
Aucun fichier ou répertoire de ce type
** Is there a function that gives the value of $! in Perl C API? I do
not see one.
Otherwise, would the right thing to do is to define a variable in the
perl_eval_pv() call (like "do '%s'; $error = $! if $!;" and then get
$error with get_sv() and checks that it is not NULL?
Incidentally, I read before PerlSilence():
/*
** Redirects STDOUT/STDERR briefly (otherwise PERL complains to the net
** connection for NNRPD and that just won't do) -- dave at jetcafe.org
*/
It may explain a behaviour seen a few weeks ago: The Doctor's gmon.out
message and a Perl "bizarre" error message (reported in Debian bugs for
inn2) that should not be sent via the NNTP connection.
Something is not silence'd somewhere...
--
Julien ÉLIE
« – Que lui est-il arrivé ? Un choc moral ?
– Oui, avec un menhir. » (Astérix)
More information about the inn-workers
mailing list