[net.news] simulatneous updates to history

gam@amdahl.UUCP (G A Moffett) (07/20/85)

If a user is posting an article at the same time the expire
program is running, isn't there some risk that inews and expire are
going to update the history database at the same time?  This
is particularly crucial to the dbm(3) database for history.
Has anyone examined this problem?  Has anyone implimented a
file-locking mechanism (portable!) for inews and expire?
-- 
Gordon A. Moffett		...!{ihnp4,cbosgd,hplabs}!amdahl!gam

rick@seismo.UUCP (Rick Adams) (07/21/85)

Currently if inews/rnews is running when expirs is running you MAY
loose some articles from the history file.

Here is the shell script I  run from crontab to do the expiring. It works.

---rick

#! /bin/sh
# This is how I do it on seismo.
umask 002

# Prevent additions to history file while expire is running
mv /usr/bin/rnews /usr/bin/rnews.x
echo 'exec cat >/usr/spool/news/rnews.$$' >/usr/bin/rnews
chmod 4755 /usr/bin/rnews
/etc/chown news /usr/bin/rnews

# actually expire the articles
cd /usr/lib/news
/usr/lib/news/expire -v2

# get a fresh logfile
cd /usr/spool/log
mv news.5 news.6
mv news.4 news.5
mv news.3 news.4
mv news.2 news.3
mv news.1 news.2
mv news.0 news.1
mv news news.0
cp /dev/null news
/etc/chown news news*

# turn rnews loose
mv /usr/bin/rnews.x /usr/bin/rnews
cd /usr/spool/news
for i in rnews.*
do
	/usr/bin/rnews <$i
	rm -f $i
done

boyce@daemen.UUCP (Doug Boyce) (07/26/85)

> If a user is posting an article at the same time the expire
> program is running, isn't there some risk that inews and expire are
> going to update the history database at the same time?  This
> is particularly crucial to the dbm(3) database for history.
> Has anyone examined this problem?  Has anyone implimented a
> file-locking mechanism (portable!) for inews and expire?
> -- 
> Gordon A. Moffett		...!{ihnp4,cbosgd,hplabs}!amdahl!gam

That could probably happen but our feed (sunybcs) took care of that
by writing a doexpire script (which all sites it feeds have).  It creates a
"LOCK" file in the newslib directory so inews/rnews can't add news.  There is
a problem with this though, inews only waits 45 seconds (vanilla 2.10.2) for
the lock to go away so news will be lost.  I increased DEADTIME to be about
40 minutes so if we get news while doexpire is running inews just waits
patiently until it finishes instead dumping the news onto the floor.


-- 

Doug Boyce   Daemen College, Amherst NY

UUCP : {decvax,dual,rocksanne,watmath,rocksvax}!sunybcs!daemen!boyce
ARPA : boyce@buffalo.CSNET@csnet-relay
or
ARPA : boyce%daemen.uucp@buffalo.CSNET@csnet-relay


	"What a hypocrite, after all that lecturing about screwing up the
		space-time continuum..."
	"Yeah, well, I figured what the hell.."

jerry@oliveb.UUCP (Jerry Aguirre) (07/31/85)

> Currently if inews/rnews is running when expirs is running you MAY
> loose some articles from the history file.
> 
> Here is the shell script I  run from crontab to do the expiring. It works.
  
> chmod 4755 /usr/bin/rnews
> /etc/chown news /usr/bin/rnews

On many Unix systems this sequence will not work correctly because doing
a chown will remove the set uid and gid bits from the permissions.  I
suggest that you do the chown first and then the chmod.

Of course on many Unix systems the suid will not work for shell scripts
anyway.  I just tested it on my 4.1BSD system and it doesn't.  However
if the file begins with a line of:

	#!/bin/sh

then the setuid does work.  I guess this is another advantage to the
use of the #! strategy for controlling script execution.

I suspect that the posters /usr/spool/news directory is writable without
benefit of the suid.

				Jerry Aguirre @ Olivetti ATC
{hplabs|fortune|idi|ihnp4|tolerant|allegra|tymix}!oliveb!jerry