# $Header: /projects/insg/frontd.insg/RCS/Makefile,v 2.3 1992/04/29 22:45:17 ylee Exp ylee $
#
# $Log: Makefile,v $
# Revision 2.3  1992/04/29  22:45:17  ylee
# -Extensively revised
#
# Revision 2.2  1992/03/03  22:31:39  ylee
# -Comment out FACILITY.
#
# Revision 2.1  1992/03/03  18:03:46  ylee
# -Comment out PARANOID, BUGS, and AUX_OBJ
#
# Revision 2.0  1992/03/02  22:38:41  ylee
# -Wietse Venema's Makefile for tcp_wrapper package.
#
# Revision 1.1  1992/03/02  22:07:35  ylee
# -Initial revision, complete rewritten by YDL.
#
#
#

# @(#) Makefile 1.4 91/10/04 21:28:11

##############################
## Begin configuration options

# Names of executables
FRONTD=frontd
RSHD=in.rshd
RLOGIND=in.rlogind
PIAS=pias

# By default, logfile entries are written to the same file as used for
# sendmail transaction logs. Change the definition of the following macro
# if you disagree. See /usr/include/syslog.h for examples. Some syslog
# versions do not provide this flexibility.
#
# (YDL) Fixed in the programs to use LOG_DAEMON with priority NOTICE
# and higher for logging.  This makes it possible to produce log entries
# in /var/adm/messages with the /etc/syslog.conf distributed with SunOS.

# >>>--------------- macros that affect 'frontd'
# Comment out the following macro denition if you don't want 'frontd'
# to produce log entries of its activities.

DO_LOG= -DDO_LOG

# Comment out the following macro denition if you don't want 'frontd'
# to use access control (using /etc/hosts.allow and /etc/hosts.deny).

HOSTS_ACCESS= -DHOSTS_ACCESS

# Comment out the following macro denition if you don't want 'frontd'
# to reject all requests from host for whom we have problems matching
# its host name with its IP address.

#SUSPICIOUS= -DSUSPICIOUS

# If your system supports NIS or YP-style netgroups, enable the following
# macro definition.

NETGROUP= -DNETGROUP

# ---------------<<< macros that affect 'frontd'

# Note in.rshd and in.rlogind are not affected by the settings of
# DO_LOG, HOSTS_ACCESS, and SUSPICIOUS.


# Some versions of apollo UNIX have a bug in the getpeername(2) routine.
# You have this bug if the front end reports that all UDP connections come
# from address 0.0.0.0. Compile with -DGETPEERNAME_BUG for a workaround.

#BUGS	= -DGETPEERNAME_BUG

# Apollo Domain/OS offers both bsd and sys5 environments, sometimes
# on the same machine.  If your Apollo is primarily sys5.3 and also
# has bsd4.3, enable the following to build under bsd and run under
# either environment.

#SYSTYPE=  -A run,any -A sys,any

# Include the file strcasecmp.o if it is not provided by your C library.
# The strcasecmp.c file provided with this package comes from BSD UNIX.

#AUX_OBJ	= strcasecmp.o

# Some System-V versions require that you explicitly specify the networking
# libraries (for example, -lnet or -linet).

#LIBS	= -lnet

# --------------->>> macros that affect 'pias'

# File that 'pias' uses to keep track of commands executed and
# time of execution.  Default is /var/tmp/pias_trackfile
# and need not be specified here.  If other file name is perferred,
# put the full-pathed name with "" and uncomment the line below.

#PIAS_FILE='-DPIAS_FILE="/tmp/pias_trackfile"'

# Max. number of seconds that can be specified for the 'timeperiod'
# argument for 'pias'.  Default is 7200 (i.e., 2 hrs.) and need
# not be specified here.  If a different number is preferred,
# replace 7200 with the preferred number and un-comment the
# line below.

#PIAS_MAX_PERIOD='-DPIAS_MAX_PERIOD=7200'

# The uid that 'pias' will assume while creating and updating
# the PIAS_FILE.  Default is 65534 (i.e., uid for user 'nobody')
# and need not be specified here.  If a different uid is preferred,
# replace 65534 with the preferred uid and un-comment the
# line below.

#PIAS_UID='-DPIAS_UID=65534'

# ---------------<<< macros that affect 'pias'

# Full-path filenames of the access-control files.
# Defaults are /etc/hosts.allow and /etc/hosts.deny,
# and do not have to be specified here.  If other
# file names are preferred, put the full-pathed
# name(s) within "" and uncomment the line(s).

#HOSTS_ALLOW='-DHOSTS_ALLOW="/etc/hosts.allow"'
#HOSTS_DENY='-DHOSTS_DENY="/etc/hosts.deny"'

# Parent directory into which man pages should be installed
# The man pages will be installed in ${MANDIR}/man5 and ${MANDIR}/man8.
MANDIR=/usr/local/man

# Directory into which the frontd, rlogind, rshd, and pias should be installed
NETDAEMON_DIR=/usr/etc

# The inetd configuration file, include full path
INETD_CONF=/etc/inetd.conf

# If your C library does not have memcmp(3), compile with -Dmemcmp=bcmp.

CFLAGS	= -O $(HOSTS_ACCESS) $(HOSTS_ALLOW) $(SUSPICIOUS) $(DO_LOG)\
	$(HOSTS_DENY) $(NETGROUP) $(BUGS) $(SYSTYPE)

## End configuration options
############################

# current date and time in form of yymmddHHMM
DATETIME:sh=/bin/date +'%y%m%d%H%M'

TCPD_OBJ= tcpd.o fromhost.o hosts_access.o shell_cmd.o refuse.o
TRY_OBJ	= try.o hosts_access.o shell_cmd.o
RLOGIND_OBJ= rlogind.o fromhost.o hosts_access.o shell_cmd.o logout.o logwtmp.o
RSHD_OBJ= rshd.o fromhost.o hosts_access.o shell_cmd.o

all:	$(FRONTD) $(RLOGIND) $(RSHD) $(PIAS) try

$(FRONTD):	$(TCPD_OBJ) $(AUX_OBJ)
	$(CC) $(CFLAGS) -o $@ $(TCPD_OBJ) $(AUX_OBJ) $(LIBS)

$(RSHD): $(RSHD_OBJ)
	$(CC) $(CFLAGS) -o $@ $(RSHD_OBJ)

$(RLOGIND): $(RLOGIND_OBJ)
	$(CC) $(CFLAGS) -o $@ $(RLOGIND_OBJ)

$(PIAS): pias.c
	$(CC) $(PIAS_FILE) $(PIAS_MAX_PERIOD) $(PIAS_UID) -O -o $@ pias.c

printuid: printuid.c
	cc -O -o printuid printuid.c

try:	$(TRY_OBJ) $(AUX_OBJ)
	$(CC) $(CFLAGS) -o try $(TRY_OBJ) $(AUX_OBJ)


# install may only be done by root

install: install_bin install_man remind

install_bin: ${FRONTD} ${RLOGIND} ${RSHD} ${PIAS} \
	inetd.conf.sample hosts.allow.sample hosts.deny.sample
# copy executables to destination directory
	-mv ${NETDAEMON_DIR}/${FRONTD} ${NETDAEMON_DIR}/${FRONTD}.${DATETIME}
	install -c -m 0755 ${FRONTD} ${NETDAEMON_DIR}
	-mv ${NETDAEMON_DIR}/${RLOGIND} ${NETDAEMON_DIR}/${RLOGIND}.${DATETIME}
	install -c -m 0755 ${RLOGIND} ${NETDAEMON_DIR}
	-mv ${NETDAEMON_DIR}/${RSHD} ${NETDAEMON_DIR}/${RSHD}.${DATETIME}
	install -c -m 0755 ${RSHD} ${NETDAEMON_DIR}
	-mv ${NETDAEMON_DIR}/${PIAS} ${NETDAEMON_DIR}/${PIAS}.${DATETIME}
	install -c -m 4755 ${PIAS} ${NETDAEMON_DIR}
	@echo "-All executables has been installed into ${NETDAEMON_DIR}."
# copy sample control files
	install -m 744 inetd.conf.sample /etc
	install -m 744 hosts.allow.sample /etc
	install -m 744 hosts.deny.sample /etc
	@echo "-Sample configuration files inetd.conf.sample, hosts.allow.sample,"
	@echo " and hosts.deny.sample have been copied into /etc.  Please edit"
	@echo " the files according to the requirements of your site (be sure"
	@echo " you read the man pages thoroughly before editing the files), rename"
	@echo " them by dropping the '.sample' part, and send HUP signal to inetd"
	@echo " process to get the desired actions activated."
	@echo

install_man: hosts_access.5 rlogind.8 rshd.8 frontd.8 pias.8 \
	in.frontd.8 in.rlogind.8 in.rshd.8 hosts.allow.5 hosts.deny.5
# install man page for hosts_access
	-mv ${MANDIR}/man5/hosts_access.5 ${MANDIR}/man5/hosts_access.5.${DATETIME}
	install -m 444 hosts_access.5 ${MANDIR}/man5
	-mv ${MANDIR}/man5/hosts.allow.5 ${MANDIR}/man5/hosts.allow.5.${DATETIME}
	install -m 444 hosts.allow.5 ${MANDIR}/man5
	-mv ${MANDIR}/man5/hosts.deny.5 ${MANDIR}/man5/hosts.deny.5.${DATETIME}
	install -m 444 hosts.deny.5 ${MANDIR}/man5
	-mv ${MANDIR}/man8/rlogind.8 ${MANDIR}/man8/rlogind.8.${DATETIME}
	install -m 444 rlogind.8 ${MANDIR}/man8
	-mv ${MANDIR}/man8/in.rlogind.8 ${MANDIR}/man8/in.rlogind.8.${DATETIME}
	install -m 444 in.rlogind.8 ${MANDIR}/man8
	-mv ${MANDIR}/man8/rshd.8 ${MANDIR}/man8/rshd.8.${DATETIME}
	install -m 444 rshd.8 ${MANDIR}/man8
	-mv ${MANDIR}/man8/in.rshd.8 ${MANDIR}/man8/in.rshd.8.${DATETIME}
	install -m 444 in.rshd.8 ${MANDIR}/man8
	-mv ${MANDIR}/man8/pias.8 ${MANDIR}/man8/pias.8.${DATETIME}
	install -m 444 pias.8 ${MANDIR}/man8
	-mv ${MANDIR}/man8/frontd.8 ${MANDIR}/man8/frontd.8.${DATETIME}
	install -m 444 frontd.8 ${MANDIR}/man8
	-mv ${MANDIR}/man8/in.frontd.8 ${MANDIR}/man8/in.frontd.8.${DATETIME}
	install -m 444 in.frontd.8 ${MANDIR}/man8
	@echo "-Man pages for hosts_access, frontd, pias, (in.)rlogind, (in.)rshd has been"
	@echo " added/updated.  Please use 'man hosts_access', 'man frontd', 'man pias',"
	@echo " 'man rlogind', and 'man rshd' to refer to them."
	@echo

remind:
# Some reminders:
	@echo "-Please edit the files /etc/inetd.conf.sample, /etc/hosts.allow.sample,"
	@echo " and /etc/hosts.deny.sample according to the requirements of your site (be"
	@echo " sure you read the man pages thoroughly before editing the files), rename"
	@echo " them by dropping the '.sample' part, and send HUP signal to inetd"
	@echo " process to get the desired actions activated."
	@echo "-The file /etc/syslog.conf controls all the system logging activities."
	@echo " If you don't see log entries of networking activities showing up"
	@echo " in /var/adm/messages, you may have to change /etc/syslog.conf and"
	@echo " send a HUP signal to syslogd process."
	@echo

clean:
	-rm -f ${FRONTD} ${RSHD} ${RLOGIND} ${PIAS} try *.o core

# Enable all bells and whistles for linting.

lint:
	lint -DFACILITY=LOG_MAIL -DHOSTS_ACCESS -DPARANOID -DNETGROUP \
	-DGETPEERNAME_BUG tcpd.c fromhost.c hosts_access.c shell_cmd.c refuse.c
	lint -DFACILITY=LOG_MAIL -DHOSTS_ACCESS -DPARANOID -DNETGROUP \
	-DGETPEERNAME_BUG miscd.c fromhost.c hosts_access.c shell_cmd.c refuse.c

# Compilation dependencies.

rlogind.o: rlogind.c log_tcp.h
rshd.o: rshd.c log_tcp.h
fromhost.o : fromhost.c log_tcp.h Makefile
hosts_access.o : hosts_access.c Makefile
miscd.o : miscd.c log_tcp.h Makefile
refuse.o : refuse.c log_tcp.h
shell_cmd.o : shell_cmd.c Makefile
strcasecmp.o : strcasecmp.c 
tcpd.o : tcpd.c log_tcp.h Makefile
try.o : try.c Makefile
