#!/bin/sh -e

echo "Setting password ages"

login_defs_sed_script='s/PASS_MAX_DAYS.*$/PASS_MAX_DAYS 90/
s/PASS_MIN_DAYS.*$/PASS_MIN_DAYS 10/
s/PASS_WARN_AGE.*$/PASS_WARN_AGE 7/'
if [ "$cpch_DRY_RUN" -eq 0 ]; then
	sed --in-place=.bak -e "$login_defs_sed_script" /etc/login.defs
	if [ "$cpch_VERBOSITY" -gt 0 ]; then
		diff /etc/login.defs /etc/login.defs.bak
	fi
else
	sed -e "$login_defs_sed_script" /etc/login.defs |
		if [ "$cpch_VERBOSITY" -gt 0 ]; then diff /etc/login.defs -; fi
fi
