From: woods@robohack.UUCP (Greg A. Woods)
Subject: C News ctl/newgroup script isn't very careful!
Organization: Elegant Communications Inc.
Summary: broken newgroup control message trashes active file, breaks expire
Date: Mon, 12 Oct 92 22:27:25 GMT

The following control message arrived today, and C News' newgroup
script duitifully appended a line to the active file with an empty
blank line!

This caused expire to barf with the following message:

	expire: bad active-file line for `0000000000'

I've fixed my ctl/newgroup script, and I've been meaning to add a
whole lot more sanity checking to these scripts for some time.  I've
also thought of fixing up inews somewhat, but since it is only a
front-end, such error checking would be only a user-friendly feature,
not a systems assurance feature.  Besides, I'm eagerly awaiting the
"final" C version of inews!

The purpose of this message is to warn the Usenet admin's out there,
who are using C News to watch out for errors in your active files and
offer the attached newgroup.sh as a temporary fix.  I expect the C
News authors will devise their own sanity checks and release some new
code A.S.A.P.

I'd also like to politely request that anyone posting newgroup
messages be extremely careful about how you go about it!

In article <1992Oct6.180812.28639@peanuts.informatik.uni-tuebingen.de> es@peanuts.informatik.uni-tuebingen.de (Endric Schubert) writes:
> Control: newgroup
> Newsgroups: alt.fan.schwaben.heul.heul.heul
> Path: robohack!feline!censor!geac!utcsri!torn!cs.utexas.edu!natinst.com!news.dell.com!swrinde!sdd.hp.com!ux1.cso.uiuc.edu!uwm.edu!linac!convex!darwin.sura.net!jvnc.net!gmd.de!Germany.EU.net!rrz.uni-koeln.de!unidui!math.fu-berlin.de!news.belwue.de!news.uni-tuebingen.de!peanuts!peanuts!es
> From: es@peanuts.informatik.uni-tuebingen.de (Endric Schubert)
> Subject: ... traenen luegen nicht
> Message-ID: <1992Oct6.180812.28639@peanuts.informatik.uni-tuebingen.de>
> Sender: es@peanuts (Endric Schubert)
> Organization: "Lehrstuhl fuer Technische Informatik, Uni Tuebingen"
> Date: Tue, 6 Oct 92 18:08:12 GMT
> Approved: schwabe@scheisshaus
> Lines: 8
> 
> 
> -- 
> 
>                      Endric Schubert
>                   Universitaet Tuebingen
>            Lehrstuhl fuer Technische Informatik
>                         Sand 13
>                  7400 Tuebingen, Germany

----------------- cut here -----------------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  newgroup.sh
# Wrapped by woods@robohack on Mon Oct 12 18:22:39 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'newgroup.sh' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'newgroup.sh'\"
else
echo shar: Extracting \"'newgroup.sh'\" \(2074 characters\)
sed "s/^X//" >'newgroup.sh' <<'END_OF_FILE'
X#!/bin/sh
X: || exec /bin/sh $0 $argv:q
X# uncomment the following if you have trouble with older ksh's on USG systems
X#(alias) >/dev/null 2>&1 && exec /bin/sh "$0" ${1+"$@"}
X
X#ident	"%Z%%Y%:%M%	%I%	%E% %U% (%Q%)"
X
X#
X# newgroup group flag - create group (4-field version: B-2.10.3+ compatible)
X#	subject to our sys file group pattern
X
X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
X. ${NEWSCONFIG-/usr/lib/news/bin/config}
Xexport NEWSCTL NEWSBIN NEWSARTS
XPATH=$NEWSCTL/bin:$NEWSBIN/relay:$NEWSBIN:$NEWSPATH ; export PATH # include mkpdir
Xumask $NEWSUMASK
X
XARTICLE=/tmp/art$$
Xhdr=/tmp/nc$$
X
Xtrap "rm -f $hdr $ARTICLE; exit 0" 0
X
Xtee $ARTICLE | canonhdr >$hdr
X
X# unapproved ctl msg? then quit
Xgrep -s '^Approved:' $hdr >/dev/null || { rm -f $hdr; exit 0; }
X
X# empty newsgroup name? then quit
Xtest "$1 " = " " && { rm -f $hdr; exit 0; }
X
XSENDER="`grep '^Sender:' $hdr | sed 's/^[^:]*: *//'`"
Xcase "$SENDER" in
X"")	SENDER="`grep '^From:' $hdr | sed 's/^[^:]*: *//' `" ;;
Xesac
X
Xgreppat="^`echo $1 | sed 's/\./\\\\./g' ` "
Xif grep -s "$greppat" $NEWSCTL/active >/dev/null; then	# group exists?
X	export SENDER
X	chamod "$1" "$2" 		# change moderated flag if needed
X	exit
Xfi
X
Xme="`newshostname`"
Xgngppat=`awk -f $NEWSBIN/relay/canonsys.awk $NEWSCTL/sys |
X	egrep "^($me|ME):" |
X	awk -F: '
X{
X	fields = split($2, field2, "/")	# split ngs/dists
X	print field2[1]			# print only ngs
X	exit
X}' `
X
Xif gngp -a "$gngppat" >/dev/null <<!
X$1
X!
Xthen			# no group in active, but sys file likes it: make it
X	case "$2" in
X	moderated)	flag=m ;;
X	*)		flag=y ;;
X	esac
X	echo "$1 0000000000 0000000001 $flag" >>$NEWSCTL/active
X	(echo "$1 `getdate now` $SENDER" >>$NEWSCTL/active.times)  # rn hook
X	# update newsgroups and officialgroups
X	sed -n -e '
X		:top
X	        /^For your newsgroups file:$/b print
X		n;b top
X		:print
X		n;p;q' $ARTICLE | tee -a $NEWSCTL/newsgroups >>$NEWSCTL/other.d/newgroups
X	# make the directory since rn will bitch if it's missing
X	mkpdir $NEWSARTS/`echo $1 | tr . / `
X	(
X		echo "Subject: network newgroup"
X		echo ""
X		echo "newsgroup $1 was created by $SENDER."
X	) | mail $NEWSMASTER
Xfi
END_OF_FILE
if test 2074 -ne `wc -c <'newgroup.sh'`; then
    echo shar: \"'newgroup.sh'\" unpacked with wrong size!
fi
# end of 'newgroup.sh'
fi
echo shar: End of shell archive.
exit 0
-- 
						Greg A. Woods

woods@robohack.UUCP, woods@Elegant.COM  VE3TCP	UniForum Canada & ECI
+1 416 443-1734 [home] +1 416 362-9772 [work]	Toronto, Ontario; CANADA
Newsgroups: news.software.b