Thread View: news.software.nntp
10 messages
10 total messages
Started by Michael Grimm
Sun, 14 Nov 2010 14:41
Undefined $user in filter_nnrpd.pl?
Author: Michael Grimm
Date: Sun, 14 Nov 2010 14:41
Date: Sun, 14 Nov 2010 14:41
35 lines
2498 bytes
2498 bytes
Hi -- I'm running nnrpd (20100814) in daemon mode (plus: -S -p xxx), and user authentication is achieved using ckpasswd (from file) in readers.conf. My filter_nnrpd.pl has always been used to access headers (encryption of sensible data) successfully. Recently, I tried to expand that filter regarding Cancel-Lock and Cancel-Key addition. In order to generate user specific locks and keys I'm trying to use $user according: ,----[ http://www.eyrie.org/~eagle/software/inn/docs/hook-perl.html ]- | ... if the poster authenticated via AUTHINFO (or if either Perl | authentication or a readers.conf authentication method is used and | produces user information), it has access to the authenticated username | of the poster in the variable $user. `---- But, whenever I access the variable $user in filter_nnrpd.pl's filter_post subroutine, I'll end up in: ,---- | nnrpd[123]: Perl function filter_post died: Undefined subroutine &main::filter_post called. | nnrpd[123]: SERVER perl filtering disabled `---- Whenever I do hardcode a user like ... my $user = "someone"; ... everything's fine with my code. What's wrong with my approach? Why isn't $user defined? Is it my setup with nnrpd in daemon mode, my authentication method, or? Regards, Michael -- to let
Re: Undefined $user in filter_nnrpd.pl?
Author: Thomas Hochstein
Date: Sun, 14 Nov 2010 18:28
Date: Sun, 14 Nov 2010 18:28
19 lines
1789 bytes
1789 bytes
Michael Grimm schrieb: > But, whenever I access the variable $user in filter_nnrpd.pl's filter_post > subroutine, I'll end up in: > ,---- >| nnrpd[123]: Perl function filter_post died: Undefined subroutine &main::filter_post called. >| nnrpd[123]: SERVER perl filtering disabled > `---- Strange. > Whenever I do hardcode a user like ... > my $user = "someone"; > ... everything's fine with my code. Could you show us the relevant parts of your filter_nnrpd.pl, anonymized as necessary? -thh
Re: Undefined $user in filter_nnrpd.pl?
Author: Michael Grimm
Date: Sun, 14 Nov 2010 20:33
Date: Sun, 14 Nov 2010 20:33
28 lines
2006 bytes
2006 bytes
Thomas Hochstein <thh@inter.net> wrote:
> Michael Grimm schrieb:
>> But, whenever I access the variable $user in filter_nnrpd.pl's filter_post
>> subroutine, I'll end up in:
>> ,----
>>| nnrpd[123]: Perl function filter_post died: Undefined subroutine &main::filter_post called.
>>| nnrpd[123]: SERVER perl filtering disabled
>> `----
>
> Strange.
>
>> Whenever I do hardcode a user like ...
>> my $user = "someone";
>> ... everything's fine with my code.
>
> Could you show us the relevant parts of your filter_nnrpd.pl,
> anonymized as necessary?
A simple ...
INN::syslog('notice',$user);
... at the end of filter_post will trigger that error message. Whenever
I define a global $user variable as mentioned above, everything's fine.
Regards,
Michael
--
to let
Re: Undefined $user in filter_nnrpd.pl?
Author: Michael Grimm
Date: Sun, 14 Nov 2010 20:48
Date: Sun, 14 Nov 2010 20:48
13 lines
1615 bytes
1615 bytes
Michael "Ingrid" Grimm <trashcan@odo.in-berlin.de> wrote:
> A simple ...
> INN::syslog('notice',$user);
> ... at the end of filter_post will trigger that error message. Whenever
> I define a global $user variable as mentioned above, everything's fine.
BTW: It's Perl 5.8.9
Regards,
Michael
--
to let
Re: Undefined $user in filter_nnrpd.pl?
Author: Julien ÉLIE
Date: Sun, 14 Nov 2010 23:07
Date: Sun, 14 Nov 2010 23:07
32 lines
2430 bytes
2430 bytes
Hi Michael,
>>> But, whenever I access the variable $user in filter_nnrpd.pl's filter_post
>>> subroutine, I'll end up in:
>>> ,----
>>>| nnrpd[123]: Perl function filter_post died: Undefined subroutine
>>>&main::filter_post called.
>>>| nnrpd[123]: SERVER perl filtering disabled
>>> `----
>
> A simple ...
> INN::syslog('notice',$user);
> ... at the end of filter_post will trigger that error message.
I'm sorry to tell you that this very line (placed just before "return $rval;")
works fine with my CURRENT nnrpd...
No changes done on nnrpd since August, that could have had an impact.
I've just seen in my logs:
Nov 15 00:01:26 news nnrpd[4029]: filter: julien
Perl 5.8.8 at my end (Debian Etch).
--
Julien ÉLIE
« -- Ils transportent une arme secrète dans un tonneau !
-- La cervoise tiède !!!
-- Non, ça c'est une arme connue. » (Astérix)
Re: Undefined $user in filter_nnrpd.pl?
Author: Thomas Hochstein
Date: Mon, 15 Nov 2010 07:51
Date: Mon, 15 Nov 2010 07:51
28 lines
2200 bytes
2200 bytes
Michael Grimm schrieb:
> Thomas Hochstein <thh@inter.net> wrote:
>> Michael Grimm schrieb:
>>> But, whenever I access the variable $user in filter_nnrpd.pl's filter_post
>>> subroutine, I'll end up in:
>>> ,----
>>>| nnrpd[123]: Perl function filter_post died: Undefined subroutine &main::filter_post called.
>>>| nnrpd[123]: SERVER perl filtering disabled
>>> `----
>> Strange.
To elaborate on that: even an undefinied $user shouldn't lead to
&filter_post being undefined!
>> Could you show us the relevant parts of your filter_nnrpd.pl,
>> anonymized as necessary?
So that was the reason for my request.
> A simple ...
> INN::syslog('notice',$user);
> ... at the end of filter_post will trigger that error message. Whenever
> I define a global $user variable as mentioned above, everything's fine.
It doesn't here, and it shouldn't. :)
-thh
Re: Undefined $user in filter_nnrpd.pl?
Author: Michael Grimm
Date: Mon, 15 Nov 2010 17:12
Date: Mon, 15 Nov 2010 17:12
43 lines
2757 bytes
2757 bytes
Thomas Hochstein <thh@inter.net> wrote:
> Michael Grimm schrieb:
>> Thomas Hochstein <thh@inter.net> wrote:
>>> Michael Grimm schrieb:
>>>> But, whenever I access the variable $user in filter_nnrpd.pl's filter_post
>>>> subroutine, I'll end up in:
>>>> ,----
>>>>| nnrpd[123]: Perl function filter_post died: Undefined subroutine &main::filter_post called.
>>>>| nnrpd[123]: SERVER perl filtering disabled
>>>> `----
>>> Strange.
>
> To elaborate on that: even an undefinied $user shouldn't lead to
> &filter_post being undefined!
>
>>> Could you show us the relevant parts of your filter_nnrpd.pl,
>>> anonymized as necessary?
>
> So that was the reason for my request.
Well, I did reduce my filter_nnrpd.pl to ...
,----
| use strict;
| our (%hdr, $modify_headers);
| sub filter_post {
| my $rval = '';
| $modify_headers = 1;
| INN::syslog('notice',"DEBUG(user): ".$user);
| return $rval;
| }
`----
... and it triggered the error message as cited above. But, when I do
remove the "use strict;", well, then the filter works as expected ;-)
Hmm. I'm not that much an expert in Perl, thus I don't understand it.
Anyway, thanks to both of you in helping me to debug my issue here.
Regards,
Michael
--
to let
Re: Undefined $user in filter_nnrpd.pl?
Author: Ralf Döblitz
Date: Mon, 15 Nov 2010 18:12
Date: Mon, 15 Nov 2010 18:12
22 lines
2499 bytes
2499 bytes
Michael Grimm <trashcan@odo.in-berlin.de> wrote:
[...]
>>> Whenever I do hardcode a user like ...
>>> my $user = "someone";
>>> ... everything's fine with my code.
[...]
> A simple ...
> INN::syslog('notice',$user);
> ... at the end of filter_post will trigger that error message. Whenever
> I define a global $user variable as mentioned above, everything's fine.
WFM, no error message and there is a line in the log file.
JFTR: A declaration with "my" is a lexical variable, not a global
variable (which you can define with "our").
Ralf
--
Ralf Döblitz * Schapenstraße 6 * 38104 Braunschweig * Germany
Phone: +49-531-2361223 Fax: +49-531-2361224 mailto:doeblitz@doeblitz.net
Homepage: http://www.escape.de/users/selene/
Mit UTF-8 kann man gleichzeitig äöüßÄÖÜæœłø‱¼½¾¤¹²³¢€£¥¶§¬÷×±©®™¡¿ verwenden…
Re: Undefined $user in filter_nnrpd.pl?
Author: Ralf Döblitz
Date: Tue, 16 Nov 2010 07:23
Date: Tue, 16 Nov 2010 07:23
29 lines
2944 bytes
2944 bytes
Michael Grimm <trashcan@odo.in-berlin.de> wrote:
[...]
> Well, I did reduce my filter_nnrpd.pl to ...
> ,----
> | use strict;
> | our (%hdr, $modify_headers);
> | sub filter_post {
> | my $rval = '';
> | $modify_headers = 1;
> | INN::syslog('notice',"DEBUG(user): ".$user);
> | return $rval;
> | }
> `----
> ... and it triggered the error message as cited above. But, when I do
> remove the "use strict;", well, then the filter works as expected ;-)
Ahemm, if you use "use strict" you have to declare all variables that
you use. So you should expand
| our (%hdr, $modify_headers);
to
| our (%hdr, $modify_headers, $user);
and your perl script will not complain about that variable anymore.
Ralf
--
Ralf Döblitz * Schapenstraße 6 * 38104 Braunschweig * Germany
Phone: +49-531-2361223 Fax: +49-531-2361224 mailto:doeblitz@doeblitz.net
Homepage: http://www.escape.de/users/selene/
Mit UTF-8 kann man gleichzeitig äöüßÄÖÜæœłø‱¼½¾¤¹²³¢€£¥¶§¬÷×±©®™¡¿ verwenden…
Re: Undefined $user in filter_nnrpd.pl?
Author: Michael Grimm
Date: Wed, 17 Nov 2010 19:15
Date: Wed, 17 Nov 2010 19:15
31 lines
2424 bytes
2424 bytes
Ralf Döblitz <doeblitz@doeblitz.net> wrote:
> Michael Grimm <trashcan@odo.in-berlin.de> wrote:
>> Well, I did reduce my filter_nnrpd.pl to ...
>> ,----
>> | use strict;
>> | our (%hdr, $modify_headers);
>> | sub filter_post {
>> | my $rval = '';
>> | $modify_headers = 1;
>> | INN::syslog('notice',"DEBUG(user): ".$user);
>> | return $rval;
>> | }
>> `----
>> ... and it triggered the error message as cited above. But, when I do
>> remove the "use strict;", well, then the filter works as expected ;-)
>
> Ahemm, if you use "use strict" you have to declare all variables that
> you use. So you should expand
>| our (%hdr, $modify_headers);
> to
>| our (%hdr, $modify_headers, $user);
> and your perl script will not complain about that variable anymore.
Thanks for your clarification. Now, I do understand, and, yes, that
script doesn't complain any longer.
Regards,
Michael
--
to let
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads