Change password script....

Our help desk group has a shared account and runs a menu on each system to perform their daily tasks, among those tasks is changing user account passwords.

I am trying to fix this account password change script that is part of the menu. Our help desk group runs this script below to change user passwords. But as of late, the script has not worked properly. When a user password is changed by the script, it appears to have worked. But if the same user attempts to log into the same system with the new password, they will get an access denied message. This has happened to Solaris 8, 9, and 10 systems. I have no idea on what has gone wrong. Can anyone help, please? Thanks in advance.

ECHO=/usr/bin/echo

BACKUPDIR=/admin/sys_backup

$ECHO "Enter USERNAME: "

read USERNAME

if [ "$USERNAME" = "" ]; then

$ECHO ""

$ECHO "*** SORRY: MUST ENTER A USERNAME!! ***"

$ECHO ""

/bin/sh $BACKUPDIR/not_change_root

fi

GROUPID="`grep $USERNAME /etc/passwd | cut -d: -f4 - `"

GROUPNAME="`grep ":$GROUPID:" /etc/group | cut -d: -f1 - `"

if [ "$USERNAME" = "root" ]; then

$ECHO ""

$ECHO "*** SORRY: CAN'T CHANGE THE ROOT PASSWORD!! ***"

$ECHO ""

/bin/sh $BACKUPDIR/not_change_root

fi

if [ "$GROUPNAME" = "csg" ]; then

$ECHO ""

$ECHO "*** SORRY: CAN'T CHANGE CSG MEMBER'S PASSWORD!! ***"

$ECHO ""

/bin/sh $BACKUPDIR/not_change_root

fi

/usr/local/bin/sudo /usr/bin/passwd $USERNAME

/usr/local/bin/sudo /usr/bin/passwd -f -x 90 -w 10 $USERNAME

$ECHO ""

$ECHO ""

$ECHO "Password for $USERNAME was SUCCESSFULLY changed."

$ECHO ""

$ECHO ""

sleep 2

[2004 byte] By [DCAdmin] at [2007-11-25 22:51:00]
# 1

I am not sure of why it is not working but would ask the following question concerning the script:

On the premise tou have a user called fred and one called frederick, what will be returned as a result of your <b>GROUPID="`grep $USERNAME /etc/passwd | cut -d: -f4 - `"

</b> command?

SimonM at 2007-7-5 17:06:27 > top of Java-index,General,Sun Networking Services and Protocols...
# 2

To answer your question, I used two user accounts test1 and test123 and they both in the same group.....group id = 32. I ran the GROUPID script and this is what I got:

bash-2.03# grep test123 /etc/passwd | cut -d: -f4 -

32

bash-2.03# grep test1 /etc/passwd | cut -d: -f4 -

32

32

DCAdmin at 2007-7-5 17:06:27 > top of Java-index,General,Sun Networking Services and Protocols...
# 3
Yes, that is the sort of output I would expect ... now - what happens when that variable (with the value "32\n32") in it is used in your next command: <b>GROUPNAME="`grep ":$GROUPID:" /etc/group | cut -d: -f1 - `"</b>?
SimonM at 2007-7-5 17:06:27 > top of Java-index,General,Sun Networking Services and Protocols...
# 4
I beilve all that does is make sure they are not in the "csg" script. Can you post your exact error message? I would look into permissions of the script and the user who is running it. I also see you are using sudo check the sudoers file settings.
SteveC at 2007-7-5 17:06:27 > top of Java-index,General,Sun Networking Services and Protocols...