Date: Fri, 4 Oct 2002 16:03:51 -0500 (CDT) From: "Scot W. Hetzel" <hetzels@westbend.net> To: FreeBSD-gnats-submit@FreeBSD.org Cc: ume@FreeBSD.org Subject: ports/43673: RC_NG script for mail/cyrus_sasl2 Message-ID: <200210042103.g94L3pC0030866@WBIw009.westbend.net>
next in thread | raw e-mail | index | archive | help
>Number: 43673 >Category: ports >Synopsis: RC_NG script for mail/cyrus_sasl2 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Oct 04 14:10:05 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Scot W. Hetzel >Release: FreeBSD 5.0-CURRENT i386 >Organization: West Bend Internet >Environment: System: FreeBSD Current.westbend.net 5.0-CURRENT FreeBSD 5.0-CURRENT #5: Tue Sep 24 11:27:41 CDT 2002 root@Current.westbend.net:/usr/obj/usr/src/srcC/sys/GENERIC-SMP i386 >Description: While looking at the RC_NG scripts on 5.0-CURRENT, I looked at converting the ports rc startup scripts to RC_NG. I decided to start with cyrus-imapd and the ports that it depends on (cyrus-sasl, openldap, openldap2, mysql323-client). To ensure compatibility with previous FreeBSD Releases, the rc scripts contain both the new RC_NG and pre RC_NG scripts. >How-To-Repeat: >Fix: Changed Files: Makefile - Add support for RC_NG scripts pkg-deinstall - Add delete_rc_conf_d to remove rc script configuration files ${prefix}/etc/rc.conf.d/{cyrus_pwcheck,saslauthd) pkg-install - Add create_rc_conf_d to create rc script configuration files ${prefix}/etc/rc.conf.d/{cyrus_pwcheck,saslauthd) pkg-plist - Add cyrus-sasl files/pwcheck.sh - Update to RC_NG script files/saslauthd.sh - Update to RC_NG script scripts/configure.sasl - Change PWCHECK_SUB to RC_SCRIPTS_SUB (similar to PLIST_SUB) New Files: files/cyrus_sasl - Dummy RC_NG Dependency file used to ensure that any dependency script is started before the use of the sasl libraries. Only usefull if placed into /etc/rc.d with the script it depends on. (i.e. mysql-client needs to run before cyrus_sasl) Index: Makefile =================================================================== RCS file: /home/ncvs/ports/security/cyrus-sasl2/Makefile,v retrieving revision 1.54 diff -u -r1.54 Makefile --- Makefile 13 Sep 2002 16:23:23 -0000 1.54 +++ Makefile 4 Oct 2002 01:10:45 -0000 @@ -116,9 +116,11 @@ post-patch: @${SED} -e "s;%%SASLDB%%;${SASLDB_NAME};g" \ -e "s;%%PWCHECK_METHOD%%;${PWCHECK_METHOD};g" \ + -e "s;%%ENABLE_SASLAUTHD%%;${ENABLE_SASLAUTHD};g" \ ${.CURDIR}/pkg-install > ${PKGINSTALL} @${SED} -e "s;%%SASLDB%%;${SASLDB_NAME};g" \ -e "s;%%PWCHECK_METHOD%%;${PWCHECK_METHOD};g" \ + -e "s;%%ENABLE_SASLAUTHD%%;${ENABLE_SASLAUTHD};g" \ ${.CURDIR}/pkg-deinstall > ${PKGDEINSTALL} @${SED} -e "s;%%PWCHECK_METHOD%%;${PWCHECK_METHOD};g" \ -e "s;%%PREFIX%%;${PREFIX};g" \ @@ -135,9 +137,11 @@ ${MAN8PREFIX}/man/man8/sasldblistusers2.8 ${INSTALL_MAN} ${WRKSRC}/saslauthd/saslauthd.mdoc \ ${MAN8PREFIX}/man/man8/saslauthd.8 - @${SED} -e "s;%%PREFIX%%;${PREFIX};g" ${PWCHECK_SUB} \ - ${FILESDIR}/saslauthd.sh > ${PREFIX}/etc/rc.d/saslauthd.sh - @${CHMOD} 755 ${PREFIX}/etc/rc.d/saslauthd.sh +.for rc_script in cyrus_sasl saslauthd.sh + @${SED} ${RC_SCRIPTS_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \ + ${FILESDIR}/${rc_script} > ${PREFIX}/etc/rc.d/${rc_script} + @${CHMOD} 755 ${PREFIX}/etc/rc.d/${rc_script} +.endfor ${MKDIR} -m 770 /var/state/saslauthd ${CHOWN} cyrus:cyrus /var/state/saslauthd .if !defined(NOPORTDOCS) Index: pkg-deinstall =================================================================== RCS file: /home/ncvs/ports/security/cyrus-sasl2/pkg-deinstall,v retrieving revision 1.7 diff -u -r1.7 pkg-deinstall --- pkg-deinstall 29 Aug 2002 17:57:31 -0000 1.7 +++ pkg-deinstall 4 Oct 2002 01:21:04 -0000 @@ -12,6 +12,26 @@ SASLDB_NAME=${PKG_PREFIX}/etc/%%SASLDB%% +remove_file() +{ + file=$1 + + if cmp -s ${file} ${file}.tmp; then + rm -f ${file} + fi + rm -f ${file}.tmp +} + +delete_rc_conf_d() { + SASLAUTHD_CONF=${PKG_PREFIX}/etc/rc.conf.d/saslauthd + + if [ -f ${SASLAUTHD_CONF} ]; then + echo "saslauthd_enable=%%ENABLE_SASLAUTHD%%" >> ${SASLAUTHD_CONF}.tmp + echo "saslauthd_flags=\"-a pam\"" >> ${SASLAUTHD_CONF}.tmp + remove_file ${SASLAUTHD_CONF} + fi +} + # delete sasldb database delete_sasldb() { @@ -39,16 +59,14 @@ sendmail_conf() { if [ -f ${PKG_PREFIX}/lib/sasl2/Sendmail.conf ]; then echo "pwcheck_method: %%PWCHECK_METHOD%%" > ${PKG_PREFIX}/lib/sasl2/Sendmail.conf.tmp - if cmp -s ${PKG_PREFIX}/lib/sasl2/Sendmail.conf ${PKG_PREFIX}/lib/sasl2/Sendmail.conf.tmp; then - rm -f ${PKG_PREFIX}/lib/sasl2/Sendmail.conf - fi - rm -f ${PKG_PREFIX}/lib/sasl2/Sendmail.conf.tmp + remove_file ${PKG_PREFIX}/lib/sasl2/Sendmail.conf fi } case $2 in DEINSTALL) delete_sasldb + delete_rc_conf_d sendmail_conf ;; POST-DEINSTALL) Index: pkg-install =================================================================== RCS file: /home/ncvs/ports/security/cyrus-sasl2/pkg-install,v retrieving revision 1.11 diff -u -r1.11 pkg-install --- pkg-install 29 Aug 2002 17:57:31 -0000 1.11 +++ pkg-install 4 Oct 2002 01:16:47 -0000 @@ -96,6 +96,18 @@ fi } +create_rc_conf_d() { + SASLAUTHD_CONF=${PKG_PREFIX}/etc/rc.conf.d/saslauthd + + if [ ! -d ${PKG_PREFIX}/etc/rc.conf.d ]; then + mkdir ${PKG_PREFIX}/etc/rc.conf.d + fi + if [ ! -f ${SASLAUTHD_CONF} ]; then + echo "saslauthd_enable=%%ENABLE_SASLAUTHD%%" > ${SASLAUTHD_CONF} + echo "saslauthd_flags=\"-a pam\"" >> ${SASLAUTHD_CONF} + fi +} + case $2 in PRE-INSTALL) create_user @@ -103,6 +115,7 @@ POST-INSTALL) if [ "${PKG_BATCH}" = "NO" ]; then create_sasldb + create_rc_conf_d sendmail_conf fi ;; Index: pkg-plist =================================================================== RCS file: /home/ncvs/ports/security/cyrus-sasl2/pkg-plist,v retrieving revision 1.19 diff -u -r1.19 pkg-plist --- pkg-plist 13 Sep 2002 16:23:23 -0000 1.19 +++ pkg-plist 4 Oct 2002 01:30:22 -0000 @@ -1,3 +1,7 @@ +@comment The following makes sure that the pwcheck and saslauthd +@comment daemons are stopped before removing the files. +@unexec if [ -f /var/state/saslauthd/mux.pid ] ; then %D/etc/rc.d/saslauthd.sh stop ; echo " stopped." ; fi +etc/rc.d/cyrus_sasl etc/rc.d/saslauthd.sh include/sasl/hmac-md5.h include/sasl/md5.h Index: files/cyrus_sasl =================================================================== RCS file: files/cyrus_sasl diff -N files/cyrus_sasl --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/cyrus_sasl 4 Oct 2002 01:11:43 -0000 @@ -0,0 +1,16 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: sasl +# REQUIRE: DAEMON %%MYSQL_REQ%% +# KEYWORD: FreeBSD +# +# NOTE for FreeBSD 5.0+: +# If you want this script to start with the base rc scripts copy +# cyrus_sasl1 to /etc/rc.d/cyrus_sasl1 + +# This is a dummy dependancy, to ensure that daemons are run _before_ +# `sasl' is available. + Index: files/saslauthd.sh =================================================================== RCS file: /home/ncvs/ports/security/cyrus-sasl2/files/saslauthd.sh,v retrieving revision 1.1 diff -u -r1.1 saslauthd.sh --- files/saslauthd.sh 8 Aug 2002 14:04:44 -0000 1.1 +++ files/saslauthd.sh 4 Oct 2002 17:04:58 -0000 @@ -3,73 +3,124 @@ # $FreeBSD: ports/security/cyrus-sasl2/files/saslauthd.sh,v 1.1 2002/08/08 14:04:44 ume Exp $ # -action=$1 - -PREFIX=%%PREFIX%% - -# Suck in the configuration variables. -if [ -z "${source_rc_confs_defined}" ]; then - if [ -r /etc/defaults/rc.conf ]; then - . /etc/defaults/rc.conf - source_rc_confs - elif [ -r /etc/rc.conf ]; then - . /etc/rc.conf - fi -fi - -# The following sasl_saslauthd_* variables may be defined in rc.conf +# PROVIDE: saslauthd +# REQUIRE: DAEMON +# BEFORE: mail imap +# KEYWORD: FreeBSD shutdown # -# sasl_saslauthd_enable - Set to YES to enable saslauthd -# Default: %%ENABLEPWCHECK%% +# NOTE for FreeBSD 5.0+: +# If you want this script to start with the base rc scripts +# move saslauthd.sh to /etc/rc.d/saslauthd + +# Define the following saslauthd_* variables in one of the following: +# /etc/rc.conf +# /etc/rc.conf.d/saslauthd +# ${prefix}/etc/rc.conf.d/saslauthd # -# sasl_saslauthd_program - Path to saslauthd program -# Default: ${PREFIX}/sbin/%%PWCHECK%% +# saslauthd_enable - Set to YES to enable saslauthd +# Default: %%ENABLE_SASLAUTHD%% # -# sasl_saslauthd_flags - Flags to saslauthd program -# Default: -a pam +# saslauthd_program - Path to saslauthd program +# Default: ${prefix}/sbin/saslauthd +# +# saslauthd_flags - Flags to saslauthd program +# Default: -a pam -if [ -z "${sasl_saslauthd_enable}" ]; then - sasl_saslauthd_enable=%%ENABLEPWCHECK%% -fi +prefix=%%PREFIX%% -if [ -z "${sasl_saslauthd_program}" ]; then - sasl_saslauthd_program=${PREFIX}/sbin/%%PWCHECK%% -fi +if [ -f /etc/rc.subr ]; then + . /etc/rc.subr -if [ -z "${sasl_saslauthd_flags}" ]; then - sasl_saslauthd_flags="-a pam" -fi + name="saslauthd" + rcvar=`set_rcvar` + command="${prefix}/sbin/${name}" + pidfile="/var/state/${name}/mux.pid" + + # The below may be removed when load_local_rc_config is added to rc.subr + + if [ -f ${prefix}/etc/rc.conf.d/"$name" ]; then + debug "Sourcing ${prefix}/etc/rc.conf.d/${name}" + . ${prefix}/etc/rc.conf.d/"$name" + fi + + load_rc_config $name + + if [ -z "${saslauthd_enable}" ]; then + saslauthd_enable=%%ENABLE_SASLAUTHD%% + fi + + # The above may be removed when load_local_rc_config is added to rc.subr + # + # load_local_rc_config $name + run_rc_command "$1" +else + # Suck in the configuration variables. + if [ -z "${source_rc_confs_defined}" ]; then + if [ -r /etc/defaults/rc.conf ]; then + . /etc/defaults/rc.conf + source_rc_confs + elif [ -r /etc/rc.conf ]; then + . /etc/rc.conf + fi + fi -rc=0 + if [ -f ${prefix}/etc/rc.conf.d/saslauthd ]; then + . ${prefix}/etc/rc.conf.d/saslauthd + fi + + if [ -n "${sasl_saslauthd_enable}" ]; then + echo "sasl_saslauthd_enable has been depreciated, use saslauthd_enable instead" + saslauthd_enable=$sasl_saslauthd_enable + fi + + if [ -z "${saslauthd_enable}" ]; then + saslauthd_enable=%%ENABLE_SASLAUTHD%% + fi + + if [ -z "${saslauthd_program}" ]; then + saslauthd_program=${prefix}/sbin/saslauthd + fi + + if [ -n "${sasl_saslauthd_flags}" ]; then + echo "sasl_saslauthd_flags has been depreciated, use saslauthd_flags instead" + saslauthd_flags=$sasl_saslauthd_flags + fi + + if [ -z "${saslauthd_flags}" ]; then + saslauthd_flags="-a pam" + fi -case "${sasl_saslauthd_enable}" in - [Yy][Ee][Ss]) - case "${action}" in - - start) - if [ -x ${sasl_saslauthd_program} ] ; then - ${sasl_saslauthd_program} ${sasl_saslauthd_flags} \ - && echo -n " saslauthd" - fi - ;; + rc=0 - stop) - if [ -r /var/state/saslauthd/mux.pid ]; then - kill `cat /var/state/saslauthd/mux.pid` && \ - echo -n " saslauthd" - rm /var/state/saslauthd/mux.pid - fi + case "${saslauthd_enable}" in + [Yy][Ee][Ss]) + case "${1}" in + + start) + if [ -x ${saslauthd_program} ] ; then + ${saslauthd_program} ${saslauthd_flags} \ + && echo -n " saslauthd" + fi + ;; + + stop) + if [ -r /var/state/saslauthd/mux.pid ]; then + kill `cat /var/state/saslauthd/mux.pid` && \ + echo -n " saslauthd" + rm /var/state/saslauthd/mux.pid + fi + ;; + + *) + echo "usage: $0 {start|stop}" 1>&2 + rc=64 + ;; + esac ;; - *) - echo "usage: $0 {start|stop}" 1>&2 - rc=64 + rc=0 ;; esac - ;; - *) - rc=0 - ;; -esac -exit $rc + exit $rc +fi Index: scripts/configure.sasl =================================================================== RCS file: /home/ncvs/ports/security/cyrus-sasl2/scripts/configure.sasl,v retrieving revision 1.15 diff -u -r1.15 configure.sasl --- scripts/configure.sasl 29 Aug 2002 17:57:31 -0000 1.15 +++ scripts/configure.sasl 4 Oct 2002 01:42:16 -0000 @@ -83,8 +83,7 @@ DBLIB=1 ;; \"SASLAUTHD\") - echo "PWCHECK_SUB+= -e \"s;%%PWCHECK%%;saslauthd;g\"" - PWCHECK=1 + SASLAUTHD=1 ;; *) echo "Invalid option(s): $*" > /dev/stderr @@ -95,14 +94,21 @@ shift done -if [ "$PWCHECK" ]; then - echo "PWCHECK_SUB+= -e \"s;%%ENABLEPWCHECK%%;yes;g\"" - echo "PWCHECK_METHOD= saslauthd" +if [ "${SASLAUTHD}" ]; then + PWCHECK_METHOD=saslauthd + ENABLE_SASLAUTHD=yes else - echo "PWCHECK_SUB+= -e \"s;%%PWCHECK%%;saslauthd;g\" \\" - echo " -e \"s;%%ENABLEPWCHECK%%;no;g\"" - echo "PWCHECK_METHOD= auxprop" + PWCHECK_METHOD=auxprop + ENABLE_SASLAUTHD=no fi + +echo "PWCHECK_METHOD= ${PWCHECK_METHOD}" +echo "ENABLE_SASLAUTHD= ${ENABLE_SASLAUTHD}" + +echo "RC_SCRIPTS_SUB+= PREFIX=\${PREFIX} \\" +echo " ENABLE_SASLAUTHD=\${ENABLE_SASLAUTHD} \\" +echo " MYSQL_REQ=${MYSQL_REQ}" + if [ ! "${DBLIB}" ]; then echo "CONFIGURE_ARGS+= --with-dblib=ndbm" echo "SASLDB_NAME= sasldb2.db" >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200210042103.g94L3pC0030866>