#!/bin/sh
#
# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# ident	"@(#)S36_fix_pam_conf.sh	1.1	08/05/06 SMI"
#

# Comment out any Solaris Resource Manager entries in /etc/pam.conf.
#
# As part of the p2v module interface there are environment variables set for
# this script (e.g. FILEDIR - path to brand-specific file repository).
# See the p2v script for a full list of variables.
#

nawk '{
	if (substr($1, 0, 1) == "#") {
		print $0
	} else if (match($0, "pam_srm\.so\.1") != 0) {
		print "#", $0
		modified=1
	} else {
		print $0
	}
}
END {
	if (modified == 1) {
		printf("# Modified by p2v ")
		system("/usr/bin/date")
		exit 0
	}
	exit 1
}' /etc/pam.conf >/tmp/pam.conf.$$

if [ $? -eq 0 ]; then
	if [ ! -f /etc/pam.conf.pre_p2v ]; then
		cp -p /etc/pam.conf /etc/pam.conf.pre_p2v
	fi
	cp /tmp/pam.conf.$$ /etc/pam.conf
fi
rm -f /tmp/pam.conf.$$
