🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #84205

Re: Mail-to-News

#84205
From: Julien ÉLIE
Date: Mon, 18 Jul 2011 18:43
121 lines
5641 bytes
Hi Dennis,

> "postnews 0.5.3" script seems to rely on readermode.  Many others
> rely on a working version of inews.  As does the mailpost perl
> script that comes with INN-2.5.2.  Are you suggesting that the
> mailpost perl script be extended to use "ihave" where using inews is
> not applicable?

I would tend to think that inews itself should use IHAVE (if available) 
when POST cannot be used.  It is the whole point of the NNTP protocol as 
described in RFC 3977 and implemented in current versions of innd & nnrpd.
inews should comply with RFC 3977, that is to say it should use 
CAPABILITIES and select the right command to invoke (IHAVE, POST, 
eventually MODE READER).

Of course, it would be the same for rnews.

With news servers like INN 2.4 that predate RFC 3977, the behaviour 
would remain the same as currently (or maybe try both IHAVE and POST 
when one of them is not available).


No changes in scripts like mailpost.



> The problem, as I indicated, seems due to file locking being system
> specific.  I suspect most INN development is done on Linux, which
> seems to have both fnctl(2) and flock(2) and the corresponding
> perl functions.
>
> The *BSD systems, OpenBSD at least, have flock(2) but not fnctl(2).
> Solarix has fnctl(2) but *not* flock(2), other than in the SunOS/BSD
> Compatibility Library Functions, which aren't really usable for
> me.  This is a potential problem when installing INN on Solaris as
> several of the perl scripts use the flock perl function.  Including
> the mailpost script which I want to use.

All right.  Thanks for the explanation.



> So I first thought to switch the file locking in mailpost to use
> the shlock program that comes with INN.  However I decided against
> this as the LockFile-Simple module seems more versatile as well as
> system-independent.

However, it adds a dependency on an external Perl module that is not 
necessarily available on the system.

Why isn't shlock versatile enough?
We already have an example of working implementation in controlchan:


shlock($lockfile);
# Do what you want.
unlink $lockfile;


sub shlock {
     my $lockfile = shift;

     my $locktry = 0;
     while ($locktry < 60) {
         if (system("$INN::Config::newsbin/shlock",
                    '-p', $$, '-f', $lockfile) == 0) {
             return 1;
         }
         $locktry++;
         sleep 2;
     }

     my $lockreason;
     if (open(LOCKFILE, $lockfile)) {
         $lockreason = 'held by ' . (<LOCKFILE> || '?');
         close LOCKFILE;
     } else {
         $lockreason = $!;
     }
     logdie("Cannot get lock $lockfile: $lockreason");
     return undef;
}



> So I installed the LockFile-Simple perl module and modified the code
> of mailpost to use this module if it's available.  Now everything is
> working as expected.  The pullnews and signcontrol perl scripts that
> come with INN also use flock; I suppose I should also look at these
> scripts.

No need to touch signcontrol before having decided on the future of this 
script:
   http://inn.eyrie.org/trac/ticket/14

pullnews could indeed make use of another function than flock.

I am glad to read that everything works as expected with your change. 
Thanks.  They will be shipped with INN 2.5.3 (probably with shlock, that 
seems more straight-forward to use for users — no need to install an 
external Perl module).



> !     $lockmgr = LockFile::Simple->make (-format =>  '%f.lock',
> !         -max =>  5, -delay =>  1);
> !     $lockmgr->lock ($Database) || mailArtAndDie ("can't lock $Database");
[…]
> ! $lockmgr->unlock ($Database) || mailArtAndDie ("can't unlock
> $Database");

That indeed requires less lines than a call to shlock.
Yet, I am still unconvinced compared to a similar use of shlock…
Anyway, thanks for the suggestion of change and, above all, your bug 
report and patch proposal.

-- 
Julien ÉLIE

« Les horizontales se rencontrent dans tous les milieux, les
   parallèles jamais. » (Alphonse Allais)
Technical Details
Message-ID: <j01usk$v8r$1@news.trigofacile.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.20141118.mbox.gz!num2.nntp.dca.giganews.com!num1.nntp.dca.giganews.com!number.nntp.dca.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!goblin2!goblin3!goblin.stu.neva.ru!news.matabio.net!jeffrey.matabio.net!news.trigofacile.com!.POSTED.aaubervilliers-552-1-98-96.w83-199.abo.wanadoo.fr!not-for-mail
References: <iuaorh$gbt$1@n102.xanadu-bbs.net> <iufpeq$qgh$1@n102.xanadu-bbs.net> <LnLzu6.6IE.B.larch@bath.ac.uk> <ivvjd7$c15$1@news.trigofacile.com> <LoJ8po.KpC.B.larch@bath.ac.uk>

Show Full Headers
Complete Article Headers
Message-ID: <j01usk$v8r$1@news.trigofacile.com>
Subject: Re: Mail-to-News
Date: Mon, 18 Jul 2011 20:43:32 +0200
From: Julien ÉLIE <iulius@nom-de-mon-site.com.invalid>
References: <iuaorh$gbt$1@n102.xanadu-bbs.net> <iufpeq$qgh$1@n102.xanadu-bbs.net> <LnLzu6.6IE.B.larch@bath.ac.uk> <ivvjd7$c15$1@news.trigofacile.com> <LoJ8po.KpC.B.larch@bath.ac.uk>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!num2.nntp.dca.giganews.com!num1.nntp.dca.giganews.com!number.nntp.dca.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!goblin2!goblin3!goblin.stu.neva.ru!news.matabio.net!jeffrey.matabio.net!news.trigofacile.com!.POSTED.aaubervilliers-552-1-98-96.w83-199.abo.wanadoo.fr!not-for-mail
Newsgroups: news.software.nntp
Organization: TrigoFACILE -- http://www.trigofacile.com/
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 18 Jul 2011 18:43:32 +0000 (UTC)
Injection-Info: news.trigofacile.com;
 posting-host="aaubervilliers-552-1-98-96.w83-199.abo.wanadoo.fr:83.199.209.96";
 logging-data="32027"; mail-complaints-to="abuse@trigofacile.com"
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; fr; rv:1.9.2.13)
 Gecko/20101207 Thunderbird/3.1.7
In-Reply-To: <LoJ8po.KpC.B.larch@bath.ac.uk>
Lines: 120