[news.sysadmin] Bug in insertbatch, and fix

howard@cpocd2.UUCP (02/11/87)

We just got USENET running at our site.  Every time insertbatch
was run manually it worked fine.  Every time it was run from
/usr/lib/crontab, it deleted all the new news without adding the
data to the appropriate directories.  I finally tracked down the
problem and thought someone should know.

There is a serious bug in our version of insertbatch (we got it
from intelca!mipos3; it may be the standard version or not, I don't
know) which is triggered when the default path for user root does not
include the directory where rnews resides.  The effect is that
insertbatch deletes all NEWSBATCH files without unbatching them!

Here's the distributed code (yes I KNOW this is probably copyrighted
but I don't know how else to explain this, and anyway it's WRONG!).

	for i in /usr/spool/newsbatch/decnet/NEWSBATCH.*; do
	    rnews < $i
	    rm $i
	done

If rnews is not found, that DOES NOT PREVENT THE rm FROM EXECUTING!
A correct version might be:

	for i in /usr/spool/newsbatch/decnet/NEWSBATCH.*; do
	    rnews < $i  &&  rm $i
	done
	# modified by Howard A. Landman, 10 Feb 1987, to add '&&'.

In this script, if rnews is not found, the rm will not execute.
Insertbatch will still fail, but you won't lose any news.

I hereby place this fix into the public domain; note that this does not
release you from the copyright (if any) on the original code.
-- 

	Howard A. Landman
	...!intelca!mipos3!cpocd2!howard