#!/bin/ksh ## ## SCRIPT: chk_varmail ## ## Where: in $FEDIR/scripts where $FEDIR=/apps/nns_com/fea ## ########################################################################### ## PURPOSE: Checks /var/mail/$USER files on SGI mail server to see if ## they are owned by the user $USER. ## ## Uses the 'ls' and 'awk' commands. ## ########################################################################### ## CALL FORMAT: feamain -> office_utils.menu -> mailhelp.menu ## (or manually) ## ########################################################################### ## MAINTENANCE HISTORY: ## Written by : B. Montandon 12Jan1998 ## Last Update: B. Montandon 17Apr2000 Chg server from 'sgia' to 'engprd00' ## in var SERVER. ########################################################################### SERVER="engprd00" if test "$FEDIR" = "" then FEDIR="/apps/nns_com/fea" fi THISHOST=`hostname` ########################################################################### # THISHOST=`hostname` # # if test ! "$THISHOST" = "$SERVER" # then # echo " # This script should be run on * $SERVER * for best performance and to reduce # some load on the network. # # *** Press Enter to exit/continue. # " # read NNS_JUNK # exit # fi ############################################################################## ############################################################################## ## GENERATE THE NAME OF THE OUTPUT-REPORT FILE. ############################################################################## . $FEDIR/scripts/set_localoutlist rm -f $OUTLIST ############################################################################## ## GENERATE THE HEADING OF THE OUTPUT-REPORT FILE. ############################################################################## echo "\ ************** `date '+%Y %b %d %T%p'` ************************ CHECK OF OWNERSHIP OF $SERVER NETWORK /var/mail DIRECTORIES. An exception list follows. Normally the mail file of a user, abc00, is owned by that user. Example: /var/mail/abc00 is owned by abc00. This exception list indicates /var/mail files that are NOT owned by the userid shown in the name of the mail file. OWNER FILENAME ---------- ------------ " > $OUTLIST ############################################################################## ## GENERATE THE HEADING OF THE OUTPUT-REPORT FILE. ############################################################################## # FOR TESTING: # set -x # FOR TESTING: # ls -l /var/mail/te* 2> /dev/null \ # FOR TESTING: # ls -l /var/mail/t* \ # FOR REAL: # ls -l /var/mail 2> /dev/null \ ls -l /var/mail 2> /dev/null \ | grep -v '^d' \ | awk '{ if ( $1 ~ "total" ) { continue } if ( NF != 9 ) { printf ("\"ls\" record not containing 9 fields: %s \n", $0) continue } # if ( NF != 9 ) {print # continue } ## 'awk' Statements like this can be used to skip special files/directories : ## # if ( $9 ~ ".partial" ) { # continue } ## FOR TESTING /var/mail/whatever* : ## (get characters after /var/mail/) ## # userchek = substr($9,11,20) userchek = $9 if ( $3 !~ userchek ) printf ("%10s owns '/var/mail' FILE %10s \n", $3, $9) ## FOR TESTING: # printf ("%20s %20s \n", userchek, $3) # }' >> $OUTLIST ############################################################################## ## GENERATE A TRAILER OF THE OUTPUT-REPORT FILE. ############################################################################## echo " ************** `date '+%Y %b %d %T%p'` ************************ The /var/mail FILE list above was generated by running the script $0 on host $THISHOST. It uses a rather simple awk script to perform the owner/filename comparison and format the output. This list can be generated by nnsFEAmenu option 'u o h cv'. ________________________________________________________________________ There are `ls -1 /var/mail | wc -l` /var/mail files, currently. ________________________________________________________________________ Enter/paste the command ls -l /var/mail to see the size, permissions, owners of the /var/mail files. ________________________________________________________________________ The command 'df -k' can be used to determine whether /var/mail is indeed NFS-mounted to this host $THISHOST and from which server it is mounted. Their output follows: " >> $OUTLIST df -k >> $OUTLIST echo " 'stat /var/mail' can be used to verify the NFS-mount: " >> $OUTLIST stat /var/mail >> $OUTLIST echo " ________________________________________________________________________ " >> $OUTLIST ############################################################################## ## SHOW THE OUTPUT-REPORT FILE. ############################################################################## $FEDIR/scripts/shofil $OUTLIST