jeo wrote:
Hi canit0!
What sort of issues are you having on AIX? I don't have access to an AIX shell at the moment, but I used to do a lot of cross *nix scripting. Stuff that had to work on Linux, AIX, HPUX, and Solaris...
Hi jeo-
Thank you for asking. I am not that familiar with AIX and the passwd file in /etc/security. When trying to calculate the password age using the lastupdate number for a given user I don't know what that number means if days, seconds, weeks, so I am working on that at the moment. But this script will need to work on AIX, Linux, HPUX, Solaris.
Ok, I just learned this is in seconds since EPOCH time.

-->

-----------------------------------------------------------------
I just updated the script and *believe* to have it working in AIX.
I just converted the lastupdate time which is set to EPOCH time in seconds to EPOCH days.
Some one please confirm?
Code:
#!/bin/sh
set -x
HOST=`uname -n`
USER=`id -u`
MAX=30
SYS=`uname`
###--- Function to check password age for the Linux root account.
LINUX (){
read USER
CURRENT_EPOCH=`grep $USER /etc/shadow | cut -d: -f3`
if [ "$CURRENT_EPOCH" = "" ]; then
return
fi
# Find the epoch time since the user's password was last changed
EPOCH=`perl -e 'print int(time/(60*60*24))'`
# Compute the age of the user's password
AGE=`echo $EPOCH - $CURRENT_EPOCH | bc`
if [ "$AGE" -ge "$MAX" ]; then
echo "The user's password is $AGE days old on $HOST"
fi
}
AIX () {
CURRENT_EPOCH=`awk 'BEGIN { i=0 } /root/ { while (i < 2 ) { getline; print $0; i++ } i=0}' "/test/passwd" |awk '/lastupdate/ {print $3}'`
if [ "$CURRENT_EPOCH" = "" ]; then
return
fi
# Converting EPOCH time in seconds to days
EPOCH_DAYS=`perl -e 'print ($CURRENT_EPOCH/(60*60*24))'`
# Find the epoch time since the user's password was last changed
EPOCH=`perl -e 'print int(time/(60*60*24))'`
# Compute the age of the user's password
AGE=`echo $EPOCH - $EPOCH_DAYS | bc`
if [ "$AGE" -ge "$MAX" ]; then
echo "The user's password is $AGE days old on $HOST"
else
echo "Password is fine and is $AGE days old"
fi
}
#--- Need root permissions to run script
if [[ $USER -ne 0 ]];
then
echo "Must be root to run this script!!"
exit 2
fi
case $(uname) in
Linux ) LINUX ;;
AIX ) AIX ;;
esac
I am having problems with the conversion and it is not working for AIX at this time.