Article Listing 1 Listing 2 Listing 3 Listing 4
Listing 5 Listing 6 Listing 7 Listing 8 Listing 9
Listing 10 Listing 11 Listing 12 dec2004.tar

Listing 6 attributes.sh

#!/bin/ksh

#*****************************************************************
# Listing 6:
# File: attributes.sh
#
# Description:
#
# This script creates a file's message digest signature in the snapshot 
# file.  Entrap's design handles up to four file signatures.
# Only md5 is used with the other three signatures commented out.
# edit this file in order to turn them on or create a different signature.
#
# Author: John Spurgeon (john.p.spurgeon@intel.com)
#
#*****************************************************************

#
# NOTES:
#
# If you change a file signature to use a different message digest command, 
# then you may need to update the cn_strings variable in list_changed.sh in  
# order for the column names to display correctly when the compare command 
# executes. If you add another file signature, add another attribute to 
# filter.sh.

# When enabling a signature, comment out the corresponding echo command.
# When disabling a signature, uncomment the corresponding echo command.

if [ -n "$(find $1 \( -type f -o -type d \) -print)" ]
then
    ls -ild $1 | awk 'BEGIN {ORS=""} {print $10" "$1" "$2" "$3" "$4" "$5" \
      "$6" "$7"-"$8"-"$9}'

#    Signature 1: /usr/local/bin/md5
    /usr/local/bin/md5 $1 | awk 'BEGIN {ORS=""} {print " "$NF}'
#    echo " -\c"

#    Signature 2: /usr/bin/sum
#    /usr/bin/sum $1 | awk 'BEGIN {ORS=""} {print " "$1}'
    echo " -\c"

#    Signature 3: /usr/ucb/sum
#    /usr/ucb/sum $1 | awk 'BEGIN {ORS=""} {print " "$1}'
    echo " -\c"

#    Signature 4: /usr/bin/cksum
#    /usr/bin/cksum $1 | awk 'BEGIN {ORS=""} {print " "$1}'
    echo " -\c"

    echo
    exit 0
fi

#
# Symbolic Links
#

if [ -n "$(find $1 -type l -print)" ]
then
    ls -ild $1 | awk 'BEGIN {ORS=""} {print $10$11$12" "$1" "$2" "$3" "$4" \
      "$5" "$6" "$7"-"$8"-"$9}'
    echo " - - - -"
    exit 0
fi

#
# Block and Character Special Files
#

if [ -n "$(find $1 \( -type b -o -type c \) -print)" ]
then
    ls -ild $1 | \
    awk 'BEGIN {ORS=""} {
    if ($6 ~ /,$/)
        print $11" "$1" "$2" "$3" "$4" "$5" "$6$7" "$8"-"$9"-"$10
    else
        print $10" "$1" "$2" "$3" "$4" "$5" "$6" "$7"-"$8"-"$9
    }'
    echo " - - - -"
    exit 0
fi

#
# Pipes, Sockets, and Doors
#

if [ -n "$(find $1 -type p -print)" ] || \
   [ -n "$(find $1 -type s -print)" ] || \
   [ -n "$(find $1 -type D -print)" ]
then
    ls -ild $1 | awk 'BEGIN {ORS=""} {print $10" "$1" "$2" "$3" "$4" "$5" \
      "$6" "$7"-"$8"-"$9}'
    echo " - - - -"
    exit 0
fi


#!/bin/ksh