X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=clients%2FHP%2Fbin%2Fpdl-new-passwd;fp=clients%2FHP%2Fbin%2Fpdl-new-passwd;h=a6f13e752e52fee021f03844aaab34b3578f753a;hb=a8c84d2892f07a6863b68a11eb0a4a79ffd71fb5;hp=0000000000000000000000000000000000000000;hpb=95384f94f88aceeb5eef2d322210ba4a438b6512;p=clearscm.git diff --git a/clients/HP/bin/pdl-new-passwd b/clients/HP/bin/pdl-new-passwd new file mode 100644 index 0000000..a6f13e7 --- /dev/null +++ b/clients/HP/bin/pdl-new-passwd @@ -0,0 +1,63 @@ +#!/bin/ksh +################################################################################ +# +# File: newpasswd +# Description: Change the root passwd entry in /etc/passwd +# Author: Kevin Lister kel@cup.hp.com +# Language: Korn Shell +# +# (c) Copyright 1999, Hewlett-Packard Company, all rights reserved. +# +################################################################################ +# +## +### Variables +## +# + +ADMIN=pdl-support@cup.hp.com +PWFILE=/etc/passwd +PWFILENEW=/etc/passwd-new +PWFILEOLD=/etc/passwd-old +SYSNAME=$(uname -n) +BASE=${0##*/} +WHOAMI=$(id -u) +NULL=/dev/null + +# +## +### Functions +## +# + +# Functions +function error { + print -u2 "$BASE: Error: $1" +} + +# +## +### Main +## +# + +# Must be root to run this +if [ $WHOAMI -ne 0 ]; then + error "Must be root to execute this command... Exiting." + exit 0 +fi + +# Create the new passwd file +/bin/cat >> $PWFILENEW <<:NEWPW +root:u4/rTgJX35zHg:0:1:Root@$SYSNAME:/:/sbin/sh +:NEWPW +/bin/grep -v "^root" $PWFILE >> $PWFILENEW + +# Save the old passwd file, install the new one +/bin/mv $PWFILE $PWFILEOLD +/bin/mv $PWFILENEW $PWFILE +/bin/chmod 444 $PWFILE +/bin/chown root:other $PWFILE + +# Email us that a machine was updated +/usr/bin/mailx -s "$SYSNAME: Root passwd changed!" $ADMIN < $NULL