#!/bin/sh
# This programs checks the default file creation mask for the File
# Transfer Protocol (FTP) service.  Prior to Solaris 9, this was
# done by setting the 'UMASK' variable in /etc/default/ftpd .  For 
# Solaris 9 and above, this is done using the 'defumask' parameter 
# in the /etc/ftpd/ftpaccess file.  For more information on this 
# functionality, see in.ftpd(1M) and ftpaccess(4) [Solaris 9+].
#
#SYSTEMS: Solaris
#
MSG="# Checking the default file creation mask for the FTP service..."
SYSTEM=`uname -s`
######Solaris######
if [ "$SYSTEM" = "SunOS" ]; then
  echo "";echo "$MSG"
  FTPD_UMASK=022 #This is the value the umask should have.
  case "`uname -r`" in
  5.[9]*) 
    FTPACCESS="/etc/ftpd/ftpaccess"
    if [ ! -f ${FTPACCESS} ]; then
      exit 0
    else
      CHK=`grep "^defumask ${FTPD_UMASK}" ${FTPACCESS}`
      if [ "$CHK" = "" ]; then
	echo "--INFO-- [FTPD002i] The umask is NOT defined as ${FTPD_UMASK} in ${FTPACCESS}."
      fi
    fi;;
  5.[678]*)
    FTPD="/etc/default/ftpd"
    if [ ! -f ${FTPD} ]; then
      exit 0
    fi
    VALUE=`grep '^UMASK=' ${FTPD} | awk -F= '{ print $2 }' 2>/dev/null`
    if [ "${VALUE}" != "${FTPD_UMASK}" ]; then
      echo "--INFO-- [FTPD003i] The ftpd umask is NOT set to ${FTPD_UMASK} in ${FTPD}."
    fi;;
  *)
    #Only supported on Solaris 2.6 and newer.
    exit 0;;
  esac
fi
