#!/bin/ksh
# Script fl by Gary L. Armstrong
# v1.1 : Resets a user's failed login count.
# v1.2 : and removes admin lock if present.

Version=1.2

# Simple, no?
if [[ -z $1 ]]; then
        print "Specify a user name to reset and try again:"
        print "fl \"username\""
        exit 1
else
        chsec -f /etc/security/lastlog -a "unsuccessful_login_count=0" -s $1
        if [[ $? -gt 0 ]]; then
                print "Error from chsec command"
                exit $?
        else
                chuser account_locked='false' $1
                if [[ $? -gt 0 ]]; then
                        print "Error from chuser command"
                        exit $?
                else
                        print "User $1's account lock is set to false"
                fi
                print "User $1's login count reset"
                exit 0
        fi
fi