Listing 1

#	fchk ----	check file permissions, owner, and group
#
#	@(#)fchk	1.22  7/23/93  /sccs/u/wdr/bin/s.fchk
#
#	developer:	Bill Rieken	4B77	x6027	(408) 241-8319
#
#	function:	check system integrity (boo-boos & badguys)
#
#	usage:	#  fchk
#		$  /letc/fchk
#		$  /usr/local/etc/fchk
#
#		(executed daily at 2am by 'Safe' from 'cron')
#
#	side effects:		Will not port to pre-Release 2.0 systems
#			because a shell function is used.
#			However, it works with both Bourne Shell
#			                        and Korn   Shell.
#
#	method:	define a shell function to 'check' a file:
#
#	FILE	PERMISSIONS	OWNER	GROUP
#
#	list the files you want checked!
#
#	/full/path/name	-rwxr-x--x	wdr	A-team
#	/etc/passwd	-rw-r--r--	root	sys
#	/etc	drwxr-xr-x	root	sys
#
#---------------------------------------------------------------
check()					#  check  file  permissions
{
FILE=$1; PERM=$2; OWNER=$3; GROUP=$4

set - `ls -ld $FILE` || \		#  get  ls  output  in  $1,  $2, ...
	{
	echo "$FILE DOES NOT EXIST *** should be $PERM $OWNER $GROUP"
	return
	}
[ $1 != "$PERM"  ]	&& echo "$FILE should be $PERM"
[ $3 != "$OWNER" ]	&& echo "$FILE should be owned by $OWNER"
[ $4 != "$GROUP" ]	&& echo "$FILE should have group owner $GROUP"
}
#  The following files will be checked.  Edit this file and add
#  files as you learn their importance.
#	FILE				PERMISSIONS	OWNER	GROUP
check	/u/wdr/.profile			-r--r--r--	wdr	users
check	/				drwxr-xr-x	root	root
check	/etc				drwxr-xr-x	root	root
check	/letc				drwxr-xr-x	root	root
check	/bin				drwxr-xr-x	bin	bin
check	/usr/bin			drwxr-xr-x	bin	bin
check	/dev				drwxr-xr-x	root	root
check	/usr				drwxr-xr-x	root	root
check	/etc/passwd			-r--r--r--	root	root
check	/etc/group			-r--r--r--	root	root
check	/usr/lib/crontab		-r--------	root	root
check	/usr/adm/cronlog		-rw-------	root	root
check	/usr/adm/sulog			-rw-------	root	root
check	/usr/lib/uucp/Systems		-r--------	uucp	root
check	/usr/lib/uucp/Devices		-r--------	uucp	root
check	/usr/lib/uucp/Dialers		-r--------	uucp	root
check	/usr/lib/uucp/Permissions	-r--------	uucp	root
check	/usr/bin/uucp			---s--x--x	uucp	bin
check	/usr/bin/uuname			---s--x--x	uucp	bin
check	/usr/bin/cu			---s--x--x	uucp	bin
check	/usr/bin/ct			----------	root	root


