🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
5 messages
5 total messages Started by D. Stussy Tue, 02 Feb 2010 20:35
NNRPD - connect message in syslog
#82731
Author: D. Stussy
Date: Tue, 02 Feb 2010 20:35
22 lines
1628 bytes
Hint:  It would be nice if the NNRPD connection message in the syslog
indicated the server's port number (so one can tell if a peer executed
"mode reader" on port 119, or if someone came in on port 563, etc.).  This
is especially helpful when NNRPD is spawned as a child process of INN or
inetd.

inn-2.5.1/nnrpd/nnrpd.c - line 612:

    notice("%s (%s) connect", Client.host, Client.ip);

becomes

    notice("%s (%s) connect - port %u", Client.host, Client.ip,
ListenPort);



Also, at line 1034, should we "free(path);"?  I think we should keep the
filename of our PID file around and unlink it as we exit - i.e. in
ExitWithStats() starting at line 196.

Re: NNRPD - connect message in syslog
#82741
Author: Julien ÉLIE
Date: Wed, 03 Feb 2010 23:25
30 lines
2453 bytes
Hi D. Stussy,

> Hint:  It would be nice if the NNRPD connection message in the syslog
> indicated the server's port number (so one can tell if a peer executed
> "mode reader" on port 119, or if someone came in on port 563, etc.).  This
> is especially helpful when NNRPD is spawned as a child process of INN or
> inetd.

OK, will be in INN 2.5.2.
To differentiate different instances of nnrpd, you can also name the
program differently.  Debian for instance uses "nnrpd-ssl" and that's
what is mentioned in relevant news.notice lines.



> Also, at line 1034, should we "free(path);"?  I think we should keep the
> filename of our PID file around and unlink it as we exit - i.e. in
> ExitWithStats() starting at line 196.

path is a local variable in main().  It is destroyed after being used.
Why would you retain it longer than needed?

-- 
Julien ÉLIE

« The hardest thing is to go to sleep at night, when there are
  so many urgent things needing to be done.  A huge gap
  exists between what we know is possible with today's machines
  and what we have so far been able to finish. »  (Donald Knuth) 
Re: NNRPD - connect message in syslog
#82745
Author: D. Stussy
Date: Thu, 04 Feb 2010 22:33
32 lines
2497 bytes
"Julien ÉLIE" <iulius@nom-de-mon-site.com.invalid> wrote in message
news:hkd0lo$opq$1@news.trigofacile.com...
> Hi D. Stussy,
> > Hint:  It would be nice if the NNRPD connection message in the syslog
> > indicated the server's port number (so one can tell if a peer executed
> > "mode reader" on port 119, or if someone came in on port 563, etc.).
This
> > is especially helpful when NNRPD is spawned as a child process of INN
or
> > inetd.
>
> OK, will be in INN 2.5.2.
> To differentiate different instances of nnrpd, you can also name the
> program differently.  Debian for instance uses "nnrpd-ssl" and that's
> what is mentioned in relevant news.notice lines.

There may be other situations where non-standard port numbers are used
(e.g. "-p"), so this is more portable to those, and probably preferred to a
link in the filesystem providing an alias name to the nnrpd executable.

> > Also, at line 1034, should we "free(path);"?  I think we should keep
the
> > filename of our PID file around and unlink it as we exit - i.e. in
> > ExitWithStats() starting at line 196.
>
> path is a local variable in main().  It is destroyed after being used.
> Why would you retain it longer than needed?

To delete the PID file when the process exits.  Unlink() takes a
file-system name.

Re: NNRPD - connect message in syslog
#82750
Author: Julien ÉLIE
Date: Thu, 04 Feb 2010 22:58
67 lines
3682 bytes
> inn-2.5.1/nnrpd/nnrpd.c - line 612:
>
>    notice("%s (%s) connect", Client.host, Client.ip);
>
> becomes
>
>    notice("%s (%s) connect - port %u", Client.host, Client.ip, ListenPort);

Hey!  That was a trap.  The variable ListenPort is not defined in
this context.  And the change breaks innreport.

You could have told me that you had not tested your suggestion.



Index: nnrpd/nnrpd.c
===================================================================
--- nnrpd/nnrpd.c       (révision 8880)
+++ nnrpd/nnrpd.c       (copie de travail)
@@ -531,7 +531,7 @@
 **  Determine access rights of the client.
 */
 static void
-StartConnection(void)
+StartConnection(unsigned short port)
 {
     static const char *default_host_error = "unknown error";
     struct sockaddr_storage ssc, sss;
@@ -612,7 +612,7 @@
      * of overviews and slow answers on some architectures (like BSD/OS). */
     setsockopt(STDIN_FILENO, IPPROTO_TCP, TCP_NODELAY, &nodelay, sizeof(nodelay));

-    notice("%s (%s) connect", Client.host, Client.ip);
+    notice("%s (%s) connect - port %u", Client.host, Client.ip, port);

     PERMgetaccess(NNRPACCESS);
     PERMgetpermissions();
@@ -1217,7 +1217,7 @@
     xsignal(SIGPIPE, CatchPipe);

     /* Get permissions and see if we can talk to this client. */
-    StartConnection();
+    StartConnection(ListenPort);
     if (!PERMcanread && !PERMcanpost && !PERMneedauth) {
        syslog(L_NOTICE, "%s no_permission", Client.host);
        Reply("%d You have no permission to talk.  Goodbye!\r\n",
Index: scripts/innreport_inn.pm
===================================================================
--- scripts/innreport_inn.pm    (révision 8880)
+++ scripts/innreport_inn.pm    (copie de travail)
@@ -1536,7 +1536,7 @@
     return 1 if $left =~ /^python: dynamic authorization access for read access 
granted$/o;
     return 1 if $left =~ /^python: dynamic authorization access type is not known: 
/o;
     # connect
-    if ($left =~ /(\S+) (\([0-9a-fA-F:.]*\) )?connect$/o) {
+    if ($left =~ /(\S+) (\([0-9a-fA-F:.]*\) )?connect(?: - port \d+)?$/o) {
       my $cust = $1;
       $cust = lc $cust unless $CASE_SENSITIVE;
       my $dom = &host2dom($cust);

-- 
Julien ÉLIE

« Le temps, c'est des sesterces. » (Coquelus) 
Re: NNRPD - connect message in syslog
#82757
Author: Julien ÉLIE
Date: Sat, 06 Feb 2010 12:24
36 lines
2589 bytes
Hi D. Stussy,

>> path is a local variable in main().  It is destroyed after being used.
>> Why would you retain it longer than needed?
>
> To delete the PID file when the process exits.  Unlink() takes a
> file-system name.

It is true that nnrpd.pid is never destroyed when nnrpd runs in daemon
mode.
But how could we handle that thing:
 * nnrpd listening on port 563, IP 91.121.26.68
 * nnrpd listening on port 563, IP 2001:41d0:1:6d44::1

that is to say two daemons listening on the same port.


No problem with innd.pid because there is only 1 possible innd running
at the same time.
Only one cnfsstat.pid and innwatch.pid too.

I see that innfeed.pid is dealt with pid-file in innfeed.conf.


But how nnrpd.pid is supposed to work?  With both the port *and the IP*
in its name?
Anyway, the file is never looked at...  If it already exists, that will
change nothing (nnrpd will complain that it cannot bind to the specified
port and IP because of innbind and not because of the pid file).

-- 
Julien ÉLIE

« -- Où vous croyez-vous ici ?
  -- Où je me trouve, je sais. » (Astérix) 
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