🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #62107

Re: Coding a auth prog for INND

#62107
From: Jeffrey M. Vinocur
Date: Mon, 25 Nov 2002 11:26
119 lines
5766 bytes
In article <3DE1E349.5020503@NOSPAM_hotmail.com>,
Marc  <syn_uw@NOSPAM_hotmail.com> wrote:
>
>I would like to do my own C code to use as auth program in the 
>readers.conf. Are there any guides out there which specifies what the 
>programm needs to return and how it receives it's input ?

I'm actually in the process of cleaning up the documentation for
that as we speak.  The examples in authprogs/ of the INN source
tree should help.

The following is documentation for CURRENT, but it should mostly
or entirely apply to other versions as well:

---------------------------------------------------------------------------
NNRPD External Authentication Support
    A fundamental part of the readers.conf(5)-based authorization mechanism
    is the interface to external authenticator and resolver programs. This
    interface is documented below.

    INN ships with a number of such programs (all written in C, although any
    language can be used). Code for them can be found in authprogs/ of the
    source tree; the authenticators are installed to *pathbin*/auth/passwd,
    and the resolvers are installed to *pathbin*/auth/resolv.

Reading information from nnrpd
    When nnrpd spawns an external auth program, it passes information on
    standard input as a sequence of "key: value" lines. Each line ends with
    CRLF, and a line consisting of only "." indicates the end of the input.
    The order of the fields is not significant. Additional fields not
    mentioned below may be included; this should not be cause for alarm.

    (For robustness as well as ease of debugging, it is probably wise to
    accept line endings consisting only of LF, and to treat EOF as
    indicating the end of the input even if "." has not been received.)

  For authenticators

    When nnrpd calls an authenticator, the lines it passes are

        ClientAuthname: user\r
        ClientPassword: pass\r

    where *user* and *pass* are the username and password provided by the
    client (e.g. using AUTHINFO). In addition, nnrpd generally also passes
    the fields mentioned as intended for resolvers; it rare instances this
    data may be useful for authenticators.

  For resolvers

    When nnrpd calls a resolver, the lines it passes are

        ClientHost: hostname\r
        ClientIP: IP-address\r
        ClientPort: port\r
        LocalIP: IP-address\r
        LocalPort: port\r
        .\r

    where *hostname* indicates a string representing the hostname if
    available, *IP-address* is a numeric IP address (dotted-quad for IPv4,
    equivalent for IPv6 if appropriate), and *port* is a numeric port
    number. (The *LocalIP* paramter may be useful for determining which
    interface was used for the incoming connection.)

    If information is not available, nnrpd will omit the corresponding
    fields. In particular, this applies to the unusual situation of nnrpd
    not being connected to a socket; TCP-related information is not
    available for standard input.

Returning information to nnrpd
  Exit status and signals

    The external auth program must exit with a status of `0' to indicate
    success; any other exit status indicates failure. (The non-zero exit
    value will be logged.)

    If the program dies due to catching a signal (for example, a
    segmentation fault occurs), this will be logged and treated as a
    failure.

  Returning a username and domain

    If the program succeeds, it may return a username string (optionally
    with a domain appended) by writing to standard output. The line it
    should write is exactly:

        user:username\r

    where *username* is the string that nnrpd should use in matching
    readers.conf access blocks.

    There should be no extra spaces in lines sent from the hook to nnrpd;
    `user:aidan' is read by nnrpd as a different username than `user:
    aidan'.

Error messages
    As mentioned above, errors can be indicated by a non-zero exit value, or
    termination due to an unhandled signal; both cases are logged by nnrpd.
    However, external auth programs may wish to log error messages
    separately.

    Although nnrpd will syslog() anything an external auth program writes to
    standard error, it is generally better to use the messages.h functions,
    such as warn() and die().

    Please use the ckpasswd.c program as an example for any authenticators
    you write, and ident.c as an example for any resolvers.

HISTORY
    Written by Aidan Cully for InterNetNews. This documentation rewritten in
    POD by Jeffrey M. Vinocur <jeff@litech.org>.
---------------------------------------------------------------------------


-- 
Jeffrey M. Vinocur
jeff@litech.org
Technical Details
Message-ID: <art1dk$j1j$1@puck.litech.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.ems.psu.edu!news.litech.org!not-for-mail
References: <3DE1E349.5020503@NOSPAM_hotmail.com>

Show Full Headers
Complete Article Headers
Message-ID: <art1dk$j1j$1@puck.litech.org>
Subject: Re: Coding a auth prog for INND
Date: Mon, 25 Nov 2002 11:26:44 +0000
From: jeff@litech.org (Jeffrey M. Vinocur)
References: <3DE1E349.5020503@NOSPAM_hotmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.ems.psu.edu!news.litech.org!not-for-mail
Newsgroups: news.software.nntp
Organization: Litech Systems Design
Lines: 118
Sender: jeff@litech.org
NNTP-Posting-Host: puck.litech.org
X-Trace: puck.litech.org 1038223604 19507 66.218.0.75 (25 Nov 2002 11:26:44 GMT)
X-Complaints-To: usenet@litech.org
NNTP-Posting-Date: Mon, 25 Nov 2002 11:26:44 +0000 (UTC)
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
Originator: jeff@litech.org (Jeffrey M. Vinocur)