#!/bin/sh
# Wrapper file for Crack
# written by Javier Fernandez-Sanguino for the Debian GNU/Linux distribution
# 
# Licensed under the GNU GPL v2.
# See /usr/share/doc/common-licenses/GPL

# This is needed due to relative calls to 'dawg' and co.
PATH=/usr/lib/Crack:$PATH
export PATH

if [ "`id -u`" != "0" ]
then
  echo "Crack requires root priviledges to run."
  exit 1
fi

cd /usr/share/Crack
MERGED=`tempfile -d run`
if [ "$1" = "/etc/passwd" -a "$2" = "" ] ;
then
# User supplied one argument (hasn't read the instructions :)
# Check if there is a shadow file
	if [ -f /etc/shadow ] ; then
	>$MERGED
	# Just in case..
	chmod 600 $MERGED
 	sh scripts/shadmrg.sv >$MERGED
	./Crack $MERGED
	[ -f $MERGED ] && /bin/rm $MERGED
	else
	./Crack $*
	fi
else
	./Crack $*
fi
