X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=clients%2FHP%2Fbin%2Fmkpass.prenis;fp=clients%2FHP%2Fbin%2Fmkpass.prenis;h=c2b484cf7c87bd3ff554aef88a10bfdcdf39e5cc;hb=a8c84d2892f07a6863b68a11eb0a4a79ffd71fb5;hp=0000000000000000000000000000000000000000;hpb=95384f94f88aceeb5eef2d322210ba4a438b6512;p=clearscm.git diff --git a/clients/HP/bin/mkpass.prenis b/clients/HP/bin/mkpass.prenis new file mode 100644 index 0000000..c2b484c --- /dev/null +++ b/clients/HP/bin/mkpass.prenis @@ -0,0 +1,227 @@ +#!/bin/ksh +################################################################################ +# +# File: mkpass +# Description: Mother of All (MoA) passwd administration script +# Author: Cory Chan (cory@cup.hp.com) +# Language: Korn Shell +# Modified: 11/18/1994 Ryan Fong (fong@cup.hp.com) Modified for 10.0 +# 07/26/1995 Andrew DeFaria (defaria@cup.hp.com) Revamped to use +# NFS mount point to avoid rcp. Script now works for both 9.0 +# and 10.0. +# 08/21/1995 Andrew DeFaria (defaria@cup.hp.com) Revamped mail +# message sending. +# 03/25/98 Michael Coulter (coulter) Changed "ch.apollo" to +# "che.hp.com" because of a domain name change for Chelmsford. +# +# (c) Copyright 2001, Andrew@DeFaria.com, all rights reserved +# +################################################################################ +# First source the appserver script +if [ -x /app/appserver ]; then + . /app/appserver +fi + +# Set ADMIN_ROOT +ADMIN_ROOT=/app/admin + +# Check for force flag +FORCE="False" + +if [ "$1" = "-f" ]; then + FORCE="True" +fi + +# Whom to notify of problems. +NOTIFY=root@$(hostname) + +# Determine OS level +OS=`uname -r | cut -c 3-4` + +MASTER_PASSWD=$ADMIN_ROOT/lib/master_passwd +MASTER_PASSWD_MLL=$ADMIN_ROOT/lib/master_passwd.mll +LOCAL_PASSWD=/etc/passwd.loc +EXCLUDED_PASSWD=/etc/passwd.exc +MARKER_FILE=/etc/pass.time +PASSWD_OLD=/etc/passwd.old +PASSWD=/etc/passwd +TMP_PASSWD=/tmp/passwd.$$ +TMP_PASSWD2=/tmp/passwd2.$$ + +# Log and save old messages if there were any problems +MESSAGE_FILE=$ADMIN_ROOT/log/mkpass.$(uname -n) + +# Set file attribute +umask 022 +# Check for existance of $MASTER_PASSWD file. If missing send message and +# abort. +if [[ ! -f $MASTER_PASSWD ]]; then + mailx -s "mkpass: $MASTER_PASSWD file is missing!" $NOTIFY < /dev/null + exit 1 +fi + +# Check existence of necessary files; make when necessary. +if [[ ! -f $MARKER_FILE ]]; then + # make time marker if not exists + touch $MARKER_FILE +fi + +if [[ ! -f $EXCLUDED_PASSWD ]]; then + echo "# one login per line, no space/tab/null line#" > $EXCLUDED_PASSWD +fi + +if [[ ! -f $PASSWD_OLD ]]; then + # make old passwd file if not exists + cp $PASSWD $PASSWD_OLD +fi + +if [[ ! -f $LOCAL_PASSWD ]]; then + # no local file, notify and exit + cat > $MESSAGE_FILE < $MESSAGE_FILE < = /etc/passwd.old) +----------------------------------------------------------------------------- +!EOM + diff $PASSWD $PASSWD_OLD >> $MESSAGE_FILE + mailx -s "mkpass: $PASSWD incorrectly changed" $NOTIFY < $MESSAGE_FILE + exit 0 + fi +fi + +# Check to see if $LOCAL_PASSWD, $MASTER_PASSWD or $EXCLUDED_PASSWD is newer +# than $PASSWD. If so, combine $LOCAL_PASSWD and $MASTER_PASSWD (excluding +# entries from $EXCLUDED_PASSWD) to form new $PASSWD +if [[ $FORCE = "True" || + $LOCAL_PASSWD -nt $PASSWD || + $MASTER_PASSWD -nt $PASSWD || + $MASTER_PASSWD_MLL -nt $PASSWD || + $EXCLUDED_PASSWD -nt $PASSWD ]]; then + + # If only the $MASTER_PASSWD changed then make a note not to send email + if [[ $LOCAL_PASSWD -nt $PASSWD || + $EXCLUDED_PASSWD -nt $PASSWD ]]; then + NOTIFY_OF_CHANGE=True + else + NOTIFY_OF_CHANGE=False + fi + + # Save an old copy around + cp $PASSWD $PASSWD_OLD + + # Check root entry in $LOCAL_PASSWD + if grep -v "^#" $LOCAL_PASSWD | head -n 1 | grep "^root:" > /dev/null; then + # 1st entry root OKAY in $LOCAL_PASSWD + : + else + # 1st entry NOT root in passwd.loc + cat > $MESSAGE_FILE <> $TMP_PASSWD2 + done < $MASTER_PASSWD_MLL + + cat $LOCAL_PASSWD $MASTER_PASSWD $TMP_PASSWD2 > $TMP_PASSWD + + # Do exclusion + grep -v "^#" $EXCLUDED_PASSWD |\ + grep -vf $EXCLUDED_PASSWD $TMP_PASSWD > $TMP_PASSWD2 + + # Transform password file to 10.0 format + if [ $OS = "10" ]; then + sed -e 's/:\/nfs/:\/net/' -e 's/:\/bin/:\/usr\/bin/' \ + $TMP_PASSWD2 > $TMP_PASSWD + rm -f $TMP_PASSWD2 + else + mv $TMP_PASSWD2 $TMP_PASSWD + fi + + if [ -s $TMP_PASSWD ]; then + mv $TMP_PASSWD $PASSWD + chmod 444 $PASSWD + else + rm -f $TMP_PASSWD + mailx -s "mkpass: Error: Zero length passwd file resulted!" $NOTIFY < $MESSAGE_FILE < = /etc/passwd.old) +----------------------------------------------------------------------------- +!EOM + diff $PASSWD $PASSWD_OLD >> $MESSAGE_FILE + mailx -s "mkpass: Made new $PASSWD" $NOTIFY < $MESSAGE_FILE + fi +fi + +# Update marker file +touch -ma $MARKER_FILE + +# Update log file +echo "$PASSWD on `uname -n` is up to date as of `date`" > $MESSAGE_FILE + +exit 0