5562N/A#!/usr/sbin/sh
5562N/A#
5562N/A# CDDL HEADER START
5562N/A#
5562N/A# The contents of this file are subject to the terms of the
7118N/A# Common Development and Distribution License (the "License").
7118N/A# You may not use this file except in compliance with the License.
5562N/A#
5562N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
5562N/A# or http://www.opensolaris.org/os/licensing.
5562N/A# See the License for the specific language governing permissions
5562N/A# and limitations under the License.
5562N/A#
5562N/A# When distributing Covered Code, include this CDDL HEADER in each
5562N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
5562N/A# If applicable, add the following below this CDDL HEADER, with the
7118N/A# fields enclosed by brackets "[]" replaced with your own identifying
7118N/A# information: Portions Copyright [yyyy] [name of copyright owner]
5562N/A#
5562N/A# CDDL HEADER END
7118N/A#
7118N/A# Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
7118N/A
7118N/ADEFAULT_FILE="/etc/default/sendmail"
7118N/ASENDMAIL="/usr/lib/inet/sendmail"
7118N/APATH="/usr/bin:/usr/sbin"
7118N/Aexport PATH
7118N/A
7118N/Acheck_queue_interval_syntax()
7118N/A{
5562N/A default="15m"
5562N/A if [ $# -lt 1 ]; then
5562N/A answer=$default
5562N/A return
5562N/A fi
5562N/A if echo $1 | egrep '^([0-9]*[1-9][0-9]*[smhdw])+$' >/dev/null 2>&1; then
5562N/A answer=$1
5562N/A else
5562N/A answer=$default
5562N/A fi
5562N/A}
5562N/A
5562N/Acheck_and_kill()
5562N/A{
5562N/A PID=`head -1 $1`
5562N/A kill -0 $PID > /dev/null 2>&1
5562N/A [ $? -eq 0 ] && kill $PID
5562N/A}
5562N/A
5562N/Aexist_or_exit()
7118N/A{
7118N/A if [ ! -f $1 ]; then
7118N/A echo "$1 does not exist" >&2
7118N/A exit $SMF_EXIT_ERR_CONFIG
7118N/A fi
7118N/A}
7118N/A
7118N/Aturn_m4_crank()
7118N/A{
7118N/A # expected to be called with two arguments: .cf path & path to m4 file
7118N/A [ $# -lt 2 ] && return
7118N/A cf_path=$1
7118N/A m4_path=$2
7118N/A if [ "$m4_path" = "_DONT_TOUCH_THIS" ]; then
7118N/A if [ -f "${cf_path}.old" ]; then
7118N/A mv "$cf_path" "${cf_path}.new"
7118N/A [ $? -ne 0 ] && exit $SMF_EXIT_ERR_CONFIG
7118N/A mv "${cf_path}.old" "$cf_path"
7118N/A [ $? -ne 0 ] && exit $SMF_EXIT_ERR_CONFIG
7118N/A fi
7118N/A #
7118N/A # If ${cf_path}.old does not exist, assume it was taken care
7118N/A # of on a previous run.
7118N/A #
7118N/A else
7118N/A case "$m4_path" in
7118N/A /*) ;; # absolute path
7118N/A *) return;;
7118N/A esac
7118N/A exist_or_exit "$m4_path"
7118N/A cd `dirname "$m4_path"`
7118N/A base=`basename "$m4_path"`
7118N/A name=`basename "$m4_path" .mc`
7118N/A m4flags="-D_CF_DIR_=/etc/mail/cf/"
7118N/A info=`svcprop -p config/include_info $SMF_FMRI 2>/dev/null`
7118N/A if [ "$info" != "true" ]; then
7118N/A m4flags="$m4flags -DSUN_HIDE_INTERNAL_DETAILS"
7118N/A fi
7118N/A m4 $m4flags /etc/mail/cf/m4/cf.m4 "$base" > "${name}.cf"
7118N/A [ $? -ne 0 ] && exit $SMF_EXIT_ERR_CONFIG
7118N/A cmp -s "${name}.cf" "$cf_path" || (
7118N/A cp "${name}.cf" "${cf_path}.tmp" &&
7118N/A chown root:bin "${cf_path}.tmp" &&
7118N/A chmod 444 "${cf_path}.tmp" &&
7118N/A mv "${cf_path}.tmp" "$cf_path"
7118N/A )
7118N/A [ $? -ne 0 ] && exit $SMF_EXIT_ERR_CONFIG
7118N/A fi
7118N/A}
7118N/A