return to PRS Technologies website


login_enable.sh
#!/usr/bin/ksh ############################################################################### # # Module: login_enable.sh # Author: Peter R. Schmidt # Description: Enable Unix and Elite-for-Windows logins # # Change Log # # Date Name Description................. # 10/28/01 Peter R. Schmidt Start Program # ############################################################################### CRITICAL="root informix" SYSTEM="root daemon bin sys adm uucp lp nuucp hpdb nobody" if [ $LOGNAME != 'root' ]; then echo "Sorry - you must be logged on a 'root' to run this program." exit 1 fi . /elite/custom/run.elite DISABLE=/usr/local/custom/login_disable if [ ! -f $DISABLE ] then echo echo "NOTE: Unix login was ALREADY enabled" exit 0 fi #------------------------------------------------------------------------------- CUSTOM=/usr/local/custom PASSWD=/etc/passwd PASSWD_BACKUP=/etc/passwd.DISABLE PASSWD_PREVIOUS=/etc/passwd.DISABLE.PREVIOUS if [ ! -d $CUSTOM ]; then echo "Error: $CUSTOM does not exist." exit 1 fi if [ ! -f $PASSWD ]; then echo "Error: $PASSWD does not exist." exit 1 fi if [ ! -w $PASSWD ]; then echo "Error: $PASSWD is not writable - which is required for this program." exit 1 fi if [ ! -f $PASSWD_BACKUP ]; then echo "Error: $PASSWD_BACKUP does not exist!" echo "This could be a serious problem." exit 1 fi #------------------------------------------------------------------------------- # Check integrity of backup file echo echo "Checking integrity of the passwd backup..." echo for LOGIN in $SYSTEM do CNT=`egrep -c "^${LOGIN}:" $PASSWD_BACKUP` if [ $CNT != 1 ]; then echo "Error: for some reason, the login for $LOGIN was not in the $PASSWD_BACKUP file" echo "or exists more then once." echo "This suggests we should NOT overwrite the $PASSWD file with the $PASSWD_BACKUP file." echo "Program terminated!" exit 1 fi done for LOGIN in $CRITICAL do CNT=`egrep -c "^${LOGIN}:" $PASSWD_BACKUP` if [ $CNT != 1 ]; then echo "Error: for some reason, the login for $LOGIN was not in the $PASSWD_BACKUP file" echo "or exists more then once." echo "This suggests we should NOT overwrite the $PASSWD file with the $PASSWD_BACKUP file." echo "Program terminated!" exit 1 fi done WC_PASSWD=`cat $PASSWD | wc -l` WC_BACKUP=`cat $PASSWD_BACKUP | wc -l` if [ $WC_PASSWD -ge $WC_BACKUP ]; then echo "The $PASSWD is bigger then the $PASSWD_BACKUP file." echo "This is unexpected and should be checked out and corrected before proceeding." exit 1 fi #------------------------------------------------------------------------------- # All checks passwd - re-enable all logins echo "Restoring original passwd from backup..." echo rm -f $PASSWD_PREVIOUS cp -p $PASSWD $PASSWD_PREVIOUS # Save the old passwd file - just in case cp -p $PASSWD_BACKUP $PASSWD # Restore from backup rm -f $PASSWD_BACKUP rm -f $DISABLE UDATE=`date` echo "Unix login is ENABLED" echo "by $LOGNAME on $UDATE" ################################################################################