Send inn-committers mailing list submissions to inn-committers@lists.isc.org
To subscribe or unsubscribe via the World Wide Web, visit https://lists.isc.org/mailman/listinfo/inn-committers or, via email, send a message with subject or body 'help' to inn-committers-requ...@lists.isc.org You can reach the person managing the list at inn-committers-ow...@lists.isc.org When replying, please edit your Subject line so it is more specific than "Re: Contents of inn-committers digest..." Today's Topics: 1. INN commit: branches/2.5 (4 files) (INN Commit) 2. INN commit: branches/2.5/frontends (pullnews.in) (INN Commit) ---------------------------------------------------------------------- Message: 1 Date: Mon, 8 Jul 2013 12:28:15 -0700 (PDT) From: INN Commit <r...@isc.org> To: inn-committ...@isc.org Subject: INN commit: branches/2.5 (4 files) Message-ID: <20130708192815.960d867...@hope.eyrie.org> Date: Monday, July 8, 2013 @ 12:28:15 Author: iulius Revision: 9504 pullnews: looks for the config file in the running user's home directory After commits [9304] and [9330], INN 2.5.3 broke the legacy behaviour of pullnews looking for its configuration file in the running user's home directory. Adding INN::Config changed the $HOME environment variable to the news user's home directory (in fact the pathnews parameter set in inn.conf). Besides, pullnews was no longer useable outside INN. Fixed these issues by: - making INN::Config and INN::Utils::Shlock optional. If these Perl modules are not present, pullnews falls back to its legacy handle of locks (that is unfortunately broken in Solaris); - setting the home directory to the one of the running user. Thanks to Tony Evans for the bug report. Modified: branches/2.5/CONTRIBUTORS branches/2.5/doc/pod/news.pod branches/2.5/doc/pod/pullnews.pod branches/2.5/frontends/pullnews.in -----------------------+ CONTRIBUTORS | 2 - doc/pod/news.pod | 8 ++++++ doc/pod/pullnews.pod | 5 +-- frontends/pullnews.in | 64 ++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 65 insertions(+), 14 deletions(-) Modified: CONTRIBUTORS =================================================================== --- CONTRIBUTORS 2013-07-03 20:08:03 UTC (rev 9503) +++ CONTRIBUTORS 2013-07-08 19:28:15 UTC (rev 9504) @@ -275,4 +275,4 @@ Lars Magne Ingebrigtsen, Sam Varshavchik, Matthew Vernon, Ian Jackson, Edmund H. Ramm, Raphael Barrois, Bo Lindbergh, Matthias Meyser, Dennis Preiser, Paolo Amoroso, Dennis Davis, River Tarnell, Jochen Schmitt, -Tim Fardell, Remco Rijnders, David Binderman +Tim Fardell, Remco Rijnders, David Binderman, Tony Evans Modified: doc/pod/news.pod =================================================================== --- doc/pod/news.pod 2013-07-03 20:08:03 UTC (rev 9503) +++ doc/pod/news.pod 2013-07-08 19:28:15 UTC (rev 9504) @@ -39,6 +39,14 @@ =item * +Fixed a regression that occurred in S<INN 2.5.3> regarding the path used +by default by B<pullnews> for its configuration file. Instead of looking +in the running user's home directory, it was looking in the I<pathnews> +directory parametered in F<inn.conf>. Thanks to Tony Evans for the +bug report. + +=item * + Fixed a Perl warning in B<inncheck>; using C<defined(@array)> has been deprecated since S<Perl 5.16>. Modified: doc/pod/pullnews.pod =================================================================== --- doc/pod/pullnews.pod 2013-07-03 20:08:03 UTC (rev 9503) +++ doc/pod/pullnews.pod 2013-07-08 19:28:15 UTC (rev 9504) @@ -267,10 +267,9 @@ The Perl script itself used to pull news from upstream servers and feed it to another news server. -=item I<$HOME>/.pullnews +=item ~/.pullnews -The default config file. It is in the running user's home directory -(normally called F<~/.pullnews>). +The default config file. It is in the running user's home directory. =back Modified: frontends/pullnews.in =================================================================== --- frontends/pullnews.in 2013-07-03 20:08:03 UTC (rev 9503) +++ frontends/pullnews.in 2013-07-08 19:28:15 UTC (rev 9504) @@ -1,6 +1,7 @@ #! /usr/bin/perl -w -# fixscript will replace this line with code to load INN::Config -# +# use lib '@LIBPERLDIR@'; use INN::Config; +# If running inside INN, uncomment the above and point to INN::Config. +# # Author: James Brister <bris...@vix.com> -- berkeley-unix -- # Start Date: Sat, 10 Oct 1998 21:40:11 +0200 # Project: INN @@ -22,7 +23,7 @@ # machines (in the guise of a reader), and pulls over articles # and feeds them to a downstream server (in the guise of a feeder). # -# Uses a simple configuration file: $HOME/.pullnews to define +# Uses a simple configuration file: ~/.pullnews to define # which machines to pull articles from and which groups at each # machine to pull over. There is also support for more specific # configurations like cross-posted newsgroups to kill, thanks to @@ -63,11 +64,10 @@ use Getopt::Std; use IO::Handle; use POSIX qw(ceil floor); -use INN::Utils::Shlock; use strict; my $usage = $0; -my $defaultConfig = "$ENV{HOME}/.pullnews"; +my $defaultConfig = (getpwuid($<))[7] . "/.pullnews"; my $defaultPort = 119; my $defaultHost = "localhost"; my $defaultCheckPoint = 0; @@ -76,10 +76,34 @@ my $defaultRetryTime = 1; my $defaultProgressWidth = 50; my $defaultMaxArts; +my $lockfile; +# Check whether pullnews is run inside INN. +my $use_inn_shlock = 0; +eval { + require INN::Utils::Shlock; + import INN::Utils::Shlock; + $use_inn_shlock = 1; +}; + +# In case pullnews is run outside INN, fall back to call flock(2) +# and its corresponding Perl function instead of shlock (a program +# shipped with INN). +# Note that this Perl function does not work as expected on all +# existing systems (for instance on Solaris). +if (not $use_inn_shlock) { + use Fcntl; + use Fcntl qw(:flock); +} + END { # In case we bail out, while holding a lock. - INN::Utils::Shlock::releaselocks(); + if ($use_inn_shlock) { + INN::Utils::Shlock::releaselocks(); + } elsif (defined $lockfile) { + flock (LOCK, LOCK_UN); + unlink $lockfile; + } } $usage =~ s!.*/!!; @@ -97,7 +121,7 @@ the server. The default is to do nothing. -c config specify the configuration file instead of the - default of $ENV{HOME}/.pullnews (also called ~/.pullnews). + default of ~/.pullnews (in the running user's home directory). -C width use width characters for progress (default is $defaultProgressWidth). @@ -277,11 +301,26 @@ my $oldfh = select; $| = 1; select LOG; $| = 1; select $oldfh; -my $lockfile = $groupFile . '.pid'; +$lockfile = $groupFile . '.pid'; # Acquire a lock. -INN::Utils::Shlock::lock($lockfile) or die "cannot create lockfile $lockfile\n"; +if ($use_inn_shlock) { + INN::Utils::Shlock::lock($lockfile) or die "cannot create lockfile $lockfile\n"; +} else { + sysopen (LOCK, "$lockfile", O_RDWR | O_CREAT, 0700) + or die "cannot create lockfile $lockfile: $!\n"; + $oldfh = select; select LOCK; $| = 1; select $oldfh; + if (!flock (LOCK, LOCK_EX | LOCK_NB)) { + seek LOCK, 0, 0; + my $otherpid = <LOCK>; + chomp $otherpid; + die "Another pullnews (pid: $otherpid) seems to be running.\n"; + } + + print LOCK "$$\n"; +} + print LOG scalar(localtime(time)), " start\n\n" unless $quiet; if (@groupsToGet && ! $quiet) { @@ -541,7 +580,12 @@ sub cleanLock { # Unlock. - INN::Utils::Shlock::unlock($lockfile) if defined $lockfile; + if ($use_inn_shlock) { + INN::Utils::Shlock::unlock($lockfile) if defined $lockfile; + } else { + flock (LOCK, LOCK_UN); + unlink $lockfile if defined $lockfile; + } } sub bail { ------------------------------ Message: 2 Date: Mon, 8 Jul 2013 12:30:33 -0700 (PDT) From: INN Commit <r...@isc.org> To: inn-committ...@isc.org Subject: INN commit: branches/2.5/frontends (pullnews.in) Message-ID: <20130708193033.b423b67...@hope.eyrie.org> Date: Monday, July 8, 2013 @ 12:30:33 Author: iulius Revision: 9505 pullnews: fixed a Perl warning Latest Perl versions catch this use of uninitialized variable. Thanks to Tony Evans for the bug report. Modified: branches/2.5/frontends/pullnews.in -------------+ pullnews.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Modified: pullnews.in =================================================================== --- pullnews.in 2013-07-08 19:28:15 UTC (rev 9504) +++ pullnews.in 2013-07-08 19:30:33 UTC (rev 9505) @@ -233,7 +233,7 @@ my $no_op = $opt_n || 0; my $reader = $opt_R || 0; my $quietness = $opt_Q || 0; -my $skip_headers = lc($opt_H) || ''; +my $skip_headers = defined $opt_H ? lc($opt_H) : ''; my $logFile = '>&STDOUT'; $logFile = ">>$opt_l" if $opt_l; my @hdr_to_match = split(/\s+/, $opt_m) if defined $opt_m; ------------------------------ _______________________________________________ inn-committers mailing list inn-committers@lists.isc.org https://lists.isc.org/mailman/listinfo/inn-committers End of inn-committers Digest, Vol 53, Issue 4 *********************************************