Thread View: news.software.nntp
19 messages
19 total messages
Started by John F. Morse
Mon, 27 Jun 2011 20:23
Mail-to-News
Author: John F. Morse
Date: Mon, 27 Jun 2011 20:23
Date: Mon, 27 Jun 2011 20:23
35 lines
2370 bytes
2370 bytes
I receive e-mail from a few mailing lists that I'd like to automatically post into local newsgroups. There seems to be several mail-to-news programs (or scripts) available, such as: Gmane mail-to-news scripts mail2news mailpost pyg The Gmane scripts are available as a tarball. The mail2news is available as a gdebi (APT) and rpm package. The mailpost Perl script is included with INN. Only the pyg package is available in the Debian APT repositories. The INN servers available are 2.4.5 on Debian Lenny, and 2.5.2 on Debian Squeeze. Each runs the standard Debian MTA default of Exim4. There are other MTAs available for receiving e-mail from the WAN, using Postfix under Debian, and SIMS under Mac OS 9.0.4. They could relay or mirror incoming mail. Or the incoming mail for the mail-to-news application could be routed to that mail-to-news client. Anyone having experience with the above mail-to-news programs and scripts, who could assist me in selecting the software, configuration, etc.? TIA. -- John When a person has -- whether they knew it or not -- already rejected the Truth, by what means do they discern a lie?
Re: Mail-to-News
Author: Steve Crook
Date: Tue, 28 Jun 2011 08:28
Date: Tue, 28 Jun 2011 08:28
21 lines
1706 bytes
1706 bytes
On Mon, 27 Jun 2011 15:23:13 -0500, John F. Morse wrote in Message-Id: <iuaorh$gbt$1@n102.xanadu-bbs.net>: > Anyone having experience with the above mail-to-news programs and > scripts, who could assist me in selecting the software, configuration, etc.? Hi John, you might also want to consider: http://www.banana.mixmin.net/svn/mail2news/ I wrote this as a public mail2news gateway but also use it for posting various mailing lists to local.* newsgroups via procmail. For example: FORMAIL=/usr/bin/formail :0fw * ^List-Id: .*<inn-announce.lists.isc.org> | $FORMAIL -a "Newsgroups: local.lists.inn.announce" :0 * ^Newsgroups: ! mail2news@m2n.mixmin.net
Re: Mail-to-News
Author: John F. Morse
Date: Tue, 28 Jun 2011 19:49
Date: Tue, 28 Jun 2011 19:49
36 lines
2226 bytes
2226 bytes
Steve Crook wrote: > On Mon, 27 Jun 2011 15:23:13 -0500, John F. Morse wrote in > Message-Id: <iuaorh$gbt$1@n102.xanadu-bbs.net>: > > >> Anyone having experience with the above mail-to-news programs and >> scripts, who could assist me in selecting the software, configuration, etc.? >> > > Hi John, you might also want to consider: > http://www.banana.mixmin.net/svn/mail2news/ > > I wrote this as a public mail2news gateway but also use it for posting > various mailing lists to local.* newsgroups via procmail. For example: > > FORMAIL=/usr/bin/formail > > :0fw > * ^List-Id: .*<inn-announce.lists.isc.org> > | $FORMAIL -a "Newsgroups: local.lists.inn.announce" > > :0 > * ^Newsgroups: > ! mail2news@m2n.mixmin.net > Thanks Steve. I'll check it out. -- John When a person has -- whether they knew it or not -- already rejected the Truth, by what means do they discern a lie?
Re: Mail-to-News
Author: Dennis Davis
Date: Wed, 29 Jun 2011 13:45
Date: Wed, 29 Jun 2011 13:45
38 lines
2327 bytes
2327 bytes
In the referenced article, dont.bother writes: >I receive e-mail from a few mailing lists that I'd like to >automatically post into local newsgroups. > >There seems to be several mail-to-news programs (or scripts) >available, such as: > >Gmane mail-to-news scripts mail2news mailpost pyg > >The Gmane scripts are available as a tarball. The mail2news is >available as a gdebi (APT) and rpm package. The mailpost Perl >script is included with INN. Only the pyg package is available in >the Debian APT repositories. > >The INN servers available are 2.4.5 on Debian Lenny, and 2.5.2 on >Debian Squeeze. > >Each runs the standard Debian MTA default of Exim4. > >There are other MTAs available for receiving e-mail from the WAN, >using Postfix under Debian, and SIMS under Mac OS 9.0.4. They >could relay or mirror incoming mail. Or the incoming mail for the >mail-to-news application could be routed to that mail-to-news >client. > >Anyone having experience with the above mail-to-news programs >and scripts, who could assist me in selecting the software, >configuration, etc.? I've just got this working here with INN. We're currently running exim4 + Cnews + mail2news (from newsgate.tar.Z) on a Solaris/sparc platform. We intend to replace this with a newer Solaris/i386 box running INN-2.5.2 + exim4. I decided to go with the above mail2news routine as I'm familiar with it and, being lazy, I could just copy over the exim4 configuration I was using. -- Dennis Davis, BUCS, University of Bath, Bath, BA2 7AY, UK D.H.Davis@bath.ac.uk
Re: Mail-to-News
Author: John F. Morse
Date: Wed, 29 Jun 2011 18:04
Date: Wed, 29 Jun 2011 18:04
123 lines
5783 bytes
5783 bytes
Hi Dennis, > In the referenced article, dont.bother writes: > >> I receive e-mail from a few mailing lists that I'd like to >> automatically post into local newsgroups. >> >> There seems to be several mail-to-news programs (or scripts) >> available, such as: >> >> Gmane mail-to-news scripts mail2news mailpost pyg >> >> The Gmane scripts are available as a tarball. The mail2news is >> available as a gdebi (APT) and rpm package. The mailpost Perl >> script is included with INN. Only the pyg package is available in >> the Debian APT repositories. >> >> The INN servers available are 2.4.5 on Debian Lenny, and 2.5.2 on >> Debian Squeeze. >> >> Each runs the standard Debian MTA default of Exim4. >> >> There are other MTAs available for receiving e-mail from the WAN, >> using Postfix under Debian, and SIMS under Mac OS 9.0.4. They >> could relay or mirror incoming mail. Or the incoming mail for the >> mail-to-news application could be routed to that mail-to-news >> client. >> >> Anyone having experience with the above mail-to-news programs >> and scripts, who could assist me in selecting the software, >> configuration, etc.? >> > > I've just got this working here with INN. We're currently running > exim4 + Cnews + mail2news (from newsgate.tar.Z) on a Solaris/sparc > platform. We intend to replace this with a newer Solaris/i386 box > running INN-2.5.2 + exim4. I decided to go with the above mail2news > routine as I'm familiar with it and, being lazy, I could just copy > over the exim4 configuration I was using. > I played with this for quite awhile yesterday (and today) and never got it to work. I'm not sure I understand the principles behind the whole operation. Here's what I believe must happen (please make all the corrections you find in my flawed assumptions): E-mail from a mailing list comes in to my domain MTA (SIMS on a PowerMac). I must route (forward) it to the INN server (a different computer than the domain MTA). The INN server is running Exim4 version 4.69-9+lenny4. From what I've read, the INN server box needs an entry in /etc/aliases and I have entered: larryslist: "| /usr/lib/news/bin/mailpost -b /var/tmp ARRL.Div.Midwest.KS.LarrysList" When that failed, I reduced it to: larryslist: "| /usr/lib/news/bin/mailpost ARRL.Div.Midwest.KS.LarrysList" The newsgroup was created and is shown below on yesterday's Daily Usenet Report: Newsgroups created: Group Mode ARRL.Div.Midwest.KS.LarrysList m TOTAL 1 Today I changed the group mode to "y" for testing, so I wouldn't be stumped by a moderator issue. I am guessing the /etc/aliases entry will take anything addressed to "larryslist" and pipe it into mailpost, which basically triggers the mailpost script into processing the message. As mentioned, so far it isn't working. Nothing has been posted to that group. I know very little about Exim4. It is a default MTA installed with Sarge, Lenny, Squeeze, ... and has always "just worked" as far as I can remember. After further testing, I may have a problem with my main MTA routing. Plus DNS issues with testing on the same LAN that contains the main MTA and the INN box. So I tried bypassing those possible problem and sent e-mail to "larryslist" using mailx on the INN computer itself. This resulted in the following from a tail of /var/log/exim4/mainlog : 2011-06-29 12:33:00 1QbydI-0001Mk-AA <= john@optima11.my.net U=john P=local S=456 2011-06-29 12:33:01 1QbydI-0001Mk-AA == |/usr/lib/news/bin/mailpost ARRL.Div.Midwest.KS.LarrysList <larryslist@optima11.my.net> R=system_aliases defer (-30): pipe_transport unset in system_aliases router I put the original /etc/aliases entry back and got the same failure: 2011-06-29 12:45:45 1Qbypd-0001PK-2V <= john@optima11.my.net U=john P=local S=420 2011-06-29 12:45:45 1Qbypd-0001PK-2V == | /usr/lib/news/bin/mailpost -b /var/tmp ARRL.Div.Midwest.KS.LarrysList <larryslist@optima11.my.net> R=system_aliases defer (-30): pipe_transport unset in system_aliases router Two terms there that I'm not familiar with, "pipe_transport" and "system_aliases router" and I cannot find anything defining them. Anything you (or anyone) can offer will be greatly appreciated. TIA. -- John When a person has -- whether they knew it or not -- already rejected the Truth, by what means do they discern a lie?
Re: Mail-to-News
Author: Dennis Davis
Date: Thu, 30 Jun 2011 15:18
Date: Thu, 30 Jun 2011 15:18
205 lines
8322 bytes
8322 bytes
In the referenced article, dont.bother writes:
...
>I'm not sure I understand the principles behind the whole
>operation. Here's what I believe must happen (please make all the
>corrections you find in my flawed assumptions):
>
>E-mail from a mailing list comes in to my domain MTA (SIMS on a
>PowerMac).
>
>I must route (forward) it to the INN server (a different computer
>than the domain MTA).
That's right. The INN machine then recognises these re-routed
addresses as "special" and delivers them to the appropriate Newsgroup.
>The INN server is running Exim4 version 4.69-9+lenny4.
I'm not at all familar with the Debian installation of exim. I
believe the Debian exim configuation file is somewhat fragmented.
Enough that there's a separate mailing list for exim issues on
Debian. However at the level we're talking it doesn't matter.
> From what I've read, the INN server box needs an entry in
>/etc/aliases and I have entered:
>
>larryslist: "| /usr/lib/news/bin/mailpost -b /var/tmp
>ARRL.Div.Midwest.KS.LarrysList"
I do things slightly differently, but that's certainly appropriate.
>When that failed, I reduced it to:
>
>larryslist: "| /usr/lib/news/bin/mailpost ARRL.Div.Midwest.KS.LarrysList"
No. you probably need the "-b /var/tmp" as the exim processes and
INN processes may be running under different usernames.
>The newsgroup was created and is shown below on yesterday's Daily Usenet
>Report:
>
>Newsgroups created:
>Group Mode
>ARRL.Div.Midwest.KS.LarrysList m
>
>TOTAL 1
>
>
>Today I changed the group mode to "y" for testing, so I wouldn't be
>stumped by a moderator issue.
Use the "-a {address}" argument to mailpost to get round moderator
issues.
>I am guessing the /etc/aliases entry will take anything addressed to
>"larryslist" and pipe it into mailpost, which basically triggers the
>mailpost script into processing the message.
That sounds OK. But you'll need to tweak the exim configuration
to get it to do so. Or so it seems from the error messages you
describe later.
>As mentioned, so far it isn't working. Nothing has been posted to
>that group.
>
>I know very little about Exim4. It is a default MTA installed with
>Sarge, Lenny, Squeeze, ... and has always "just worked" as far as I
>can remember.
You're trying do do something a little out of the ordinary. So the
default configuration might not be up to this. A crash course in
exim might be required :-(
>After further testing, I may have a problem with my main MTA routing.
>Plus DNS issues with testing on the same LAN that contains the main MTA
>and the INN box.
>
>So I tried bypassing those possible problem and sent e-mail to
>"larryslist" using mailx on the INN computer itself. This resulted in
>the following from a tail of /var/log/exim4/mainlog :
>
>2011-06-29 12:33:00 1QbydI-0001Mk-AA <= john@optima11.my.net U=john
>P=local S=456
>2011-06-29 12:33:01 1QbydI-0001Mk-AA == |/usr/lib/news/bin/mailpost
>ARRL.Div.Midwest.KS.LarrysList <larryslist@optima11.my.net>
>R=system_aliases defer (-30): pipe_transport unset in system_aliases router
>
>I put the original /etc/aliases entry back and got the same failure:
>
>2011-06-29 12:45:45 1Qbypd-0001PK-2V <= john@optima11.my.net U=john
>P=local S=420
>2011-06-29 12:45:45 1Qbypd-0001PK-2V == | /usr/lib/news/bin/mailpost -b
>/var/tmp ARRL.Div.Midwest.KS.LarrysList <larryslist@optima11.my.net>
>R=system_aliases defer (-30): pipe_transport unset in system_aliases router
>
>Two terms there that I'm not familiar with, "pipe_transport" and
>"system_aliases router" and I cannot find anything defining them.
>
>Anything you (or anyone) can offer will be greatly appreciated.
See:
http://www.exim.org/exim-html-current/doc/html/spec_html/ch22.html
right close to the top of the page you'll see:
system_aliases:
driver = redirect
data = ${lookup{$local_part}lsearch{/etc/aliases}}
You'll have something like this is your exim configuration file.
This'll be the "system_aliases router" that's interpreting your
alias file.
Later on in the above page you'll see a comment:
An item is treated as a pipe command if it begins with | and
does not parse as a valid RFC 2822 address that includes a
domain. A transport for running the command must be specified by
the pipe_transport option. Normally, either the router or the
transport specifies a user and a group under which to run the
delivery. The default is to use the Exim user and group.
The error message is complaining that you've used | (pipe) in your
aliases file but haven't specified an exim transport to handle these
deliveries. Note that you'll probably want to specify the "news"
user and group to run the delivery.
The default, example configuration file that comes with the source
of exim, eg exim-4.76/src/configure.default is well-commented and
contains good examples of the above. It might be worth you getting a
copy and looking through it. It may well contain the bits you want.
(Apologies if this sounds a bit hazy, I set this up for our Cnews
box a few years ago and the configurations hasn't really changed
other than to move it to the INN box.)
However before doing any of the above, check that your INN setup
will allow you to post articles in the manner you require. I'm
still a bit of a newbie with this. The last time I ran INN was in
2004 with INN2.2. And I can't remember any of it :-(
However I needed to tweak my INN installation to let it post
articles to itself. Here's the steps I took, they might be a
useful checklist.
(1) Check that:
server: localhost
is set in inn.conf. The default is to have it unset. Without this
set, inews won't know how to post articles.
(2) Make sure the example entry:
#DHD#peer ME {
#DHD# hostname: "localhost, 127.0.0.1, ::1"
#DHD#}
is commented out similar to what I've done. With this entry present,
the local host can only transit articles, not post them.
(3) Ensure you have the identity:
# This assigns the identity of <localhost> to the local machine.
auth "localhost" {
key: "localhost"
hosts: "localhost, 127.0.0.1, ::1, stdin"
default: "<localhost>"
}
and auth:
# "localhost" has access to read and post to any Newsgroup and post
# articles with Approved: headers to moderated Newsgroups.
access "localhost" {
key: "localhost"
users: "<localhost>"
newsgroups: "*"
access: RPA
}
set in readers.conf. This sets up the loopback address with
permission to post articles.
You'll probably need to "ctlinnd xexec innd" to get the above to
take effect. Then you can use "inews -h" to test posting articles
in the manner that mailpost requires.
(I've tried using mailpost on Solaris and I get a failure:
can't lock /var/tmp/mailpost-msgid.lock: Bad file number
on the second article posted. The first one creates the above file
& article database. I suspect this is because mailpost uses the
flock perl command and this isn't working as expected on Solaris.
If so this should be easy to fix, just tweak the perl to use
something like the perl module LockFile-Simple-0.207. Should be
good enough. It's just finding time to do this.)
--
Dennis Davis, BUCS, University of Bath, Bath, BA2 7AY, UK
D.H.Davis@bath.ac.uk
Re: Mail-to-News
Author: Nomen Nescio
Date: Fri, 01 Jul 2011 07:23
Date: Fri, 01 Jul 2011 07:23
58 lines
2705 bytes
2705 bytes
"John F. Morse" <john@example.invalid> wrote: > I receive e-mail from a few mailing lists that I'd like to automatically > post into local newsgroups. > > There seems to be several mail-to-news programs (or scripts) available, > such as: > > Gmane mail-to-news scripts > mail2news > mailpost > pyg > > The Gmane scripts are available as a tarball. The mail2news is available > as a gdebi (APT) and rpm package. The mailpost Perl script is included > with INN. Only the pyg package is available in the Debian APT > repositories. > > The INN servers available are 2.4.5 on Debian Lenny, and 2.5.2 on Debian > Squeeze. > > Each runs the standard Debian MTA default of Exim4. > > There are other MTAs available for receiving e-mail from the WAN, using > Postfix under Debian, and SIMS under Mac OS 9.0.4. They could relay or > mirror incoming mail. Or the incoming mail for the mail-to-news > application could be routed to that mail-to-news client. > > Anyone having experience with the above mail-to-news programs and > scripts, who could assist me in selecting the software, configuration, > etc.? I use Claws mail and it has scripting options as in when a message matching some criteria is received, run this script. When other messages are received, run some other script. It's rules based and flexible. If you have leafnode or any other (somewhat) compliant news server then mail2news is trivial because the nntp protocol is very simple. I wrote my own mail2news just because it was easier for me to do and have control over it then play around with somebody else's scripts in languages I don't know. If you are a coder even if you don't code much this could be a nice little project. There are only a few commands necessary to post and the responses are also few and easy to test for.
Re: Mail-to-News
Author: Julien ÉLIE
Date: Sun, 17 Jul 2011 21:15
Date: Sun, 17 Jul 2011 21:15
62 lines
3412 bytes
3412 bytes
Hi Dennis,
> (1) Check that:
>
> server: localhost
>
> is set in inn.conf. The default is to have it unset. Without this
> set, inews won't know how to post articles.
>
> (2) Make sure the example entry:
>
> #DHD#peer ME {
> #DHD# hostname: "localhost, 127.0.0.1, ::1"
> #DHD#}
>
>
> is commented out similar to what I've done. With this entry present,
> the local host can only transit articles, not post them.
What was used to post articles?
I see that mailnews.py knows both IHAVE (transit mode) and POST (reader
mode, with MODE READER sent after connecting to the news server).
if method == 'ihave':
[…]
else:
nntplib.NNTP(host, port, readermode=True)
Unless you were using inews (POST), as it can be guessed in the comment
of (1). Then why not use rnews (IHAVE) instead? :-)
> (I've tried using mailpost on Solaris and I get a failure:
>
> can't lock /var/tmp/mailpost-msgid.lock: Bad file number
>
> on the second article posted. The first one creates the above file
> & article database. I suspect this is because mailpost uses the
> flock perl command and this isn't working as expected on Solaris.
> If so this should be easy to fix, just tweak the perl to use
> something like the perl module LockFile-Simple-0.207. Should be
> good enough. It's just finding time to do this.)
Is it linked to:
http://inn.eyrie.org/trac/ticket/81
mailpost tries to store its message ID database in INN's pathtmp,
but since it's usually running as the mail system (often daemon)
rather than as news, this fails.
or is it something totally different? What are the rights on your
/var/tmp/mailpost-msgid.lock file? (readable and writable by the user
or daemon which runs mailpost?)
--
Julien ÉLIE
« Les horizontales se rencontrent dans tous les milieux, les
parallèles jamais. » (Alphonse Allais)
Re: Mail-to-News
Author: Dennis Davis
Date: Mon, 18 Jul 2011 14:10
Date: Mon, 18 Jul 2011 14:10
280 lines
10262 bytes
10262 bytes
In the referenced article, =?windows-1252?Q?Julien_=C9LIE?=
<iulius@nom-de-mon-site.com.invalid> writes:
>
> > (1) Check that:
> >
> > server: localhost
> >
> > is set in inn.conf. The default is to have it unset. Without this
> > set, inews won't know how to post articles.
> >
> > (2) Make sure the example entry:
> >
> > #DHD#peer ME {
> > #DHD# hostname: "localhost, 127.0.0.1, ::1"
> > #DHD#}
> >
> >
> > is commented out similar to what I've done. With this entry present,
> > the local host can only transit articles, not post them.
>
> What was used to post articles?
Ultimately the s/w was using inews.
> I see that mailnews.py knows both IHAVE (transit mode) and POST (reader
> mode, with MODE READER sent after connecting to the news server).
>
> if method == 'ihave':
> [Â…]
> else:
> nntplib.NNTP(host, port, readermode=True)
>
>
> Unless you were using inews (POST), as it can be guessed in the comment
> of (1). Then why not use rnews (IHAVE) instead? :-)
The smiley -- :-) -- is duly noted. However you're suggesting that
a specific third-party package which knows about the "ihave" method
is installed to solve this problem. Not all mail-to-news packages
I've seen know about "ihave". If you're talking python, the older
"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've tried using mailpost on Solaris and I get a failure:
> >
> > can't lock /var/tmp/mailpost-msgid.lock: Bad file number
> >
> > on the second article posted. The first one creates the above file
> > & article database. I suspect this is because mailpost uses the
> > flock perl command and this isn't working as expected on Solaris.
> > If so this should be easy to fix, just tweak the perl to use
> > something like the perl module LockFile-Simple-0.207. Should be
> > good enough. It's just finding time to do this.)
>
> Is it linked to:
>
> http://inn.eyrie.org/trac/ticket/81
>
> mailpost tries to store its message ID database in INN's pathtmp,
> but since it's usually running as the mail system (often daemon)
> rather than as news, this fails.
>
> or is it something totally different? What are the rights on your
> /var/tmp/mailpost-msgid.lock file? (readable and writable by the user
> or daemon which runs mailpost?)
It isn't linked to:
http://inn.eyrie.org/trac/ticket/81
I noted the warnings about this in the documentation. I'm using
exim to inject the email articles as news. The exim transport that
does this has a couple of lines:
user = NEWS_USER
command = /bin/sh -c ${lookup{$local_part}SEARCH{MAIL2NEWS_INJECTORS}}
so the command *is* being run as the news user. This worked well
on the Cnews system and does work with INN.
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. However my older perl book includes the following
comment about fnctl:
fcntl will produce a fatal error if used on a machine that doesn't
implement fcntl(2).
It also includes the following comment about flock:
Invoking flock will produce a fatal error if used on a machine
that doesn't implement flock(2), or emulate it through some other
locking mechanism.
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.
Locking with the perl scripts that come with INN seems fairly basic,
ie it's file locking rather than locking records inside a database.
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.
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.
Patches to mailpost are given below in case they're of use to anyone
else.
*** mailpost.o Fri Jun 3 10:51:39 2011
--- mailpost Mon Jul 4 13:11:18 2011
***************
*** 35,44 ****
--- 35,51 ----
my $LOCK_NB = 4;
my $LOCK_UN = 8;
+ my $lockmgr;
+
my $usage = $0 ;
$usage =~ s!.*/!! ;
my $prog = $usage ;
+ my $use_lockfile_simple = 0;
+
+ eval { require LockFile::Simple; import LockFile::Simple;
+ $use_lockfile_simple = 1; };
+
my $use_syslog = 0;
eval { require Sys::Syslog; import Sys::Syslog; $use_syslog = 1; };
***************
*** 381,398 ****
my $lockfile = sprintf("%s.lock", $Database);
! open(LOCKFILE, "<$lockfile") ||
! open(LOCKFILE, ">$lockfile") ||
! mailArtAndDie ("can't open $lockfile: $!") ;
!
! my $i ;
! for ($i = 0 ; $i < 5 ; $i++) {
! flock(LOCKFILE, $LOCK_EX) && last ;
! sleep 1 ;
}
- mailArtAndDie ("can't lock $lockfile: $!") if ($i == 5) ;
-
my %DATABASE ;
dbmopen(%DATABASE, $Database, 0666) || mailArtAndDie ("can't dbmopen $Database: $!");
--- 388,411 ----
my $lockfile = sprintf("%s.lock", $Database);
! if ($use_lockfile_simple) {
! $lockmgr = LockFile::Simple->make (-format => '%f.lock',
! -max => 5, -delay => 1);
! $lockmgr->lock ($Database) || mailArtAndDie ("can't lock $Database");
! } else {
! open(LOCKFILE, "<$lockfile") ||
! open(LOCKFILE, ">$lockfile") ||
! mailArtAndDie ("can't open $lockfile: $!") ;
!
! my $i ;
! for ($i = 0 ; $i < 5 ; $i++) {
! flock(LOCKFILE, $LOCK_EX) && last ;
! sleep 1 ;
! }
!
! mailArtAndDie ("can't lock $lockfile: $!") if ($i == 5) ;
}
my %DATABASE ;
dbmopen(%DATABASE, $Database, 0666) || mailArtAndDie ("can't dbmopen $Database: $!");
***************
*** 416,423 ****
dbmclose(%DATABASE) || mailArtAndDie ("can't dbmclose $Database: $!") ;
! flock(LOCKFILE, $LOCK_UN) || mailArtAndDie ("can't unlock $lockfile: $!");
! close LOCKFILE ;
## For crosspost.
--- 429,440 ----
dbmclose(%DATABASE) || mailArtAndDie ("can't dbmclose $Database: $!") ;
! if ($use_lockfile_simple) {
! $lockmgr->unlock ($Database) || mailArtAndDie ("can't unlock $Database");
! } else {
! flock(LOCKFILE, $LOCK_UN) || mailArtAndDie ("can't unlock $lockfile: $!");
! close LOCKFILE ;
! }
## For crosspost.
***************
*** 442,458 ****
sleep $opt_c ;
! open(LOCKFILE, "<$lockfile") ||
! open(LOCKFILE, ">$lockfile") ||
! mailArtAndDie ("can't open $lockfile: $!") ;
- my $i ;
- for ($i = 0 ; $i < 5 ; $i++) {
- flock(LOCKFILE, $LOCK_EX) && last ;
- sleep 1 ;
- }
- mailArtAndDie ("can't lock $lockfile: $!") if ($i == 5) ;
-
my $umask_bak = umask();
umask(000);
dbmopen(%DATABASE, $Database, 0666) || mailArtAndDie ("can't dbmopen $Database: $!");
--- 459,481 ----
sleep $opt_c ;
! if ($use_lockfile_simple) {
! $lockmgr = LockFile::Simple->make (-format => '%f.lock',
! -max => 5, -delay => 1);
! $lockmgr->lock ($Database) || mailArtAndDie ("can't lock $Database");
! } else {
! open(LOCKFILE, "<$lockfile") ||
! open(LOCKFILE, ">$lockfile") ||
! mailArtAndDie ("can't open $lockfile: $!") ;
!
! my $i ;
! for ($i = 0 ; $i < 5 ; $i++) {
! flock(LOCKFILE, $LOCK_EX) && last ;
! sleep 1 ;
! }
! mailArtAndDie ("can't lock $lockfile: $!") if ($i == 5) ;
! }
my $umask_bak = umask();
umask(000);
dbmopen(%DATABASE, $Database, 0666) || mailArtAndDie ("can't dbmopen $Database: $!");
***************
*** 464,471 ****
dbmclose(%DATABASE) || mailArtAndDie ("can't dbmclose $Database: $!") ;
! flock(LOCKFILE, $LOCK_UN) || mailArtAndDie ("can't unlock $lockfile: $!");
! close LOCKFILE ;
if (defined($dup)) {
syslog("err", "mismatch $newsgroups") if $debugging && $use_syslog;
--- 487,498 ----
dbmclose(%DATABASE) || mailArtAndDie ("can't dbmclose $Database: $!") ;
! if ($use_lockfile_simple) {
! $lockmgr->unlock ($Database) || mailArtAndDie ("can't unlock $Database");
! } else {
! flock(LOCKFILE, $LOCK_UN) || mailArtAndDie ("can't unlock $lockfile: $!");
! close LOCKFILE ;
! }
if (defined($dup)) {
syslog("err", "mismatch $newsgroups") if $debugging && $use_syslog;
--
Dennis Davis, BUCS, University of Bath, Bath, BA2 7AY, UK
D.H.Davis@bath.ac.uk
Re: Mail-to-News
Author: Julien ÉLIE
Date: Mon, 18 Jul 2011 18:43
Date: Mon, 18 Jul 2011 18:43
121 lines
5641 bytes
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)
Re: Mail-to-News
Author: Dennis Davis
Date: Wed, 20 Jul 2011 10:04
Date: Wed, 20 Jul 2011 10:04
129 lines
5731 bytes
5731 bytes
In the referenced article, =?UTF-8?B?SnVsaWVuIMOJTElF?= <iulius@nom-de-mon-site.com.invalid> writes:
>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.
Documentation for inews in INN indicates that it's not suitable
for use on client machines. So these changes won't affect other
versions of inews out there. Eg the inews that comes with the
trn Newsreader and the mini-inews that's still out there somewhere.
However I don't see this as a problem. It's not likely
that a client machine won't have POST permission.
>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).
That's a judgement call. Do you want to maintain a 2.4.x branch
as well as a 2.5.x branch?
>No changes in scripts like mailpost.
Agreed.
...
>> 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 defence here is, as stated earlier in this thread:
The last time I ran INN was in 2004 with INN2.2. And I can't
remember any of it :-(
So I'm effectively starting out fresh with INN. I hadn't spotted
the shlock perl subroutine in controlchan but had been looking at
the LockFile-Simple perl module for other purposes. The use of
locking in mailpost -- try five time to get a lock, waiting a second
between each attempt -- was easy to set up with LockFile-Simple so I
went with that.
The above shlock perl routine could certainly be made versatile
enough for most puposes by adding extra parameters. Eg
"lock_attempts" and "delay" for use in mailpost.
>> 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
A compromise would be to include signcontrol and maintain it as
part of the source but not install it by default. Those that
require it would need to type:
make install signcontrol
Easy enough to explain in the INSTALL documentation.
>pullnews could indeed make use of another function than flock.
Pullnews seems to create a lockfile to ensure two copies aren't
running at once. Easily implemented using a perl routine based on
shlock.
...
>> ! $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.
Maybe, but you've still got the overhead of including the perl module.
So the total size of the perl program may still be larger
>Yet, I am still unconvinced compared to a similar use of shlock…
Me too. I suspect a suitable perl subroutine, based on shlock, and
is the way to go. The subroutine could be included in each perl
program that required it. Or, if the need for such routines grows,
form part of an INN perl module.
>Anyway, thanks for the suggestion of change and, above all, your
>bug report and patch proposal.
No problem. I'm sure I can come up with other semi-useless
suggestions :-)
--
Dennis Davis, BUCS, University of Bath, Bath, BA2 7AY, UK
D.H.Davis@bath.ac.uk
Re: Mail-to-News
Author: Julien ÉLIE
Date: Fri, 22 Jul 2011 23:01
Date: Fri, 22 Jul 2011 23:01
135 lines
6147 bytes
6147 bytes
Hi Dennis,
>> 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).
>
> Documentation for inews in INN indicates that it's not suitable
> for use on client machines. So these changes won't affect other
> versions of inews out there. Eg the inews that comes with the
> trn Newsreader and the mini-inews that's still out there somewhere.
My comment was only meant for the inews program shipped with INN.
It should be updated to take a benefit from the new commands defined
in RFC 3977.
I do not know much about the other "inews" programs in the wild.
I bet it would also be worthwhile updating them.
>> 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).
>
> That's a judgement call. Do you want to maintain a 2.4.x branch
> as well as a 2.5.x branch?
No, the 2.4.x branch is no longer maintained.
I was speaking about an updated inews program (knowing RFC 3977) that
would be used against an older news server (knowing RFC 977) like INN 2.4.
The new inews program should send CAPABILITIES, see that it is not
an available command, then probe POST, and then probe IHAVE if POST
did not work, and finally try MODE READER and probe POST again.
> The above shlock perl routine could certainly be made versatile
> enough for most puposes by adding extra parameters. Eg
> "lock_attempts" and "delay" for use in mailpost.
I have come up with a Perl module named INN::Utils::Shlock.
I hope the naming is fine.
Extract from INN::Utils::Shlock(3pm):
NAME
INN::Utils::Shlock - Wrapper around the shlock program
DESCRIPTION
This Perl module wraps the shlock(1) program so that it can easily be used. Calling
shlock is more portable than using flock(2) and its corresponding Perl function
because this function does not work as expected on all existing systems.
See the shlock(1) documentation for more information.
Using INN::Utils::Shlock is straight-forward:
use lib '<pathnews>/lib/perl';
use INN::Utils::Shlock;
my $lockfile = "myprogram.LOCK";
# Acquire a lock.
$INN::Utils::Shlock::lock($lockfile);
# Unlock.
$INN::Utils::Shlock::unlock($lockfile);
These two functions return 1 on success, 0 on failure. Therefore, the success of
(un)locking can be checked for instance as follows:
$INN::Utils::Shlock::lock($lockfile) or die "cannot create lock file";
or:
if ($INN::Utils::Shlock::lock($lockfile, 4) < 1) {
die "giving up after 4 unsuccessful attempts to create lock file";
}
INTERFACE
lock(lockfile)
Tries to create a lock file named lockfile.
lock(lockfile, retries)
Tries to create a lock file named lockfile. If it fails, locking attempts are
repeated once every 2 seconds for at most retries times.
lock(lockfile, retries, delay)
Tries to create a lock file named lockfile. If it fails, locking attempts are
repeated once every delay seconds for at most retries times.
Note that lock(lockfile) is equivalent to lock(lockfile, 0, 2).
unlock(lockfile)
Removes the file named lockfile.
Do not hesitate to make any comments you think appropriate.
(In the man page, the variables are properly written in "italics".)
This new Perl wrapper currently works pretty well.
>> No need to touch signcontrol before having decided on the future of
>> this script:
>> http://inn.eyrie.org/trac/ticket/14
>
> A compromise would be to include signcontrol and maintain it as
> part of the source but not install it by default. Those that
> require it would need to type:
>
> make install signcontrol
>
> Easy enough to explain in the INSTALL documentation.
More ideally, we should fix the per-site configuration issue of
signcontrol so that an update does not erase the customization
made by the user...
> I'm sure I can come up with other semi-useless suggestions :-)
You're welcome!
--
Julien ÉLIE
« Piscis primum a capite foetet. »
Re: Mail-to-News
Author: Julien ÉLIE
Date: Sun, 24 Jul 2011 21:44
Date: Sun, 24 Jul 2011 21:44
112 lines
4430 bytes
4430 bytes
Hi Dennis,
> 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.
Does it also affect fcntl() used in our C code (on *BSD systems)?
For instance:
innfeed/endpoint.c
-> int newfd = fcntl(fd, F_DUPFD, stdioFdMax + 1);
lib/fdflags.c
-> fcntl(fd, F_SETFD, flag ? (oflag | FD_CLOEXEC) : (oflag & ~FD_CLOEXEC));
lib/lockfile.c
-> status = fcntl(fd, block ? F_SETLKW : F_SETLK, &fl);
And for flock():
storage/buffindexed/shmem.c
-> if( flock( fd, LOCK_EX ) < 0 ) {
> Patches to mailpost are given below in case they're of use to anyone
> else.
OK, thanks. I obtain a similar patch with INN::Utils::Shlock.
> The pullnews and signcontrol perl scripts that come with INN also use
> flock; I suppose I should also look at these scripts.
Unfortunately, signcontrol does not currently use any INN variables.
(It is designed to work as a stand-alone program.)
Directly adding INN::Utils::Shlock would be weird. Maybe a solution based on your
LockFile::Simple example would be best. This time using:
eval { require INN::Utils::Shlock; import INN::Utils::Shlock;
$use_shlock = 1; };
As for pullnews:
--- frontends/pullnews.in (révision 9281)
+++ frontends/pullnews.in (copie de travail)
@@ -68,8 +68,7 @@
use Getopt::Std;
use IO::Handle;
use POSIX qw(ceil floor);
-use Fcntl;
-use Fcntl qw(:flock);
+use INN::Utils::Shlock;
use strict;
my $usage = $0;
@@ -275,23 +274,15 @@
}
open(LOG, $logFile) || die "can't open logfile ($logFile)!: $!\n";
+# Forces a flush after each write or print.
my $oldfh = select;
$| = 1; select LOG; $| = 1; select $oldfh;
my $lockfile = $groupFile . '.pid';
-sysopen (LOCK, "$lockfile", O_RDWR | O_CREAT, 0700) ||
- die "can't create lock file ($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";
-}
+# Acquire a lock.
+INN::Utils::Shlock::lock($lockfile) or die "cannot create lockfile $lockfile\n";
-print LOCK "$$\n";
-
print LOG scalar(localtime(time)), " start\n\n" unless $quiet;
if (@groupsToGet && ! $quiet) {
@@ -550,8 +541,8 @@
}
sub cleanLock {
- flock (LOCK, LOCK_UN);
- unlink $lockfile if defined $lockfile;
+ # Unlock.
+ INN::Utils::Shlock::unlock($lockfile) if defined $lockfile;
}
sub bail {
--
Julien ÉLIE
« Ce n'est pas en tournant le dos aux choses qu'on leur fait face. »
(Pierre Dac)
Re: Mail-to-News
Author: Dennis Davis
Date: Mon, 25 Jul 2011 15:15
Date: Mon, 25 Jul 2011 15:15
84 lines
3554 bytes
3554 bytes
In the referenced article, =?ISO-8859-1?Q?Julien_=C9LIE?= <iulius@nom-de-mon-site.com.invalid> writes:
>Hi Dennis,
>
>> 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.
>
>Does it also affect fcntl() used in our C code (on *BSD systems)?
Many apologies, I misled you. OpenBSD *does* have fcntl(2) and
flock(2). Don't know how I manged to think fcntl(2) wasn't
available. I they're all closely related, I expect fcntl(2) to be
also available on the other *BSD systems.
...
>> Patches to mailpost are given below in case they're of use to anyone
>> else.
>
>OK, thanks. I obtain a similar patch with INN::Utils::Shlock.
>
>
>
>> The pullnews and signcontrol perl scripts that come with INN also use
>> flock; I suppose I should also look at these scripts.
>
>Unfortunately, signcontrol does not currently use any INN
>variables. (It is designed to work as a stand-alone program.)
>Directly adding INN::Utils::Shlock would be weird. Maybe a
>solution based on your LockFile::Simple example would be best.
>This time using:
> eval { require INN::Utils::Shlock; import INN::Utils::Shlock;
> $use_shlock = 1; };
That's one way of making conditional use of INN::Utils::Shlock::unlock,
and by inference conditional use of INN's shlock program.
Some time ago I was trying to set up locking in shell scripts. I
used the code below. I'm sure I got this idea from Cnews, it relies
on hard-linking being an atomic event on Unix systems to avoid race
conditions. This, or similar code, is readily translated to perl
and would give a primitive form of locking for stand-alone programs
such as signcontrol.
cd $fetchesdir || exit 1
# Primitive locking, to avoid straying into the gunsights of some
# running program...
pid=$$
lockname=LOCK_FETCH
lock_temp=$lockname.$pid
trap "$rm -f $lock_temp; trap 0" 0 1 2 15
$echo $pid > $lock_temp || exit 1
tries=
while :
do
if $ln $lock_temp $lockname 2> /dev/null
then
$rm -f $lock_temp
trap "$rm -f $lockname; trap 0" 0 1 2 15
break
fi
tries=$(($tries + 1))
[ $tries -gt $max ] && exit 1
$sleep $sleeptime
done
# Got a lock, proceed as normal.
>As for pullnews:
...
That looks good.
--
Dennis Davis, BUCS, University of Bath, Bath, BA2 7AY, UK
D.H.Davis@bath.ac.uk
Re: Mail-to-News
Author: Dennis Davis
Date: Tue, 26 Jul 2011 14:12
Date: Tue, 26 Jul 2011 14:12
137 lines
5963 bytes
5963 bytes
In the referenced article, =?windows-1252?Q?Julien_=C9LIE?=
<iulius@nom-de-mon-site.com.invalid> writes:
...
>> Documentation for inews in INN indicates that it's not suitable
>> for use on client machines. So these changes won't affect other
>> versions of inews out there. Eg the inews that comes with the
>> trn Newsreader and the mini-inews that's still out there somewhere.
>
>My comment was only meant for the inews program shipped with
>INN. It should be updated to take a benefit from the new commands
>defined in RFC 3977. I do not know much about the other "inews"
>programs in the wild. I bet it would also be worthwhile updating
>them.
I agree it would be worthwhile, but I'm not sure this would
have much impact. I suspect all of the "inews" programs in the wild
are used on client machines that have READ/POST permissions. In
practice any added IHAVE functionality is unlikely to be used.
I also suspect that some of these versions of "inews" aren't
currently maintained. For example, having mentioned "mini-inews"
I did an Internet search and found a copy. The datestamps on the
untarred s/w are interesting:
-rw-r--r-- 1 ccsdhd wheel 806 Nov 4 1996 Makefile
-rw-r--r-- 1 ccsdhd wheel 2412 Jul 5 1990 README
-rw-r--r-- 1 ccsdhd wheel 14069 Nov 4 1996 clientlib.c
-rw-r--r-- 1 ccsdhd wheel 11153 Feb 9 1998 conf.h
-rw-r--r-- 1 ccsdhd wheel 11153 Feb 9 1998 conf.h.orig
-rw-r--r-- 1 ccsdhd wheel 9420 Nov 4 1996 inews.c
-rw-r--r-- 1 ccsdhd wheel 3116 Jan 31 1994 nntp.h
-rw-r--r-- 1 ccsdhd wheel 1417 Nov 4 1996 postauth.c
-rw-r--r-- 1 ccsdhd wheel 3508 Nov 4 1996 strcasecmp.c
-rw-r--r-- 1 ccsdhd wheel 2336 Nov 4 1996 uname.c
-rw-r--r-- 1 ccsdhd wheel 234 Nov 4 1996 version.c
This looks to be a standalone inews client stripped out of a release
of nntp, possibly NNTP 1.5.11. I very much doubt that this s/w is
actively maintained. But, it still compiles, works and will post
articles to an NNTP server.
...
>> The above shlock perl routine could certainly be made versatile
>> enough for most puposes by adding extra parameters. Eg
>> "lock_attempts" and "delay" for use in mailpost.
>
>I have come up with a Perl module named INN::Utils::Shlock.
>I hope the naming is fine.
>
>
>Extract from INN::Utils::Shlock(3pm):
>
>NAME
> INN::Utils::Shlock - Wrapper around the shlock program
>
>DESCRIPTION
> This Perl module wraps the shlock(1) program so that it can easily be used. Calling
> shlock is more portable than using flock(2) and its corresponding Perl function
> because this function does not work as expected on all existing systems.
>
> See the shlock(1) documentation for more information.
>
> Using INN::Utils::Shlock is straight-forward:
>
> use lib '<pathnews>/lib/perl';
> use INN::Utils::Shlock;
>
> my $lockfile = "myprogram.LOCK";
>
> # Acquire a lock.
> $INN::Utils::Shlock::lock($lockfile);
>
> # Unlock.
> $INN::Utils::Shlock::unlock($lockfile);
>
> These two functions return 1 on success, 0 on failure. Therefore, the success of
> (un)locking can be checked for instance as follows:
>
> $INN::Utils::Shlock::lock($lockfile) or die "cannot create lock file";
>
> or:
>
> if ($INN::Utils::Shlock::lock($lockfile, 4) < 1) {
> die "giving up after 4 unsuccessful attempts to create lock file";
> }
>
>INTERFACE
> lock(lockfile)
> Tries to create a lock file named lockfile.
>
> lock(lockfile, retries)
> Tries to create a lock file named lockfile. If it fails, locking attempts are
> repeated once every 2 seconds for at most retries times.
>
> lock(lockfile, retries, delay)
> Tries to create a lock file named lockfile. If it fails, locking attempts are
> repeated once every delay seconds for at most retries times.
>
> Note that lock(lockfile) is equivalent to lock(lockfile, 0, 2).
>
> unlock(lockfile)
> Removes the file named lockfile.
>
>
>
>
>Do not hesitate to make any comments you think appropriate.
>(In the man page, the variables are properly written in "italics".)
>
>This new Perl wrapper currently works pretty well.
Glad to here it.
I suspect the two lines:
> These two functions return 1 on success, 0 on failure. Therefore, the success of
> (un)locking can be checked for instance as follows:
would read better as:
These two functions return 1 on success, 0 on failure. For example
the success of (un)locking can be checked as:
and I'm sure the perl pedants will want:
> if ($INN::Utils::Shlock::lock($lockfile, 4) < 1) {
written as:
if ($INN::Utils::Shlock::lock($lockfile, 4)) {
--
Dennis Davis, BUCS, University of Bath, Bath, BA2 7AY, UK
D.H.Davis@bath.ac.uk
Re: Mail-to-News
Author: Dennis Davis
Date: Tue, 26 Jul 2011 16:37
Date: Tue, 26 Jul 2011 16:37
21 lines
1572 bytes
1572 bytes
In article <Loy243.Ax8.B.larch@bath.ac.uk>,
Dennis Davis <ccsdhd@bath.ac.uk> wrote:
...
>and I'm sure the perl pedants will want:
>
>> if ($INN::Utils::Shlock::lock($lockfile, 4) < 1) {
>
>written as:
>
> if ($INN::Utils::Shlock::lock($lockfile, 4)) {
Oops, better make that last line:
if (! $INN::Utils::Shlock::lock($lockfile, 4)) {
That's what you get for being a lousy proofreader :-)
--
Dennis Davis, BUCS, University of Bath, Bath, BA2 7AY, UK
D.H.Davis@bath.ac.uk
Re: Mail-to-News
Author: Julien ÉLIE
Date: Thu, 04 Aug 2011 22:23
Date: Thu, 04 Aug 2011 22:23
74 lines
3713 bytes
3713 bytes
Hi Dennis,
>> My comment was only meant for the inews program shipped with
>> INN. It should be updated to take a benefit from the new commands
>> defined in RFC 3977. I do not know much about the other "inews"
>> programs in the wild. I bet it would also be worthwhile updating
>> them.
>
> I agree it would be worthwhile, but I'm not sure this would
> have much impact. I suspect all of the "inews" programs in the wild
> are used on client machines that have READ/POST permissions. In
> practice any added IHAVE functionality is unlikely to be used.
>
> I also suspect that some of these versions of "inews" aren't
> currently maintained.
It is not a problem that other versions of "inews" are no longer
maintained. At least, the one shipped with INN is still maintained and
is from time to time improved.
If older "inews" programs fit the need of their users, it is great.
Otherwise, it is helpful for them to know that in case they need another
features, INN (amongst others) may do the job.
>> # Acquire a lock.
>> $INN::Utils::Shlock::lock($lockfile);
>>
>> # Unlock.
>> $INN::Utils::Shlock::unlock($lockfile);
It is in fact without the leading "$". It was a typo in my previous
article.
INN::Utils::Shlock::lock($lockfile);
INN::Utils::Shlock::unlock($lockfile);
> I suspect the two lines:
>
>> These two functions return 1 on success, 0 on failure. Therefore, the success of
>> (un)locking can be checked for instance as follows:
>
> would read better as:
>
> These two functions return 1 on success, 0 on failure. For example
> the success of (un)locking can be checked as:
Yes, totally. Thanks for the suggestion. I have adopted it.
> and I'm sure the perl pedants will want:
>
>> if ($INN::Utils::Shlock::lock($lockfile, 4)< 1) {
>
> written as:
>
> if (! INN::Utils::Shlock::lock($lockfile, 4)) {
Yup!
Whole commit here:
http://inn.eyrie.org/trac/changeset/9303
--
Julien ÉLIE
« En France, on n'a pas de pétrole, mais on a des idées ! Alors,
j'ai troqué ma deux-chevaux contre une deux-bœufs ! » (Raymond
Devos)
Re: Mail-to-News
Author: Julien ÉLIE
Date: Thu, 04 Aug 2011 22:31
Date: Thu, 04 Aug 2011 22:31
18 lines
2199 bytes
2199 bytes
Hi Dennis, > Some time ago I was trying to set up locking in shell scripts. I > used the code below. I'm sure I got this idea from Cnews, it relies > on hard-linking being an atomic event on Unix systems to avoid race > conditions. This, or similar code, is readily translated to perl > and would give a primitive form of locking for stand-alone programs > such as signcontrol. I am unsure this code prevents race conditions in all circunstances (with NFS, with multiple cores...). -- Julien ÉLIE « En France, on n'a pas de pétrole, mais on a des idées ! Alors, j'ai troqué ma deux-chevaux contre une deux-bœufs ! » (Raymond Devos)
Re: Mail-to-News
Author: Julien ÉLIE
Date: Wed, 10 Aug 2011 19:41
Date: Wed, 10 Aug 2011 19:41
22 lines
2125 bytes
2125 bytes
Hi Dennis, >> Some time ago I was trying to set up locking in shell scripts. I >> used the code below. I'm sure I got this idea from Cnews, it relies >> on hard-linking being an atomic event on Unix systems to avoid race >> conditions. This, or similar code, is readily translated to perl >> and would give a primitive form of locking for stand-alone programs >> such as signcontrol. > > I am unsure this code prevents race conditions in all circunstances > (with NFS, with multiple cores...). http://rute.2038bug.com/node23.html.gz 20.9.2 Locking over NFS “the ln function does not work exactly right over NFS -- you need to stat the file and actually check that the link count has increased to 2.” -- Julien ÉLIE « Sitis licita, etiam potio licita. »
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