home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.unix
- From: panos@cs.colorado.edu (Panos Tsirigotis)
- Subject: v26i270: xinetd-2.1.1 - inetd replacement with access control and logging, Part26/31
- Sender: unix-sources-moderator@gw.home.vix.com
- Approved: vixie@gw.home.vix.com
-
- Submitted-By: panos@cs.colorado.edu (Panos Tsirigotis)
- Posting-Number: Volume 26, Issue 270
- Archive-Name: xinetd-2.1.1/part26
-
- #! /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 archive 26 (of 31)."
- # Contents: compile-src
- # Wrapped by panos@mystique on Mon Jun 21 14:51:28 1993
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'compile-src' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'compile-src'\"
- else
- echo shar: Extracting \"'compile-src'\" \(16974 characters\)
- sed "s/^X//" >'compile-src' <<'END_OF_FILE'
- X#!/bin/sh
- X
- X#
- X# (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
- X#
- X
- X#
- X# $Id: compile-src,v 6.8 1993/06/17 16:56:30 panos Exp $
- X#
- X
- Xscript_name=`basename $0`
- X
- Xif test "$script_name" != "$0" -a "./$script_name" != "$0" ; then
- X echo This script must be executed from the top level directory
- X exit 1
- Xfi
- X
- X#
- X# The order with which the libraries are listed is important.
- X# It is also a problem; to understand why consider this:
- X# Library A depends (uses some functions from) library B
- X# Then, B must be compiled and installed before A so that
- X# A can find B's include files at the standard place.
- X# But when linking the program with A and B, if B precedes A
- X# then none of B's code will be included since nobody has yet
- X# tried to use it (since has not been encountered yet).
- X#
- X# Our solution is to list the libraries in the order they are compiled
- X# and while compiling them also generate the reverse list which is the
- X# order they have to be linked.
- X#
- Xmandatory_libs="sio misc pset xlog str"
- Xoptional_libs="pq timer"
- X
- Xcatch_sigs="2 15"
- Xinc=/usr/include
- X
- X#
- X# The value of ccopt is used for setting the DEBUG makefile variable.
- X# Therefore, it can be used to either enable debugging support (i.e. -g),
- X# profiling support (i.e. -pg), or optimization support (i.e. -O)
- X# The default is optimization.
- X#
- Xccopt=-O
- X
- Xwhile test $# -gt 0
- Xdo
- X option=$1 ; shift
- X case $option in
- X -libc)
- X if test $# -eq 0 ; then
- X echo "Argument missing. Exiting..."
- X exit 1
- X fi
- X libc=$1
- X shift
- X if test ! -r $libc ; then
- X echo "File is not readable: $libc"
- X exit 1
- X fi
- X ;;
- X
- X -signals)
- X if test $# -eq 0 ; then
- X echo "Argument missing. Exiting..."
- X exit 1
- X fi
- X signal_handling=$1
- X shift
- X ;;
- X
- X -ccopt)
- X if test $# -eq 0 ; then
- X echo "Argument missing. Exiting..."
- X exit 1
- X fi
- X ccopt=$1
- X shift
- X ;;
- X
- X -os)
- X if test $# -eq 0 ; then
- X echo "Argument missing. Exiting..."
- X exit 1
- X fi
- X osversion=$1 ;
- X shift
- X ;;
- X
- X -auto)
- X autoconfig=yes
- X ;;
- X
- X -sf|-cf)
- X if test $# -eq 0 ; then
- X echo "Missing argument to $option. Exiting..."
- X exit 1
- X fi
- X
- X if test "$option" = "-sf" ; then
- X v=yes
- X else
- X v=no
- X fi
- X
- X specified_flags=yes
- X flag=$1
- X shift
- X
- X #
- X # The first 2 lines are for xinetd.
- X # The 3rd line has to do with the man pages (xinetd and libraries)
- X # The rest of the lines are for the libraries
- X #
- X case "$flag" in
- X old_wait|no_rpc|no_termios|no_posix_types) eval $flag=$v ;;
- X no_siglist) eval $flag=$v ;;
- X has_SB) eval $flag=$v ;;
- X old_dir|no_ftw|no_timers|no_syslog) eval $flag=$v ;;
- X has_mmap|has_memops|has_bcopy) eval $flag=$v ;;
- X has_isatty|has_bsdtty|has_sysvtty) eval $flag=$v ;;
- X has_onexit|has_atexit) eval $flag=$v ;;
- X *) echo "Bad flag name: $flag. Exiting..." ; exit 1
- X esac
- X ;;
- X
- X -custom)
- X custom=yes
- X ;;
- X
- X -verbose)
- X verbose=yes
- X ;;
- X #
- X # THIS IS THE SCRIPT DOCUMENTATION
- X #
- X -help)
- X echo "Usage: $script_name [options]"
- X echo "Options:"
- X echo " -libc pathname : specifies the location of the C library"
- X echo " -signals type : type of signal handling"
- X echo " -os osname : specifies the OS name and version"
- X echo " -auto : automatic configuration"
- X echo " -verbose : display info about configuration"
- X echo " -custom : there is a custom xinetd configuration file"
- X echo " -ccopt option : option should be either -g for debugging"
- X echo " or -O for optimization"
- X echo "Possible arguments to -signals:"
- X echo " posix, bsd, simple"
- X echo "Possible arguments to -os:"
- X echo " sunos4, ultrix4"
- X echo "The -sf and -cf options set or clear flags that specify"
- X echo "what facilities are available from the operating system"
- X echo "Only one flag can be specified per -sf/-cf but these options"
- X echo "can be used multiple times."
- X echo "Available flags:"
- X echo " no_timers : BSD-type timers are not available"
- X echo " no_rpc : system does not support RPC"
- X echo " no_termios : termios(3) is not available"
- X echo " no_siglist : sys_siglist(3) is not available"
- X echo " no_ftw : ftw(3) is not available"
- X echo " no_syslog : syslog(3) is not available"
- X echo " no_posix_types : POSIX types are not available"
- X echo " has_isatty : isatty(3) is available"
- X echo " has_bsdtty : system has BSD-type tty interface"
- X echo " has_sysvtty : system has SysV-type tty interface"
- X echo " has_mmap : mmap(2) is available"
- X echo " has_memops : memops(3) functions are available"
- X echo " has_bcopy : bcopy(3) is available"
- X echo " has_onexit : onexit(3) is available"
- X echo " has_atexit : atexit(3) is available"
- X echo " old_wait : wait(2) expects a 'union wait' argument"
- X echo " old_dir : old directory(3) package"
- X echo " has_SB : system supports .SB in man pages"
- X echo
- X echo "You can use the -os option to specify an operating system"
- X echo "and then you can use -sf/-cf for further mods."
- X exit 2
- X ;;
- X
- X *) echo "Bad argument: $1. Exiting..." ; exit 1
- X esac
- Xdone
- X
- Xif test "$autoconfig" -a "$osversion" ; then
- X echo "Only one of -auto, -os can be specified"
- X exit 1
- Xfi
- X
- Xif test ! "$osversion" -a ! "$autoconfig" ; then
- X echo "I need to know the operating system you are using and the version."
- X echo "I know about"
- X echo " SunOS 4.x (sunos4)"
- X echo " Ultrix 4.x (ultrix4)"
- X echo "If your OS is among these, use the name in the parentheses, otherwise"
- X echo "just hit <return> and I will try to figure out how to properly"
- X echo -n "configure xinetd for your system --> "
- X read osversion
- Xfi
- X
- X#
- X# This if statement checks if we have a known osversion.
- X# If we don't, we set the autoconfig flag.
- X#
- Xif test "$osversion" ; then
- X case $osversion in
- X sunos4|ultrix4)
- X autoconfig=
- X signal_handling=bsd
- X ;;
- X *) echo "I don't know anything about this OS. Exiting..." ; exit 1
- X esac
- Xelse
- X autoconfig=yes
- Xfi
- X
- X#
- X# Get namelist of C library
- X#
- Xif test "$autoconfig" ; then
- X echo "Obtaining name list of C library"
- X
- X if test ! "$libc" ; then
- X if test -r /lib/libc.a ; then
- X libc=/lib/libc.a
- X else
- X if test -r /usr/lib/libc.a ; then
- X libc=/usr/lib/libc.a
- X else
- X echo -n "Please give me the pathname of the C library -> "
- X read libc
- X if test ! "$libc" -o ! -r "$libc" ; then
- X echo "Bad pathname. Exiting..."
- X exit 1
- X fi
- X fi
- X fi
- X fi
- X nmfile=/tmp/libc.nm.$$
- X nm $libc > $nmfile 2>/dev/null
- X if test $? -ne 0 ; then
- X if test ! -s $nmfile ; then
- X echo "Couldn't get the namelist of C library. Exiting..."
- X rm -f $nmfile
- X exit 1
- X else # name list file is not empty
- X echo "WARNING: The 'nm' command returned a non-zero exit status"
- X echo "WARNING: so the namelist obtained from the C library may be incomplete"
- X echo "Continuing with auto-configuration"
- X fi
- X fi
- Xfi
- X
- Xif test "$specified_flags" -o "$autoconfig" ; then
- X lib_defs=
- X xinetd_defs=
- X
- X #
- X # Determine supported signal handing
- X #
- X if test "$autoconfig" -a ! "$signal_handling" ; then
- X if test "$verbose" ; then echo "Looking for sigaction" ; fi
- X found=`grep sigaction $nmfile | grep T`
- X if test "$found" ; then
- X signal_handling=posix
- X else
- X if test "$verbose" ; then echo "Looking for sigvec" ; fi
- X found=`grep sigvec $nmfile | grep T`
- X if test "$found" ; then
- X signal_handling=bsd
- X else
- X signal_handling=simple
- X fi
- X fi
- X fi
- X
- X case "$signal_handling" in
- X posix) v= ;;
- X bsd) v="-DNO_POSIX_SIGS" ;;
- X simple) v="-DNO_POSIX_SIGS -DNO_SIGVEC" ;;
- X esac
- X xinetd_defs="$xinetd_defs $v"
- X
- X #
- X # Check for setitimer(2)
- X #
- X case "$no_timers" in
- X yes) v=-DNO_TIMERS ;;
- X no) v= ;;
- X *)
- X if test "$autoconfig" ; then
- X if test "$verbose" ; then echo "Looking for setitimer" ; fi
- X found=`grep setitimer $nmfile | grep T`
- X if test ! "$found" ; then v=-DNO_TIMERS ; else v= ; fi
- X else
- X v=
- X fi
- X esac
- X xinetd_defs="$xinetd_defs $v"
- X
- X #
- X # Check for sys_siglist
- X #
- X case "$no_siglist" in
- X yes) v=-DNO_SIGLIST ;;
- X no) v= ;;
- X *)
- X if test "$autoconfig" ; then
- X if test "$verbose" ; then echo "Looking for sys_siglist" ; fi
- X found=`grep sys_siglist $nmfile | grep D`
- X if test ! "$found" ; then v=-DNO_SIGLIST ; else v= ; fi
- X else
- X v=
- X fi
- X esac
- X xinetd_defs="$xinetd_defs $v"
- X
- X #
- X # Check for RPC
- X #
- X case "$no_rpc" in
- X yes) v=-DNO_RPC ;;
- X no) v= ;;
- X *)
- X if test "$autoconfig" ; then
- X if test "$verbose" ; then echo "Looking for RPC" ; fi
- X found=`grep rpcent $inc/netdb.h`
- X if test ! "$found" ; then v=-DNO_RPC ; else v= ; fi
- X else
- X v=
- X fi
- X esac
- X xinetd_defs="$xinetd_defs $v"
- X
- X #
- X # Check if this system supports the old wait
- X #
- X case "$old_wait" in
- X yes) v=-DOLD_WAIT ;;
- X no) v= ;;
- X *)
- X if test "$autoconfig" ; then
- X if test "$verbose" ; then echo "Looking for WEXITSTATUS" ; fi
- X found=`grep WEXITSTATUS $inc/sys/wait.h`
- X if test ! "$found" ; then v=-DOLD_WAIT ; else v= ; fi
- X else
- X v=
- X fi
- X esac
- X xinetd_defs="$xinetd_defs $v"
- X
- X #
- X # Check for pid_t
- X #
- X case "$no_posix_types" in
- X yes) v=-DNO_POSIX_TYPES ;;
- X no) v= ;;
- X *)
- X if test "$autoconfig" ; then
- X if test "$verbose" ; then echo "Looking for pid_t" ; fi
- X found=`cd $inc/sys ; grep pid_t *.h | grep typedef`
- X if test ! "$found" ; then v=-DNO_POSIX_TYPES ; else v= ; fi
- X else
- X v=
- X fi
- X esac
- X xinetd_defs="$xinetd_defs $v"
- X
- X #
- X # Check for termios
- X #
- X case "$no_termios" in
- X yes) v=-DNO_TERMIOS ;;
- X no) v= ;;
- X *)
- X if test "$autoconfig" ; then
- X if test -r $inc/sys/termios.h -o -r $inc/termios.h ; then
- X v=
- X else
- X v=-DNO_TERMIOS
- X fi
- X else
- X v=
- X fi
- X esac
- X xinetd_defs="$xinetd_defs $v"
- X
- X #
- X # Check for new directory types
- X #
- X case "$old_dir" in
- X yes) v=-DOLD_DIR ;;
- X no) v= ;;
- X *)
- X if test "$autoconfig" ; then
- X if test -r $inc/dirent.h ; then
- X v=
- X else
- X v=-DOLD_DIR
- X fi
- X else
- X v=
- X fi
- X esac
- X lib_defs="$lib_defs $v"
- X
- X #
- X # Check for ftw(3)
- X #
- X case "$no_ftw" in
- X yes) v=-D__FTWX_NO_FTW ;;
- X no) v= ;;
- X *)
- X if test "$autoconfig" ; then
- X if test -r $inc/ftw.h ; then
- X v=
- X else
- X v=-D__FTWX_NO_FTW
- X fi
- X else
- X v=
- X fi
- X esac
- X lib_defs="$lib_defs $v"
- X
- X #
- X # Check for syslog(3)
- X #
- X case "$no_syslog" in
- X yes) v=-DNO_SYSLOG ;;
- X no) v= ;;
- X *)
- X if test "$autoconfig" ; then
- X if test "$verbose" ; then echo "Looking for syslog" ; fi
- X found=`grep syslog $nmfile | grep T`
- X if test ! "$found" ; then v=-DNO_SYSLOG ; else v= ; fi
- X else
- X v=
- X fi
- X esac
- X lib_defs="$lib_defs $v"
- X
- X #
- X # Check for mmap. Since it is not required, we do not try to find
- X # if the system supports it.
- X #
- X case "$has_mmap" in
- X yes) v=-DHAS_MMAP ;;
- X *) v= ;;
- X esac
- X lib_defs="$lib_defs $v"
- X
- X case "$has_onexit" in
- X yes) v=-DHAS_ONEXIT ;;
- X no) v= ;;
- X *)
- X if test "$autoconfig" ; then
- X if test "$verbose" ; then echo "Looking for on_exit" ; fi
- X found=`grep on_exit $nmfile | grep T`
- X if test "$found" ; then v=-DHAS_ONEXIT ; else v= ; fi
- X else
- X v=
- X fi
- X esac
- X lib_defs="$lib_defs $v"
- X
- X case "$has_atexit" in
- X yes) v=-DHAS_ATEXIT ;;
- X no) v= ;;
- X *)
- X if test "$autoconfig" ; then
- X if test "$verbose" ; then echo "Looking for atexit" ; fi
- X found=`grep atexit $nmfile | grep T`
- X if test "$found" ; then v=-DHAS_ATEXIT ; else v= ; fi
- X else
- X v=
- X fi
- X esac
- X lib_defs="$lib_defs $v"
- X
- X case "$has_memops" in
- X yes) v=-DHAS_MEMOPS ;;
- X no) v= ;;
- X *)
- X if test "$autoconfig" ; then
- X if test "$verbose" ; then echo "Looking for memcpy" ; fi
- X found=`grep memcpy $nmfile | grep T`
- X if test "$found" ; then v=-DHAS_MEMOPS ; else v= ; fi
- X else
- X v=
- X fi
- X esac
- X lib_defs="$lib_defs $v"
- X
- X case "$has_bcopy" in
- X yes) v=-DHAS_BCOPY ;;
- X no) v= ;;
- X *)
- X if test "$autoconfig" ; then
- X if test "$verbose" ; then echo "Looking for bcopy" ; fi
- X found=`grep bcopy $nmfile | grep T`
- X if test "$found" ; then v=-DHAS_BCOPY ; else v= ; fi
- X else
- X v=
- X fi
- X esac
- X lib_defs="$lib_defs $v"
- X
- X case "$has_isatty" in
- X yes) v=-DHAS_ISATTY ;;
- X no) v= ;;
- X *)
- X if test "$autoconfig" ; then
- X if test "$verbose" ; then echo "Looking for isatty" ; fi
- X found=`grep bcopy $nmfile | grep T`
- X if test "$found" ; then v=-DHAS_ISATTY ; else v= ; fi
- X else
- X v=
- X fi
- X esac
- X #
- X # Since SIO cannot compile without the isatty function, if isatty is not
- X # in the C library, we have to provide our own. For this, we need to know
- X # if the system supports BSD or SysV tty handling.
- X #
- X if test ! "$osversion" -a ! "$v" ; then
- X while test ! "$v"
- X do
- X echo "Is your OS based on System V or on BSD 4.x ? I am really"
- X echo -n "interested in terminal handling. You can say sysv or bsd -->"
- X read ans
- X case $ans in
- X sysv) v=-DHAS_SYSVTTY ;;
- X bsd) v=-DHAS_BSDTTY ;;
- X *) echo "Please say either 'sysv' or 'bsd'"
- X esac
- X done
- X fi
- X lib_defs="$lib_defs $v"
- Xfi
- X
- Xif test "$autoconfig" ; then
- X rm -f $nmfile
- Xfi
- X
- X#
- X# If we know the OS, we can provide the appropriate flags for SIO
- X#
- Xcase "$osversion" in
- X sunos4) sio_defs="-DHAS_MMAP -DHAS_ONEXIT -DHAS_MEMOPS -DHAS_ISATTY" ;;
- X ultrix4) sio_defs="-DHAS_MEMOPS -DHAS_ATEXIT -DHAS_ISATTY" ;;
- X *) sio_defs="$lib_defs"
- Xesac
- X
- Xcase "$no_timers" in
- X yes) lib_names="$mandatory_libs" ;;
- X *)
- X case "$signal_handling" in
- X posix) lib_names="$mandatory_libs $optional_libs" ;;
- X bsd) lib_names="$mandatory_libs $optional_libs"
- X lib_defs="$lib_defs -DNO_POSIX_SIGS"
- X ;;
- X *) lib_names="$mandatory_libs"
- X esac
- Xesac
- X
- XPWD=`pwd`
- X
- Xincdir=$PWD/libs/include
- Xmandir=$PWD/libs/man
- Xlibdir=$PWD/libs/lib
- X
- X#
- X# Only Suns undestand .SB in man pages, so if we are not dealing with
- X# a Sun we replace .SB with .B
- X#
- Xif test "$osversion" = "sunos4" ; then
- X modify_manpages=
- Xelse
- X case "$has_SB" in
- X yes) modify_manpages= ;;
- X no) modify_manpages=yes ;;
- X *)
- X echo -n "Can your machine handle .SB in a man page ? (if you are not sure, say no) -->"
- X read x
- X if test "$x" = "n" -o "$x" = "no" ; then
- X modify_manpages=yes
- X else
- X modify_manpages=
- X fi
- X esac
- Xfi
- X
- Xif test "$modify_manpages" ; then
- X #
- X # We can't take any interrupts while processing the manpages
- X #
- X trap 'interrupt_occured=yes' $catch_sigs
- X
- X echo "Replacing .SB in library man pages with .B (if a man page is changed"
- X echo "the original will be kept by appending .orig to its name)"
- X for i in $lib_names
- X do
- X cd $PWD/libs/src/$i
- X for i in *.3
- X do
- X mv $i $i.orig # save the original
- X sed 's/[.]SB/.B/' $i.orig > $i # do the replacement
- X cmp -s $i $i.orig # are they the same ?
- X if test $? -eq 0 ; then rm $i.orig ; fi # if yes, remove the copy
- X done
- X if test "$interrupt_occured" = "yes" ; then
- X echo "Interrupt: quiting"
- X exit 1
- X fi
- X done
- X
- X trap $catch_sigs # no more trapping
- Xfi
- X
- X#
- X# Make the libraries
- X# Also prepare the value of the LIBS variable in the xinetd Makefile
- X#
- Xmvars="DEBUG=$ccopt MANDIR=$mandir INCLUDEDIR=$incdir LIBDIR=$libdir"
- Xfor i in $lib_names
- Xdo
- X libs="-l$i $libs"
- X cd $PWD/libs/src/$i
- X echo Making library: $i
- X #
- X # Remove the archive if it is already there; this is to avoid ld complaints
- X # that the table of contents is out of date.
- X #
- X rm -f lib$i.a
- X if test "$i" = "sio" ; then
- X make $mvars DEFS="$sio_defs" install
- X else
- X make $mvars DEFS="$lib_defs" install
- X fi
- X if test $? -ne 0 ; then
- X echo "Failed to create library: $i"
- X exit 2
- X fi
- Xdone
- X
- X#
- X# Now make xinetd
- X# We remove the xinetd executable, if there is one, in case the libraries
- X# have changed
- X#
- Xcd $PWD/xinetd
- Xrm -f xinetd
- Xmvars="DEBUG=$ccopt INCLUDEDIR=-I$incdir LDFLAGS=-L$libdir"
- Xif test "$custom" ; then xinetd_defs="$xinetd_defs -DCUSTOMCONF" ; fi
- Xmake "DEFS=$xinetd_defs" "LIBS=$libs" $mvars
- Xif test $? -ne 0 ; then
- X echo Failed to create xinetd
- X exit 2
- Xfi
- X
- Xif test "$modify_manpages" ; then
- X
- X trap 'interrupt_occured=yes' $catch_sigs
- X
- X echo "Replacing .SB in xinetd man pages with .B"
- X for i in *.man
- X do
- X mv $i $i.orig
- X sed 's/[.]SB/.B/' $i.orig > $i
- X cmp -s $i $i.orig # are they the same ?
- X if test $? -eq 0 ; then rm $i.orig ; fi # if yes, remove the copy
- X
- X if test "$interrupt_occured" = "yes" ; then
- X echo "Interrupt: quiting"
- X exit 1
- X fi
- X done
- X trap $catch_sigs # no more trapping
- Xfi
- X
- END_OF_FILE
- if test 16974 -ne `wc -c <'compile-src'`; then
- echo shar: \"'compile-src'\" unpacked with wrong size!
- fi
- chmod +x 'compile-src'
- # end of 'compile-src'
- fi
- echo shar: End of archive 26 \(of 31\).
- cp /dev/null ark26isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 31 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-