From: markw@gvlf7-p.gvl.unisys.com (Mark H. Weber)
Subject: Re: NNTP full pathname fix?
Organization: Paramax Systems Corporation (A Unisys Company)
Date: Mon, 16 Nov 1992 18:02:35 GMT

In article <BxM5Ax.EEF@javelin.sim.es.com> pashdown@javelin.sim.es.com (Pete Ashdown) writes:
>Last time I updated CNEWS there was some patch to fix the problem with
>nntpsend not seeing where articles are truly located due to the local path
>change in the batch files.  Now I can't find this patch, does anyone know what
>I'm talking about?

Yes. I posted this a while back, here it is again:

I guess it's my turn to answer this one.  I asked this same question 
a few weeks back, here's a summary I've been meaning to post for a while.
The problem has been encountered by a number of news administrators, and 
the solutions are all fairly straightforward.

You may be wondering why this change was made. The advantages of not 
having the leading /usr/spool/news are smaller batch files and more 
efficient access by not having to traverse the /usr/spool/news inodes 
for each and every article. This is probably not very important to
a small leaf site, but to a major hub, which may send 10,000 articles
per day to 10 or more sites, the savings can be significant.

The modifications fall into 3 different areas:

1) Patch the nntpsend script - a fairly simple change can be made to
   change the working directory before nntpxmit is invoked.

2) Patch nntpxmit - the nntpxmit program can be modified to add
   the spool directory to the article filename before it is read.

3) Patch Cnews - the relaynews program can be modified to restore
   it's former behaviour, to write the full pathname out to the
   batch file.

The second and third options do not take advantage of the intended
efficiency improvement in the change to Cnews, but all 3 will get
the system working.

------------------------------%<  cut here  >%-----------------------------

Patches for regular nntp script (csh version, sh version changes are similar):

Here's the original:

                if ( -e ${send} ) then
                        echo ${pname}: "[$$]" begin ${host}
                        time nntpxmit ${host}:${send}
                        echo ${pname}: "[$$]" end ${host}
                endif
 
add the following in the "for each host" loop:

                if ( -e ${send} ) then
                        echo ${pname}: "[$$]" begin ${host}
add line ======>        cd /usr/spool/news
add ${batchdir}/ ==>    time nntpxmit -d ${host}:${batchdir}/${send}
                        echo ${pname}: "[$$]" end ${host}
                endif

------------------------------%<  cut here  >%-----------------------------

There is also a modified nntpsend script for use with Cnews. This script
uses the Cnews locking mechanism when working with the batch files, and
expects to find the batches in the default Cnews directory. I'll post
that in it's entirety:


#!/bin/sh
#
# nntpsend site1 ... siten
# send nntp batches to remote sites, C news style.
#
# Author: Jean-Francois Lamy, lamy@ai.utoronto.ca, 1989-06-27
#
# We assume that the file of articles to be sent is found under
# $NEWSARTS/out.going/iname/togo, where iname is the site's internet name.
# this may requre a $NEWSLIB/sys entry with an explicit location specified
# if the Usenet name differs, as in the last field of:
#
# utstat:comp,news,ut,tor,can,ont,uw,list/all:F:utstat.toronto.edu/togo
#
# A togo.next file in the site directory may contain articles left over from
# previous transmissions (we append togo to togo.next, call nntpxmit on
# togo.next and it leaves failed articles there).

# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
. ${NEWSCONFIG-/usr/lib/news/bin/config}

# we assume $NEWSBIN/nntp is where nntpxmit lives; adjust appropriately
PATH=$NEWSBIN/nntp:$NEWSCTL/bin:$NEWSBIN/batch:$NEWSBIN:$NEWSPATH 
export PATH
umask $NEWSUMASK

# LOGFILE is for debugging
LOGFILE=/dev/null; export LOGFILE

pname=`basename $0`
echo ${pname}: "[$$]" begin `date` > $LOGFILE

for host in ${remotes=$*}
do
	cd $NEWSARTS/out.going/$host
	
	if test -s togo || test -s togo.next
	then

		# we have articles to send to $host. Lock the news system, so
		# that we can be sure that "togo" does not change while we
		# append it to the list of things to send out.  If we don't do
		# that, and relaynews is in a long batch, we could actually
		# catch up with relaynews and then we would need some hairy
		# stuff to deal with that.

		lock="$NEWSCTL/LOCK"		# lock relaynews.
		ltemp="$NEWSCTL/L.$$"
		echo $$ >$ltemp
		trap "rm -f $ltemp ; exit 0" 0 1 2 15
		while true
		do
			if newslock $ltemp $lock
			then
				trap "rm -f $ltemp $lock ; exit 0" 0 1 2 15
				break
			fi
			sleep 30
		done

		# while relaynews is locked, append the articles to go to
		# the togo.next file for the current site. lock current site
		# until nntpxmit completes, so we can unlock relaynews asap.

		nntplock="$NEWSCTL/LOCKnntpsend.$host"
		if newslock $ltemp $nntplock
		then 	
			# we have togo.next all to ourselves
			trap "rm -f $nntplock $ltemp $lock ; exit 0" 0 1 2 15
			if test -s togo.next
			then
				cat togo >> togo.next 2>/dev/null
				rm -f togo
			else
				mv -f togo togo.next
			fi

			# unlock news; the host's togo.next file is locked and
			# won't be tampered with, so togo no longer matters.
			rm -f $ltemp $lock

			# perform the actual transfers.
			if test -s togo.next
			then
				echo ${pname}: "[$$]" begin ${host} > $LOGFILE
				cd /usr/spool/news 
                                nntpxmit ${host}:$NEWSARTS/out.going/$host/togo.next > $LOGFILE
                                cd $NEWSARTS/out.going/$host
				echo ${pname}: "[$$]" end ${host} > $LOGFILE
			fi

			# unlock this site.
			rm -f $nntpltemp $nntplock
		else	
			# transfer in progress, leave articles to accumulate
			# in ${host} for the time being.
			echo ${pname}: "[$$]" ${host} locked by "[`cat $nntplock`]" > $LOGFILE
			rm -f $ltemp $lock
		fi # newslock LOCK$host.nntp
	fi # test -s togo ...
done

echo ${pname}: "[$$]" end `date` > $LOGFILE


------------------------------%<  cut here  >%-----------------------------

Patches to nntpxmit:

The patch:

*** nntpxmit.c.orig	Thu Jan 16 14:39:40 1992
--- nntpxmit.c	Thu Jan 16 12:39:13 1992
***************
*** 339,344 ****
--- 339,345 ----
  	char	*mode = "r";
  #endif	/* FTRUNCATE */
  	char	*msgid;
+ 	static char fullartpath[200];
  
  	if ((Qfp = fopen(file, mode)) == (FILE *)NULL) {
  		char	buf[BUFSIZ];
***************
*** 380,386 ****
  		catchsig(interrupted);
  
  		while ((msgid = getline(Qfp, Article, sizeof(Article))) != NULL) {
! 			if (!sendarticle(host, Article, msgid)) {
  				requeue(Article, msgid);
  				Article[0] = '\0';
  				cleanup();
--- 381,391 ----
  		catchsig(interrupted);
  
  		while ((msgid = getline(Qfp, Article, sizeof(Article))) != NULL) {
! 			fullartpath[0] = '\0';
! 			strcat(fullartpath, SPOOLDIR);
! 			strcat(fullartpath, "/");
! 			strcat(fullartpath, Article);
! 			if (!sendarticle(host, fullartpath, msgid)) {
  				requeue(Article, msgid);
  				Article[0] = '\0';
  				cleanup();
-- 

------------------------------%<  cut here  >%-----------------------------

Patch to Cnews

edit: relay/transmit.c as follows to get full path names from Cnews.

142c142
<               fullname = fullartfile(filename); /* mb 1-28-92 */
---
>               fullname = artfile(filename);   /* N.B.: relative path */




------------------------------%<  cut here  >%-----------------------------

Acknowledgements:

From: louie@sayshell.umd.edu (Louis A. Mamakos)
From: Frank Terhaar-Yonkers <fty@bizarre.rtpnc.epa.gov>
From: Tom Ivar Helbekkmo <tih@barsoom.nhh.no>
From: tale@cs.rpi.edu (David C Lawrence)
From: Jonathan I. Kamens <jik@pit-manager.MIT.EDU>
From: Kenneth Herron <kherron@ms.uky.edu>
From: pozar@kumr.lns.com (Tim Pozar)
From: jerry@strobe.ATC.Olivetti.Com (Jerry Aguirre)
From: stssram@st.unocal.com (Robert Myers)
From: Reg Quinton <reggers@julian.uwo.ca>
From: Mike Stok <mike@meiko.com>
From: pcc@tis.llnl.gov (Phil Cox)
From: Mark Benard <mb@cs.tulane.edu>
From: rob@merlin.georgetown.edu (Rob Guttmann)
From: jmalcolm@sura.net (Joseph Malcolm)


-- 
  Mark H. Weber                   | Internet: markw@GVL.Unisys.COM  
  Paramax Systems (A Unisys Co.)  |     UUCP: ...!gvlv2!markw
  Great Valley Laboratories       |      FAX: +1 215 648 2891
  Box 517, Paoli, PA  19301  USA  |    VOICE: +1 215 648 2112
Newsgroups: news.admin.technical