#
# Checks the /var/sysgen/stune file for the current kernel parameters.
#
# (/var/sysgen/mtune/kernel check for suidshells)
# TODO: Check nosuidshells (should be on by default but.. )

$nfs_portmon = 1;
$restricted_chown = 1;

&pcheck("STUNE: $stune");

if (open(STUNE, $stune)) {
	while (<STUNE>) {
		next if (/^\*/);
		next if (/^\s*$/);
		@line = split(/\s+/);

		if (@line[0] eq "nfs_portmon") {
			if (@line[2] == 1) { $nfs_portmon = 0; }
		}

		if (@line[0] eq "restricted_chown") {
			if (@line[2] == 1) { $restricted_chown = 0; }
		}
	}
} else {
	&report("ERROR:  Could not open the kernel config file, $stune.\n");
	&error;
	exit;
}

if ($nfs_portmon) {
	&report("WARNING:  Your kernel does not have support for NFS\n",
	"\tport monitoring.  This will let any unprivleged user\n",
	"\taccess your nfsd.  To fix, set \"nfs_portmon = 1\" in\n",
	"\tthe $stune file.( Note: This may break machines with\n",
	"\tolder NFS implementations that mount from the SGI, so\n",
	"\ttest this to be sure it will work for you.)\n");
}

if ($restricted_chown) {
	&report("WARNING:  Your kernel does not have support for restricted\n",
	"\tchowning.  This will let any user change the ownership of\n",
	"\ta file to any other user.  To fix, set the flag\n",
	"\t\"restricted_chown = 1\" in the $stune file.\n");
}

if ($restricted_chown || $nfs_portmon) {
	&warn;
} else {
	&passed;
}

exit 0;
