C News on SCO Xenix

Chip Salzenberg chip at ateng.com
Wed Jun 14 03:35:01 AEST 1989


C News on SCO Xenix/386 2.3 works like a dream.  Notes on how to do it:

First, be sure _all_ shell scripts in the development tree that start with
"#! /bin/sh" are changed to ": use /bin/sh".  It's too bad Xenix suffers
from Not Invented Here disease; "#!" is such a nice feature.  Sigh.

Second, tell "build" that the following things are unavailable:

	ANSI stdlib.h
	fsync()
	index()
	rindex()
	symlink()

Third, Xenix setuid(geteuid()) is broken so badly that it doesn't even
return -1 when it fails!  I got around this problem by making the following
change in relay/relay.c:

	/* Xenix setuid() doesn't return error?! */
	(void) setgid(newsgid);
	(void) setuid(newsuid);
	if (getgid() != newsgid || getegid() != newsgid
	 || getuid() != newsuid || geteuid() != newsuid) {
		/* this code runs the setuid-root hack program */
	}

Fourth, you need spacefor.xenix.  I'm including it in this article as a
sharchive.  You'll need to modify the device assignment labeled "dare to be
stupid". :-)

All in all, C News works tremendously well.  I love it to pieces.
Thanks much to Geoff and Henry.

#! /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:  spacefor.xenix
# Wrapped by chip at ateng on Tue Jun 13 13:31:27 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'spacefor.xenix' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'spacefor.xenix'\"
else
echo shar: Extracting \"'spacefor.xenix'\" \(1729 characters\)
sed "s/^X//" >'spacefor.xenix' <<'END_OF_FILE'
X: use /bin/sh
X# spacefor - determine available disk space
X# About how many things of $1 bytes will fit in the available space for
X# stuff of type $2 ("incoming", "articles", "control", "outbound $3",
X# or "archive") without cramping things too badly?
X#
X# You'll have to change this -- your blocksize, minimum-free-desired amounts,
X# and df output format will probably differ, and you may need to name
X# your filesystems explicitly.
X
X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
X. ${NEWSCONFIG-/usr/lib/news/bin/config}
X
XPATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH
Xumask $NEWSUMASK
X
X# punt to server if necessary
Xif test -r $NEWSCTL/server
Xthen
X	server="`cat $NEWSCTL/server`"
X	me="`hostname`"
X	if test " $server" != " $me"
X	then
X		exec rsh $server "PATH=$PATH `basename $0` $*"
X		# does not return
X	fi
Xfi
X
X# head off special case
Xcase "$1" in
X0)	echo 10000 ; exit 0 ;;
Xesac
X
X# argument to df, df units, and free space desired (in df units)
Xdfunit=512			# default unit (bytes)
Xcase "$2" in
Xincoming)	arg="$NEWSARTS/in.coming" ; desire=5000 ;;
Xarticles)	arg="$NEWSARTS" ; desire=5000 ;;
Xcontrol)	arg="$NEWSCTL" ; desire=3000 ;;
Xoutbound)	arg="/usr/spool/uucp" ; desire=10000 ;;	# ignore $3
Xarchive)	arg="$NEWSARTS" ; desire=1 ;;		# system-specific
X*)		echo "$0: bad type argument \`$2'!!" >&2
X		exit 2 ;;
Xesac
X
X# dare to be stupid
Xarg=/dev/root
X
X# this is set up for the stupid System V df
Xdf $arg | sed "s/.*:/: :/" | awk "BEGIN { nf = 6 ; nr = 1 }
X	NR == nr && NF >= nf {
X		nb = (\$3 - $desire) * $dfunit / $1
X		if (nb > 10000)
X			nb = 10000	# ensure representable as integer
X		nb = int(nb)
X		if (nb <= 0)
X			print 0
X		else
X			print nb
X		exit
X	}
X	NR == nr && NF < nf {		# idiotic Berkeley continuation
X		nr += 1
X		nf -= 1
X	}"
END_OF_FILE
if test 1729 -ne `wc -c <'spacefor.xenix'`; then
    echo shar: \"'spacefor.xenix'\" unpacked with wrong size!
fi
chmod +x 'spacefor.xenix'
# end of 'spacefor.xenix'
fi
echo shar: End of shell archive.
exit 0
-- 
You may redistribute this article only to those who may freely do likewise.
Chip Salzenberg         |       <chip at ateng.com> or <uunet!ateng!chip>
A T Engineering         |       Me?  Speak for my company?  Surely you jest!



More information about the Comp.unix.xenix mailing list