INN commit: trunk (6 files)
INN Commit
rra at isc.org
Sun Dec 14 20:55:09 UTC 2014
Date: Sunday, December 14, 2014 @ 12:55:09
Author: iulius
Revision: 9770
Add new contrib/nnrp.access2readers.conf.in script
This script converts old-style nnrp.access to readers.conf.
Thanks to Jeffrey M. Vinocur for his contribution.
Added:
trunk/contrib/nnrp.access2readers.conf.in
Modified:
trunk/MANIFEST
trunk/contrib/ (properties)
trunk/contrib/Makefile
trunk/contrib/README
trunk/support/mkmanifest
-------------------------------------+
MANIFEST | 1
contrib/Makefile | 4
contrib/README | 5 +
contrib/nnrp.access2readers.conf.in | 143 ++++++++++++++++++++++++++++++++++
support/mkmanifest | 1
5 files changed, 153 insertions(+), 1 deletion(-)
Modified: MANIFEST
===================================================================
--- MANIFEST 2014-12-14 20:53:16 UTC (rev 9769)
+++ MANIFEST 2014-12-14 20:55:09 UTC (rev 9770)
@@ -75,6 +75,7 @@
contrib/mlockfile.c Lock files into memory using mlock
contrib/mm_ckpasswd Check passwords against Mailman db
contrib/newsresp.c Measure responsiveness of remote server
+contrib/nnrp.access2readers.conf.in Convert nnrp.access file to readers.conf
contrib/pullart.c Recover articles from cyclic buffers
contrib/reset-cnfs.c Reset the state parts of a CNFS buffer
contrib/respool.c Respool articles in the storage manager
Property changes on: trunk/contrib
___________________________________________________________________
Modified: svn:ignore
- .libs
archivegz
auth_pass
backlogstat
cleannewsgroups
delayer
expirectl
findreadgroups
makeexpctl
makestorconf
mlockfile
newsresp
pullart
reset-cnfs
respool
stathist
thdexpire
tunefeed
+ .libs
archivegz
auth_pass
backlogstat
cleannewsgroups
delayer
expirectl
findreadgroups
makeexpctl
makestorconf
mlockfile
newsresp
nnrp.access2readers.conf
pullart
reset-cnfs
respool
stathist
thdexpire
tunefeed
Modified: contrib/Makefile
===================================================================
--- contrib/Makefile 2014-12-14 20:53:16 UTC (rev 9769)
+++ contrib/Makefile 2014-12-14 20:55:09 UTC (rev 9770)
@@ -12,7 +12,8 @@
ALL = archivegz auth_pass backlogstat cleannewsgroups \
delayer expirectl \
findreadgroups makeexpctl makestorconf mlockfile newsresp \
- pullart reset-cnfs respool stathist thdexpire \
+ nnrp.access2readers.conf pullart reset-cnfs respool \
+ stathist thdexpire \
tunefeed
all: $(ALL)
@@ -51,6 +52,7 @@
findreadgroups: findreadgroups.in $(FIX) ; $(FIX) findreadgroups.in
makeexpctl: makeexpctl.in $(FIX) ; $(FIX) makeexpctl.in
makestorconf: makestorconf.in $(FIX) ; $(FIX) makestorconf.in
+nnrp.access2readers.conf: nnrp.access2readers.conf.in $(FIX) ; $(FIX) -i nnrp.access2readers.conf.in
stathist: stathist.in $(FIX) ; $(FIX) -i stathist.in
thdexpire: thdexpire.in $(FIX) ; $(FIX) thdexpire.in
tunefeed: tunefeed.in $(FIX) ; $(FIX) -i tunefeed.in
Modified: contrib/README
===================================================================
--- contrib/README 2014-12-14 20:53:16 UTC (rev 9769)
+++ contrib/README 2014-12-14 20:55:09 UTC (rev 9770)
@@ -129,6 +129,11 @@
times. Can check the round-trip time and the history lookup time.
See the comments at the beginning of the source for more details.
+nnrp.access2readers.conf
+
+ Converts an old-style nnrp.access file to readers.conf format.
+ (readers.conf replaced nnrp.access, starting with INN 2.3.0.)
+
pullart
Attempts to pull news articles out of CNFS cycbuffs. Useful for
Added: contrib/nnrp.access2readers.conf.in
===================================================================
--- contrib/nnrp.access2readers.conf.in (rev 0)
+++ contrib/nnrp.access2readers.conf.in 2014-12-14 20:55:09 UTC (rev 9770)
@@ -0,0 +1,143 @@
+#! /usr/bin/perl -w
+
+## $Id$
+##
+## Convert an old-style nnrp.access file to readers.conf format.
+## (readers.conf replaced nnrp.access, starting with INN 2.3.0.)
+##
+## Written by Jeffrey M. Vinocur <jeff at litech.org>.
+##
+## This work is hereby placed in the public domain by its author.
+
+use strict;
+
+my ($src, $passwd, $dst, $debug);
+
+if (@ARGV == 1) {
+ $src = shift;
+ $passwd = 'passwd';
+ $debug = 1;
+} elsif (@ARGV == 3) {
+ ($src, $passwd, $dst) = @ARGV;
+ $debug = 0;
+} else {
+ usage();
+}
+
+my ($address, $access, $user, $pass, $groups);
+my ($noauth, $shadow);
+my %passwords;
+my @badsyntax;
+my @duplicates;
+my $OUT;
+
+open(SRC, $src) or die "Could not open $src: $!\n";
+
+if ($debug) {
+ $OUT = \*STDOUT;
+} else {
+ open(DST, ">$dst") or die "Could not open $dst: $!\n";
+ $OUT = \*DST;
+}
+
+while (<SRC>) {
+ chomp;
+ # Keep comments and blank lines.
+ if (/^\s*$/) {
+ print $OUT "\n";
+ next;
+ }
+ if (/(\#.*)/) {
+ print $OUT "$1\n";
+ }
+ s/\s*\#.*//;
+ next if /^$/;
+
+ # TODO - The following syntax is currently not recognized:
+ # host:/path/to/another/file
+ # %DEFINE0:bar.*
+ # bar.foo.net:RP:::%0
+ ($address, $access, $user, $pass, $groups) = split /:/;
+ unless (defined $groups) {
+ push (@badsyntax, $.);
+ next;
+ }
+
+ # If there is whitespace in user/pass, access is disabled.
+ $noauth = ($user =~ /\s/ or $pass =~ /\s/) ? 1 : 0;
+
+ # If user is '+', then authentication is against /etc/shadow.
+ $shadow = ($user eq '+') ? 1 : 0;
+
+ $user = '' if ($noauth or $shadow);
+
+ # Only keep R, P, N, and L for the access rights.
+ $access =~ s/[^RPNL]//g;
+
+ unless ($user eq '') {
+ push (@duplicates, $.) if defined ($passwords{$user});
+ $passwords{$user} = $pass;
+ }
+
+ print $OUT "auth \"$address\" {\n";
+ print $OUT " hosts: \"$address\"\n";
+ print $OUT " key: \"line$.\"\n";
+ print $OUT " auth: \"ckpasswd -f $passwd\"\n" unless $user eq '';
+ print $OUT " auth: \"ckpasswd -s\"\n" if $shadow;
+ print $OUT "}\n";
+ print $OUT "access \"$address\" {\n";
+ print $OUT " key: \"line$.\"\n";
+ print $OUT " newsgroups: \"$groups\"\n";
+ print $OUT " access: \"$access\"\n";
+ print $OUT " users: \"$user\"\n" unless $user eq '';
+ print $OUT " reject_with: \"Access disabled.\"\n" if $noauth;
+ print $OUT "}\n\n";
+
+}
+close SRC;
+
+srand($$^time);
+
+if (!$debug) {
+ close $OUT;
+ open(PASSWD, ">$passwd") or die "Could not open $passwd: $!\n";
+ $OUT = \*PASSWD;
+}
+while (my ($user, $pass) = each %passwords) {
+ $pass = crypt($pass, seedchar().seedchar());
+ print $OUT "$user:$pass\n";
+}
+close PASSWD unless $debug;
+
+print STDERR "\nHad trouble with syntax on line",
+ @badsyntax > 1 ? 's ' : ' ',
+ join(", ", @badsyntax), ".\n"
+ if @badsyntax;
+
+print STDERR "\nFound username duplication on line",
+ @duplicates > 1 ? 's ' : ' ',
+ join(", ", @duplicates), ".\n"
+ if @duplicates;
+
+
+sub seedchar { # From Randal Schwarz.
+ ('a'..'z','A'..'Z','0'..'9','.','/')[rand(64)];
+}
+
+sub usage {
+ print STDERR << "__END__";
+Usage:
+
+$0 <nnrp.access file> [<passwd file> <readers.conf file>]
+
+Use $0 to convert an old-style nnrp.access file to readers.conf format.
+All unique user/password pairs from the nnrp.access file are placed in
+the passwd file (in format suitable for ckpasswd).
+
+If the second and third arguments are missing, everything is printed
+instead to stdout for examination purposes.
+
+__END__
+
+exit 1;
+}
Property changes on: trunk/contrib/nnrp.access2readers.conf.in
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: support/mkmanifest
===================================================================
--- support/mkmanifest 2014-12-14 20:53:16 UTC (rev 9769)
+++ support/mkmanifest 2014-12-14 20:55:09 UTC (rev 9770)
@@ -122,6 +122,7 @@
contrib/makestorconf
contrib/mlockfile
contrib/newsresp
+contrib/nnrp.access2readers.conf
contrib/pullart
contrib/reset-cnfs
contrib/respool
More information about the inn-committers
mailing list