🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
8 messages
8 total messages Started by Julien Lajeunesse Tue, 09 May 2000 00:00
How to hook a perl script to INN?
#46343
Author: Julien Lajeunesse
Date: Tue, 09 May 2000 00:00
20 lines
1431 bytes
Hi all,

I looked on the web and in the archives of this newsgroups but cannot
find this information. If it is explained somewhere, just point me to it
and I'll RTFM ;-).

I want to use a perl script to do the authentication of the users
(username + password) automagically, i.e. if a valid username/password
pair on the system is provided, the server is accessible (I already have
a working setup with /etc/news/nnrp.access, but it is not easily
maintainable). In /etc/news/inn.conf, I set "nnrpperlauth" to true. What
then? How do I "hook" a perl script?

I use INN 2.2.2-12 on Linux 2.2.x.

Many thanks in advance to all,

Julien Lajeunesse

Re: How to hook a perl script to INN?
#46339
Author: Paul Tomblin
Date: Tue, 09 May 2000 00:00
22 lines
1539 bytes
In a previous article, ptomblin@xcski.com (Paul Tomblin) said:
>  if ($debug)
>  {
>    print DEBUG "pwname = $pwname, pass = $pwpass, name = $fullname\n";
>  }

Oh, I forgot to mention that $debug and DEBUG are stuff that I set up at
the top of the script for debugging purposes.  Near the top, I set $debug
to 0 (1 when I'm debugging), and then in sub loadnnrp, I do an
  if ($debug)
  {
    open(DEBUG, ">>/tmp/nnrpd_auth.debug") or $debug = 0;
  }



-- 
Paul Tomblin <ptomblin@xcski.com>, not speaking for anybody
"While you're waiting, read the free novel we sent you.  It's a Spanish story
about a guy named `Manual'" - Dilbert

Re: How to hook a perl script to INN?
#46340
Author: Paul Tomblin
Date: Tue, 09 May 2000 00:00
39 lines
2236 bytes
In a previous article, Julien Lajeunesse <julien.lajeunesse@hermes.usherb.ca> said:
>I want to use a perl script to do the authentication of the users
>(username + password) automagically, i.e. if a valid username/password
>pair on the system is provided, the server is accessible (I already have
>a working setup with /etc/news/nnrp.access, but it is not easily
>maintainable). In /etc/news/inn.conf, I set "nnrpperlauth" to true. What
>then? How do I "hook" a perl script?

You replace bin/filter/nnrpd_auth.pl with your own.  The existing one is
a decent template to start from.

Here's my version of sub checkuser:
sub checkuser {
  my $user = $attributes{'username'};
  my $pass = $attributes{'password'};

  my ($pwname, $pwpass, $fullname) = (getpwnam $user)[0,1,6];

  if ($debug)
  {
    print DEBUG "pwname = $pwname, pass = $pwpass, name = $fullname\n";
  }

  if (crypt($pass, $pwpass) eq $pwpass)
  {
    print DEBUG " -- passed! $authcodes{'allowed'} --\n" if $debug;
    return ($authcodes{'allowed'}, 1, 1, "*", $fullname);
  }

  return ($authcodes{'denied'}, 1, 1, "!*");
}

-- 
Paul Tomblin <ptomblin@xcski.com>, not speaking for anybody
What happens if a big asteroid hits the Earth?  Judging from realistic
simulations involving a sledge hammer and a common laboratory frog, we
can assume it will be pretty bad.  -- Dave Barry

Re: How to hook a perl script to INN?
#46342
Author: Julien Lajeunesse
Date: Tue, 09 May 2000 00:00
27 lines
1845 bytes
Ok, everything seems to be working now... I still do some test and give
you some news + a perl script working with PAM (hopefully ;-).



> > authinfo pass bar
> > (you should get "281 Ok")
> 
> Here I get a "Connection closed by foreign host" no matter what I
> entered previously (good or bad password). I even hardcoded a 281
> response in the perl script. If I enter a non-existing username, I get
> an "internal error" message.

The problem was that I had based my script on the one that comes with
INN... Not a good idea it seems after all the problems I went through
;-). Anyway, their script was sending back 5 fields in the array

(code, read, write, group mask, username)

by removing username (I saw it suddendly and got suspicious ;-) the
authentication works!

Thanks to everyone who helped!

Julien Lajeunesse

Re: How to hook a perl script to INN?
#46344
Author: Paul Tomblin
Date: Tue, 09 May 2000 00:00
31 lines
2069 bytes
In a previous article, Julien Lajeunesse <julien.lajeunesse@hermes.usherb.ca> said:
>But I still have a problem. If anyone has a clue I would like to hear
>from you! When setting useperlauth to true in /etc/news/inn.conf, I get
>an error when I try to connect. The simplest test I have done is the
>following:
>-I make sure that nnrpd_auth.pl returns (200, 1, 1, "local.*") upon a
>connection, so there's not even authentication going on;
>-When trying to connect with tin I get this error:

Never mind what tin and Netscape do, what happens when you telnet directly
to the 119 port?

You can try the following commands:
mode reader
group foo.bar.baz
(you should get "480 Authentication required for command")
authinfo user foo
(you should get "381 PASS required")
authinfo pass bar
(you should get "281 Ok")
group foo.bar.baz
(you should get "211 nnn nnnn nnnn foo.bar.baz")



-- 
Paul Tomblin <ptomblin@xcski.com>, not speaking for anybody
"If you would like a transcript of this program, sit next to your radio with a
pencil and paper and write really fast." - The WRVO Playhouse.

Re: How to hook a perl script to INN?
#46346
Author: Julien Lajeunesse
Date: Tue, 09 May 2000 00:00
40 lines
2101 bytes
Ok, I figured out what the previous problem was (some code was still
there about a CDB file... just commented it and now the previous strange
error has disappeared). However I still have the problem I was talking
about in the end of my post, about the "always denied" situation.

> Never mind what tin and Netscape do, what happens when you telnet directly
> to the 119 port?

Duh! Dumb me... I should have thought about this one myself. First thing
I try for mail servers, and I did not even think about it for my news
server ;-). ok...

> You can try the following commands:
> mode reader

ok.

> group foo.bar.baz
> (you should get "480 Authentication required for command")

ok.

> authinfo user foo
> (you should get "381 PASS required")

ok.

> authinfo pass bar
> (you should get "281 Ok")

Here I get a "Connection closed by foreign host" no matter what I
entered previously (good or bad password). I even hardcoded a 281
response in the perl script. If I enter a non-existing username, I get
an "internal error" message.

I still investigate my problem, any help appreciated!

Julien Lajeunesse

Re: How to hook a perl script to INN?
#46348
Author: Julien Lajeunesse
Date: Tue, 09 May 2000 00:00
59 lines
2938 bytes
Hi again,

Thank you very much Paul for your help, everything is going better
everyday :-).

Now I've played with the perl script. I installed the Authen::PAM perl
module which allow a script to use the PAM mechanism in Linux or FreeBSD
or Solaris. This way shadow password and encryption such as MD5 are not
a problem. As soon as I have everything working I'll post my
nnrpd_auth.pl so people interested in it can take a look.

But I still have a problem. If anyone has a clue I would like to hear
from you! When setting useperlauth to true in /etc/news/inn.conf, I get
an error when I try to connect. The simplest test I have done is the
following:
-I make sure that nnrpd_auth.pl returns (200, 1, 1, "local.*") upon a
connection, so there's not even authentication going on;
-When trying to connect with tin I get this error:

-----

bash$ tin -g localhost
tin pre-1.4 release 19990216 ("Styrofoam") [UNIX] (c) Copyright 1991-99
Iain Lea.
Reading config file...
Connecting to localhost...
localhost InterNetNews server INN 2.2 21-Jan-1999 ready
Your server does not have Xref: in its XOVER information.
Tin will try to use XHDR XREF instead (slows down things a bit).
Reading input history file...
Reading groups from active file... Active file corrupt - Subject:
Active file corrupt - From:
Active file corrupt - Date:
Active file corrupt - Message-ID:
Active file corrupt - References:
Active file corrupt - Bytes:
Active file corrupt - Lines:
Active file corrupt - Xref:full

servers active-file contains no newsgroups. Exiting.
Disconnecting from server...

-----

With Netscape I have an error message saying "Bad command use".

If I "come back" to using /etc/news/nnrp.access, everything works fine.

(If I ask for authentication, I am prompted for a username and password
and then I get a "auhtentication failed" error even if I do nothing and
*always* return the access granted value!!!)

Any cue? I'm still working on it!

Thanks again in advance for any help,

Julien Lajeunesse

Re: How to hook a perl script to INN?
#46354
Author: Paul Tomblin
Date: Wed, 10 May 2000 00:00
19 lines
1719 bytes
In a previous article, Julien Lajeunesse <julien.lajeunesse@hermes.usherb.ca> said:
>INN... Not a good idea it seems after all the problems I went through
>;-). Anyway, their script was sending back 5 fields in the array
>
>(code, read, write, group mask, username)

No, that's my example that did that, I think.  I hacked my version of inn
to replace the supplied "From" header with the user's real name and email
address, because our upstream provider at one place I run doesn't allow
munged addresses - they require us to be able to identify who posted what.

Sorry, I forgot.

-- 
Paul Tomblin <ptomblin@xcski.com>, not speaking for anybody
I've had a perfectly wonderful evening.  But this wasn't it.
        -- Groucho Marx, 1890-1977

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