#!/bin/sh
#
#     tiger - A UN*X security checking system
#     Copyright (C) 1993 Douglas Lee Schales, David K. Hess, David R. Safford
#     Copyright (C) 2004 Ryan Bradetich
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 1, or (at your option)
#    any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#     Please see the file `COPYING' for the complete copyright notice.
#
# Tru64/5/gen_inetd - 04/01/2004
#
#-----------------------------------------------------------------------------
# NOTE: Tru64 has both /etc/inetd.conf and /etc/inetd.conf.local.  The
# /etc/inetd.conf is global to the cluster and is over-ridable by the
# /etc/inetd.conf.local file.  A entry in the global /etc/inetd.conf
# file can be disabled by specifying "disable" as the serverpath.

$GREP -v '^#' /etc/inetd.conf |
while read service socket protocol wait user path args
do
	echo "$service:$socket:$protocol:$wait:$user $path $args"
done |
$SORT -u > $WORKDIR/etc_inetd.conf.$$

$GREP -v '^#' /etc/inetd.conf.local |
while read service socket protocol wait user path args
do
	echo "$service:$socket:$protocol:$wait:$user $path $args"
done |
$SORT -u > $WORKDIR/etc_inetd.conf.local.$$

echo "/etc/inetd.conf /etc/inetd.conf.local" > $WORKDIR/etc_inetd.$$.src

$JOIN -j 1 -v 1 -v 2 $WORKDIR/etc_inetd.conf.$$ $WORKDIR/etc_inetd.conf.local.$$ |
while read key path args
do
	key=`echo $key | $TR ':' ' '`
	echo "$key $path $args"
done > $WORKDIR/etc_inetd.$$


$JOIN -j 1 -v 2 $WORKDIR/etc_inetd.$$ $WORKDIR/etc_inetd.conf.local.$$ |
while read key path args
do
	[ "$path" = "disable" ] && continue

	key=`echo $key | $TR ':' ' '`
	echo "$key $path $args"
done >> $WORKDIR/etc_inetd.$$

rm $WORKDIR/etc_inetd.conf.$$ $WORKDIR/etc_inetd.conf.local.$$
echo $WORKDIR/etc_inetd.$$
