--- /lib/svc/share/sendmail_include.sh.orig Fri Apr 1 00:58:52 2011 +++ /lib/svc/share/sendmail_include.sh Thu Apr 19 00:04:33 2012 @@ -79,9 +79,14 @@ *) return;; esac exist_or_exit "$m4_path" - cd `dirname "$m4_path"` - base=`basename "$m4_path"` - name=`basename "$m4_path" .mc` + if [[ $cf_path -nt $m4_path || $cf_path -ot $m4_path ]] ; then + # fall through + : + else + return + fi + # just in case the file tries to include files with a relative path + cd `dirname "$m4_path"` || echo "Warning: Can't cd to "`dirname "$m4_path"`" (this may produce unexpected results)" info=`svcprop -p config/include_info $SMF_FMRI 2>/dev/null` if [ "$info" = "true" ]; then m4flags="" @@ -88,14 +93,15 @@ else m4flags="-DSUN_HIDE_INTERNAL_DETAILS" fi - m4 $m4flags /etc/mail/cf/m4/cf.m4 "$base" > "${name}.cf" - [ $? -ne 0 ] && exit $SMF_EXIT_ERR_CONFIG - cmp -s "${name}.cf" "$cf_path" || ( - cp "${name}.cf" "${cf_path}.tmp" && - chown root:bin "${cf_path}.tmp" && - chmod 444 "${cf_path}.tmp" && - mv "${cf_path}.tmp" "$cf_path" + m4 -D_CF_DIR_=/etc/mail/cf/ $m4flags /etc/mail/cf/m4/cf.m4 "$m4_path" \ + > "${cf_path}.new" + [[ $? -ne 0 || ! -s "${cf_path}.new" ]] && exit $SMF_EXIT_ERR_CONFIG + cmp -s "${cf_path}.new" "$cf_path" || ( + chown root:bin "${cf_path}.new" && + chmod 444 "${cf_path}.new" && + mv "${cf_path}.new" "$cf_path" ) [ $? -ne 0 ] && exit $SMF_EXIT_ERR_CONFIG + touch -r "$m4_path" "$cf_path" fi }