#
# Checks to see if Identd is installed on the machine.
#


&pcheck("Identd");
$failed = 1;

#
# Check inetd.conf to see if identd is installed.
#
if (open (INETD, $inetd)) {
	while (<INETD>) {
		next if (/^#/);
		if (/ident.*\s+/) {
			($srvname,$t,$t,$t,$t,$location) = split(/\s+/);
			$failed = 0;
		}
	}
	close (INETD);
} else {
	&report("ERROR: I can't open the $inetd file.\n");
	&error;
	exit 0;
}

if ($failed == 1) {
	&report("FAILED: Identd cannot be found in the inetd.conf file.\n");
	&failed;
	exit;
}

if (!-f $location) {
	&report("ERROR: Identd cannot be found at the path specified in the inetd.conf\n");
	&error;
	exit;
}


#
# Check the /etc/services file for the service
#
$failed2 = 1;
if (open (SERVICES, $services)) {
	while (<SERVICES>) {
		if (/\s*$srvname\s+/) {
			$failed2 = 0;
		}
	}
	close (SERVICES);
} else {
	&report("ERROR: I can't open the services file.\n");
	&error;
	exit;
}

if ($failed2 == 1) {
	&report("WARNING: The service \"$srvname\", which identd is listed under\n");
	&report("\tcannot be found on this system.\n");
	&warn;
	exit;
} else {
	&passed;
}

exit 0;
