#!/bin/sh
# $Id: t-conf-3.sh,v 1.4 2006/10/05 01:40:57 ca Exp $
# Copyright (c) 2006 Sendmail, Inc. and its suppliers.
#	All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#

test -s stop && exit 1

# source directory of this (and other) shell script
SD=`dirname $0`

ERRS=0
CNF=sm3.conf
OUT=sm3.out
OK=sm3.ok
PRG=./t-conf-3

cat > ${CNF} <<EOF
flags = { starttls, auth }
session_features notls { flags = { -starttls}}
EOF

# --------------------------------------------
cat > ${OK} <<EOF
# session feature declarations
session_features notls {
  # flags to influence behavior per session
  flags={
    # offer AUTH
    auth,
  }
  # max ta
  max_ta=0;
}
# global flags to influence behavior
flags={
  # offer STARTTLS
  starttls,
  # offer AUTH
  auth,
}
# global max ta
max_ta=99;
isset_cflags=1
n=1
name[0]=notls
flags[0]=0x01000000
isset_flags[0]=1
isset_name[0]=0
isset_max_ta[0]=0
EOF

if ${PRG} ${CNF} >${OUT} 2>&1
then
  if diff ${OK} ${OUT}
  then
    :
  else
    ERRS=`expr ${ERRS} + 1 `
    test X"${MTA_STOPONERROR}" != X && exit 1
  fi
else
  ERRS=`expr ${ERRS} + 1 `
  test X"${MTA_STOPONERROR}" != X && exit 1
fi

# --------------------------------------------
cat > ${CNF} <<EOF
flags = { starttls, auth }
session_features notls { flags = { -starttls, -auth}}
EOF

cat > ${OK} <<EOF
# session feature declarations
session_features notls {
  # max ta
  max_ta=0;
}
# global flags to influence behavior
flags={
  # offer STARTTLS
  starttls,
  # offer AUTH
  auth,
}
# global max ta
max_ta=99;
isset_cflags=1
n=1
name[0]=notls
flags[0]=0x00000000
isset_flags[0]=1
isset_name[0]=0
isset_max_ta[0]=0
EOF

if ${PRG} ${CNF} >${OUT} 2>&1
then
  if diff ${OK} ${OUT}
  then
    :
  else
    ERRS=`expr ${ERRS} + 1 `
    test X"${MTA_STOPONERROR}" != X && exit 1
  fi
else
  ERRS=`expr ${ERRS} + 1 `
  test X"${MTA_STOPONERROR}" != X && exit 1
fi


# ----------------
if test "${ERRS}" = "0"
then
  exit 0
else
  echo "${ERRS} error(s)"
  exit 1
fi


syntax highlighted by Code2HTML, v. 0.9.1