From owner-freebsd-ports-bugs@FreeBSD.ORG Mon May 26 19:40:15 2003 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 31F4D37B401 for ; Mon, 26 May 2003 19:40:15 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 973C943F93 for ; Mon, 26 May 2003 19:40:13 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h4R2eCUp057496 for ; Mon, 26 May 2003 19:40:12 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h4R2eCDk057495; Mon, 26 May 2003 19:40:12 -0700 (PDT) Resent-Date: Mon, 26 May 2003 19:40:12 -0700 (PDT) Resent-Message-Id: <200305270240.h4R2eCDk057495@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Cyrille Lefevre Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DE06D37B401 for ; Mon, 26 May 2003 19:32:18 -0700 (PDT) Received: from smtp.noos.fr (nan-smtp-06.noos.net [212.198.2.75]) by mx1.FreeBSD.org (Postfix) with ESMTP id 698AE43FAF for ; Mon, 26 May 2003 19:32:16 -0700 (PDT) (envelope-from cyrille.lefevre@laposte.net) Received: (qmail 98803552 invoked by uid 0); 27 May 2003 02:32:11 -0000 Received: from unknown (HELO mail.gits.dyndns.org) ([212.198.231.153]) (envelope-sender ) by 212.198.2.75 (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 27 May 2003 02:32:11 -0000 Received: from gits.gits.fr.invalid (8q5qpb2m2ix2xdg3@localhost [127.0.0.1]) h4R2VVAC008752 for ; Tue, 27 May 2003 04:31:33 +0200 (CEST) (envelope-from cyrille.lefevre@laposte.net) Received: by gits.gits.fr.invalid (tmda-inject, from uid 0); Tue, 27 May 2003 04:31:31 +0200 Message-Id: <20030527023126.GA70105@gits.dyndns.org> Date: Tue, 27 May 2003 04:31:26 +0200 From: Cyrille Lefevre To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 cc: Mikhail Teterin cc: Tilman Linneweh cc: Frank Shute cc: Cameron Stiles cc: Joe Talbott Subject: ports/52709: Maintainer update: astro/setiathome (3.08 - security fix) X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Cyrille Lefevre List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 May 2003 02:40:16 -0000 >Number: 52709 >Category: ports >Synopsis: Maintainer update: astro/setiathome (3.08 - security fix) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: maintainer-update >Submitter-Id: current-users >Arrival-Date: Mon May 26 19:40:11 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Cyrille Lefevre >Release: FreeBSD 5.0-RELEASE-p4 i386 >Organization: ACME >Environment: System: FreeBSD gits 5.0-RELEASE-p7 FreeBSD 5.0-RELEASE-p7 #13: Thu May 1 04:14:27 CEST 2003 root@gits:/disk3/freebsd/current/obj/disk3/freebsd/current/src/sys/CUSTOM i386 >Description: 3.03 is known as broken because of an exploitable buffer overflow. this PR supersed PR#51759 and PR#52297. PR#50723 may also be closed. The purpose of this PR is a version bump to 3.08 w/ the following enhancements : - only one master shell to monitor multiple setiathome instances - wait some time for setiathome server to come up between restarts - xsetiathome comes back - -graphics is now the default (so xsetiathome may be launched) - registration heuristic changed (see comments below) - take care, some variable names have changed (see comments below) - manual page reviewed The setiathome manual page refer to setiathome.conf while it is now named rc.setiathome.conf. also, the manual page has been completed (variables, start/stop scripts, etc.) - gracefull startup script option added Makefile PORTVERSION bumped PORTREVISION deleted FORBIDDEN deleted BROKEN bumped to 4.0 NO_XBIN deleted except for linux_base-6 wrapper added pkg-install registration heuristic changed (don't register if already registered, then automatically start setiathome in either case) pkg-list $FreeBSD$ added libexec/setiathome.bin added pkg-message FreeBSD 5.x a.out comment changed to FreeBSD 4.x comment files/rc.setiathome.conf seti_std_args defaulted to "-email -graphics" seti_proxy_args changed to seti_proxy_server seti_socks_server, seti_socks_user, seti_socks_passwd added seti_sleep changed to seti_sleep_time files/setiathome.1 /usr/local changed to %%PREFIX%% above and below changes described files/setiathome.sh same changes as files/rc.setiathome.conf don't start setiathome if already started su heuristic changed to call an external wrapper gracefull (aka apachectl :) option added using stop_after_send.txt >How-To-Repeat: man setiathome >Fix: Take care, this patch is in two parts, the first one is a diff against /dev/null and the second one a cvs diff. --- /dev/null Tue May 27 03:53:01 2003 +++ files/setiathome.bin Tue May 27 02:34:48 2003 @@ -0,0 +1,142 @@ +#!/bin/sh -T + +# $FreeBSD$ + +# Copyright (c) 2003 Cyrille Lefevre. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. The name of the authors and contributors may not be used to +# endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS +# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +setistart () { # dir + local dir + dir=$1 + + # goto the startup dir + cd ${dir} || return + + # don't start a dying client + [ -f stop_after_send.txt ] && return + + # fire up a setiathome client + ${program_path} ${program_args} > /dev/null & + + # memorize the startup dir + eval pid_$!=${dir} + # and the client process ID + setipids="${setipids} $!" +} + +setikill () { # SIGTERM handler + local pids pid + + # save pids to kill + pids="${sleeppid} ${setipids}" + # avoid futher setiathome startup + unset setipids + + # kill'em all if any + for pid in ${pids}; do + ps p ${pid} > /dev/null && kill ${pid} + done +} + +setirestart () { # SIGCHLD handler + local pids pid dir + + # killing in progress + [ -n "${setipids}" ] || return + # restart in process + [ -n "${sleeppids}" ] && return + + # wait for setiathome servers to come up + sleep ${seti_sleep_time} & + + # wait even if more than one setiathome client dies + sleeppid=$! + while ps p ${sleeppid} > /dev/null; do + wait ${sleeppid} + done + unset sleeppid + + # killing while sleeping + [ -n "${setipids}" ] || return + + # save pids to restart + pids=${setipids} + # reset the process ID list + unset setipids + + for pid in ${pids}; do + if ps p ${pid} > /dev/null; then + # still alive + setipids="${setipids} ${pid}" + else + # backup the startup dir + eval dir=\${pid_${pid}} + # clean the old one + unset pid_${pid} + # launch the dead client + eval setistart ${dir} + fi + done +} + +if [ -z "${program_path}" ]; then + case $0 in + /*) rc_dir=${0%/*} ;; + *) rc_dir=${PWD:-$(pwd)} ;; + esac + rc_file=${0##*/} + rc_path=${rc_dir}/${rc_file} + + if ! PREFIX=$(expr ${rc_path} : "\(/.*\)/libexec/${rc_file}\$"); then + echo "${rc_file}: Cannot determine PREFIX." >&2 + echo "Please use the complete pathname." >&2 + exit 64 + fi + + echo "Don't use this script directly, uses the following one instead :" >&2 + echo " ${PREFIX}/etc/rc.d/${rc_file%.bin}.sh start" >&2 + exit 1 +fi + +# save this shell process ID +echo $$ > ${seti_wrkdir}/shpid.sah + +# setup handlers +trap setikill TERM +trap setirestart CHLD + +# startup setiathome client(s) +for dir in ${seti_wrksuff}; do + setistart ${seti_wrkdir}/${dir} +done + +# wait for them until death +while [ -n "${setipids}" ]; do + wait +done Index: Makefile =================================================================== RCS file: /home/ncvs/ports/astro/setiathome/Makefile,v retrieving revision 1.38 diff -u -r1.38 Makefile --- Makefile 12 Apr 2003 17:07:42 -0000 1.38 +++ Makefile 27 May 2003 01:14:40 -0000 @@ -2,11 +2,10 @@ # Date created: 22 Apr 1999 # Whom: stb@freebsd.org # -# $FreeBSD$ +# $FreeBSD: ports/astro/setiathome/Makefile,v 1.36 2003/04/08 11:52:53 nectar Exp $ PORTNAME= setiathome -PORTVERSION?= 3.03 -PORTREVISION?= 7 +PORTVERSION?= 3.08 CATEGORIES?= astro MASTER_SITES= ftp://ftp.cdrom.com/pub/setiathome/ \ ftp://alien.ssl.berkeley.edu/pub/ @@ -16,10 +15,6 @@ MAINTAINER?= cyrille.lefevre@laposte.net COMMENT?= Donate idle cycles to the search for space aliens -.if ${PORTVERSION} == "3.03" -FORBIDDEN= 'Exploitable buffer overflow. http://spoor12.edup.tudelft.nl/' -.endif - .include # Global variables @@ -34,8 +29,8 @@ NO_BUILD= binary distribution NO_CDROM= interactive install -.if ${OSVERSION} <= 226000 -BROKEN= "currently supports only FreeBSD 2.2.6 and above" +.if ${OSVERSION} < 400000 +BROKEN= "currently supports only FreeBSD 4.0 and above" .endif EXTRACT_CMD= ${CAT} @@ -63,7 +58,7 @@ .else PORT_VENDOR?= unknown PORT_OSNAME?= freebsd -PORT_OSREL?= 2.2.8 +PORT_OSREL?= 4.0 .endif PORT_OS= ${PORT_OSNAME}${PORT_OSREL} PORT_HOST= ${PORT_CPU}-${PORT_VENDOR}-${PORT_OS} @@ -82,15 +77,13 @@ .if !exists(${LINUXBASE}/usr/X11R6/lib/libXaw.so.7) NO_XBIN= libXaw.so.7 is missing from linux_base-6 .endif -NO_XBIN?= xsetiathome is broken .endif -.elif ${OSVERSION} >= 300000 -NO_XBIN= xsetiathome is broken .endif # Local variables # +LBIN_DIR= ${PREFIX}/libexec SBIN_DIR= ${PREFIX}/sbin CONF_DIR= ${PREFIX}/etc RC_DIR= ${PREFIX}/etc/rc.d @@ -100,18 +93,8 @@ BIN_FILE= setiathome RC_FILES= setiathome -# i386 NOTES: -# xsetiathome is currently broken at 4.2. should work at 2.x, -# don't know between 3.0 and 4.2 ? so, be conservative... -# diagnostic messages are : -# Warning: Cannot convert string "doneB" to type Widget -# Floating point exception (core dumped) # Linux NOTES: # xsetiathome requires libXawk.so.7 which is missing from linux_base-6. -# using linux_base-7, diagnostic messages are : -# Warning: Cannot convert string "doneB" to type Widget -# Shared memory segment doesn't exist. errno=2 -# Couldn't attach to the science process! .if !defined(NO_XBIN) MAN1+= x${PORTNAME}.1 @@ -125,7 +108,7 @@ # Post-patch # -post-patch: patch-pkgmessage +post-patch: patch-pkgmessage patch-man patch-pkgmessage: @${SED} 's|%%PREFIX%%|${PREFIX}|g; \ @@ -133,6 +116,16 @@ s|%%SUFX%%|${PKGNAMESUFFIX}|g' \ ${MSG_FILE} > ${PKGMESSAGE} +patch-man: +.for mansect in 1 +.for man in ${MAN${mansect}} + @${SED} 's|%%PREFIX%%|${PREFIX}|g; \ + s|%%PREFX%%|${PKGNAMEPREFIX}|g; \ + s|%%SUFX%%|${PKGNAMESUFFIX}|g' \ + ${FILESDIR}/${man} > ${WRKDIR}/${man} +.endfor +.endfor + # Install # @@ -151,7 +144,7 @@ install-man: .for mansect in 1 .for man in ${MAN${mansect}} - @${INSTALL_MAN} ${FILESDIR}/${man} \ + @${INSTALL_MAN} ${WRKDIR}/${man} \ ${MAN${mansect}PREFIX}/man/man${mansect} .endfor .endfor @@ -177,6 +170,10 @@ .if exists(${FILESDIR}/${file}.sh) @${INSTALL_SCRIPT} ${FILESDIR}/${file}.sh \ ${RC_DIR}/${PKGNAMEPREFIX}${file}${PKGNAMESUFFIX}.sh +.endif +.if exists(${FILESDIR}/${file}.bin) + @${INSTALL_SCRIPT} ${FILESDIR}/${file}.bin \ + ${LBIN_DIR}/${PKGNAMEPREFIX}${file}${PKGNAMESUFFIX}.bin .endif .endfor Index: distinfo =================================================================== RCS file: /home/ncvs/ports/astro/setiathome/distinfo,v retrieving revision 1.6 diff -u -r1.6 distinfo --- distinfo 27 Jan 2001 04:40:32 -0000 1.6 +++ distinfo 27 May 2003 00:40:09 -0000 @@ -1 +1 @@ -MD5 (setiathome-3.03.i386-unknown-freebsd2.2.8.tar) = 2dd4c9016059b7532ae721c7b92be821 +MD5 (setiathome-3.08.i386-unknown-freebsd4.0.tar) = f6ba42a3bd93313cf61df62cde3c262e Index: pkg-install =================================================================== RCS file: /home/ncvs/ports/astro/setiathome/pkg-install,v retrieving revision 1.10 diff -u -r1.10 pkg-install --- pkg-install 9 Apr 2003 05:02:42 -0000 1.10 +++ pkg-install 29 Apr 2003 02:39:56 -0000 @@ -33,37 +33,54 @@ case "${PKG_ACTION}" in POST-INSTALL) - + if [ -f ${seti_wrkdir}/user_info.sah ]; then +echo "**** SETI@home already has a working directory for temporary files and" +echo " you seem to be already registered with SETI@home." +echo +echo -n " Would you like repeat the registration with SETI@home? [y/N] " + read ans +echo + if [ "X${ans}" = "XY" -o "X${ans}" = "Xy" ]; then + register=yes + else + register=no + fi + else echo "**** SETI@home requires a working directory for temporary files and a" echo " brief registration process." echo echo " Would you like to set up a working directory in ${seti_wrkdir}," - if [ ${seti_maxprocs} -gt 1 ]; then + if [ ${seti_maxprocs} -gt 1 ]; then echo " register with SETI@home, and let me arrange for ${ncpu} setiathome" - if [ ${ncpu} -eq ${seti_maxprocs} ]; then + if [ ${ncpu} -eq ${seti_maxprocs} ]; then echo " processes (one for each of your ${ncpu} CPUs) to be started" echo -n " automatically as user \`${seti_user}'? [Y/n] " - else + else echo " processes (as configured) to be started automatically as user" echo -n " \`${seti_user}'? [Y/n] " - fi - else + fi + else echo " register with SETI@home, and let me arrange for setiathome to be" echo -n " started automatically as user \`${seti_user}'? [Y/n] " - fi - read a + fi + read ans echo - if [ "X$a" = "XN" -o "X$a" = "Xn" ]; then + if [ "X${ans}" = "XN" -o "X${ans}" = "Xn" ]; then echo "**** Please set up the working directory yourself. You may use" echo " ${rc_path} register" echo " to do so. See setiathome(1) for details." - exit 0 + exit 0 + else + register=yes + fi fi - ${rc_path} register - if [ ! -f ${seti_wrkdir}/user_info.sah ]; then + if [ "${register}" = "yes" ]; then + ${rc_path} register + if [ ! -f ${seti_wrkdir}/user_info.sah ]; then echo "unable to start setiathome: it seems registration or login failed." echo "See setiathome(1) for details." - exit 0 + exit 0 + fi fi ${rc_path} start > /dev/null echo Index: pkg-message =================================================================== RCS file: /home/ncvs/ports/astro/setiathome/pkg-message,v retrieving revision 1.5 diff -u -r1.5 pkg-message --- pkg-message 20 Dec 2002 13:20:38 -0000 1.5 +++ pkg-message 27 May 2003 00:58:29 -0000 @@ -1,8 +1,7 @@ **** %%PREFIX%%/etc/rc.%%PREFX%%setiathome%%SUFX%%.conf may be edited to tune some startup variables such as `seti_nice' defaulted to 15 and `seti_maxprocs' defaulted to your number of processors. -**** NOTE: unlike previous versions, FreeBSD 5.x for i386 doesn't - support a.out binaries by default. To run setiathome, you have - to add the following line to your kernel configuration file - (/sys/i386/conf/) : - options COMPAT_AOUT # Enable i386 a.out binary support +**** NOTE: FreeBSD 5.x does support FreeBSD 4.0 binaries by default. + To run setiathome, you must have the following line to your + kernel configuration file (/sys/i386/conf/) : + options COMPAT_FREEBSD4 # Compatible with FreeBSD 4.x Index: pkg-plist =================================================================== RCS file: /home/ncvs/ports/astro/setiathome/pkg-plist,v retrieving revision 1.6 diff -u -r1.6 pkg-plist --- pkg-plist 28 Jul 2002 22:13:45 -0000 1.6 +++ pkg-plist 27 May 2003 01:15:11 -0000 @@ -1,3 +1,5 @@ +@comment $FreeBSD$ +libexec/%%PREFX%%setiathome%%SUFX%%.bin sbin/%%PREFX%%setiathome%%SUFX%% @unexec if cmp -s %D/etc/rc.%%PREFX%%setiathome%%SUFX%%.conf %D/etc/rc.%%PREFX%%setiathome%%SUFX%%.conf.sample; then rm -f %D/etc/rc.%%PREFX%%setiathome%%SUFX%%.conf; fi etc/rc.%%PREFX%%setiathome%%SUFX%%.conf.sample Index: files/rc.setiathome.conf =================================================================== RCS file: /home/ncvs/ports/astro/setiathome/files/rc.setiathome.conf,v retrieving revision 1.5 diff -u -r1.5 rc.setiathome.conf --- files/rc.setiathome.conf 9 Apr 2003 05:02:42 -0000 1.5 +++ files/rc.setiathome.conf 27 May 2003 01:19:48 -0000 @@ -4,11 +4,14 @@ # # seti_wrkdir=/var/db/${rc_file%.sh} # primary working directory -# seti_std_args=-email # command arguments for standard mode -# seti_reg_args=-login # command arguments for register mode -# seti_proxy_args= # proxy arguments -# seti_user=setiathome # user id to run as -# seti_group=${seti_user} # group id to run as +# seti_std_args="-email -graphics" # startup command line arguments +# seti_reg_args=-login # command line arguments to register +# seti_proxy_server= # HTTP proxy server (hostname:port) +# seti_socks_server= # SOCKS proxy server (hostname:port) +# seti_socks_user= # SOCKS proxy user name +# seti_socks_passwd= # SOCKS proxy password +# seti_user=setiathome # user name to run as +# seti_group=${seti_user} # group name to run as # seti_nice=15 # nice level to run at # seti_maxprocs=$(sysctl -n hw.ncpu) # max. number of processes to start -# seti_sleep=21600 # time to sleep between restarts +# seti_sleep_time=21600 # time to sleep between restarts Index: files/setiathome.1 =================================================================== RCS file: /home/ncvs/ports/astro/setiathome/files/setiathome.1,v retrieving revision 1.10 diff -u -r1.10 setiathome.1 --- files/setiathome.1 27 Jan 2001 04:40:33 -0000 1.10 +++ files/setiathome.1 29 Apr 2003 01:03:11 -0000 @@ -1,4 +1,4 @@ -.\" $FreeBSD: ports/astro/setiathome/files/setiathome.1,v 1.9 2000/04/17 01:08:33 kris Exp $ +.\" $FreeBSD: ports/astro/setiathome/files/setiathome.1,v 1.10 2001/01/27 04:40:33 kris Exp $ .Dd Dec 12, 2000 .Dt setiathome 1 LOCAL .Os FreeBSD @@ -118,22 +118,51 @@ .Fx port includes a start-up script that starts .Nm -at system start-up. +at system start-up and stop it at system shut-down. +.Ss Stopping setiathome +There is two way to stop +.Nm , +gracefully (See +.Pa stop_after_send.txt +mentioned in +.Sx FILES +below) and urgently (using kill as done at system shut-down time). +To do so, respectively run +.Pp +.Dl %%PREFIX%%/etc/rc.d/%%PREFX%%setiathome%%SUFX%%.sh gracefull +or +.Dl %%PREFIX%%/etc/rc.d/%%PREFX%%setiathome%%SUFX%%.sh stop .Ss Configuration File The optional configuration file -.Pa /usr/local/etc/setiathome.conf -can contain one or more of the following variable assignments to override +.Pa %%PREFIX%%/etc/rc.%%PREFX%%setiathome%%SUFX%%.conf +may contain one or more of the following variable assignments to override their default values: .Bl -tag -width seti_wrkdir .It Pa seti_wrkdir=/var/db/setiathome The working directory where .Nm will store it's temporary files. -.It Pa seti_user=nobody +.It Pa seti_std_args=-email and/or -graphics +The command line arguments for normal start-up. +.It Pa seti_reg_args=-login +The command line arguments for registration. +.It Pa seti_proxy_server=hostname:port +The HTTP proxy server and port to connect through. +.It Pa seti_socks_server=hostname:port +The SOCKS server and port to connect through. +.It Pa seti_socks_user=username +The SOCKS user name to connect with. +.It Pa seti_socks_passwd=password +The SOCKS password to connect with. +.It Pa seti_user=setiathome The user to run .Nm as. -.It Pa seti_nice=1 +.It Pa seti_group=setiathome +The group to run +.Nm +as (only used at registration time). +.It Pa seti_nice=15 The .Xr nice 1 value to run @@ -146,6 +175,10 @@ Running more than one instance per CPU is not useful, as .Nm is almost completely CPU-bound. +.It Pa seti_sleep_time=21600 +The time to sleep (in seconds) between restarts if the +.Nm +data server is unresponsive. .El .Pp If you change values in the configuration file, you need to stop and start @@ -153,9 +186,9 @@ and possibly reconfigure the working directory for the changes to take effect. Run .Pp -.Dl /usr/local/etc/rc.d/setiathome.sh stop -.Dl /usr/local/etc/rc.d/setiathome.sh register -.Dl /usr/local/etc/rc.d/setiathome.sh start +.Dl %%PREFIX%%/etc/rc.d/%%PREFX%%setiathome%%SUFX%%.sh stop +.Dl %%PREFIX%%/etc/rc.d/%%PREFX%%setiathome%%SUFX%%.sh register +.Dl %%PREFIX%%/etc/rc.d/%%PREFX%%setiathome%%SUFX%%.sh start .Pp to do that. .Ss Setting up setiathome @@ -210,10 +243,10 @@ .El .Sh FILES .Bl -tag -width /var/db -compact -.It Pa /usr/local/etc/rc.d/setiathome.sh +.It Pa %%PREFIX%%/etc/rc.d/%%PREFX%%setiathome%%SUFX%%.sh Start-up script. .Pp -.It Pa /usr/local/etc/setiathome.conf +.It Pa %%PREFIX%%/etc/rc.%%PREFX%%setiathome%%SUFX%%.conf Optional configuration file for the start-up script. .Pp .It Pa /var/db/setiathome/ Index: files/setiathome.sh =================================================================== RCS file: /home/ncvs/ports/astro/setiathome/files/setiathome.sh,v retrieving revision 1.11 diff -u -r1.11 setiathome.sh --- files/setiathome.sh 12 Apr 2003 17:07:42 -0000 1.11 +++ files/setiathome.sh 27 May 2003 01:48:50 -0000 @@ -14,15 +14,20 @@ rc_arg=$1 # override these variables in ${PREFIX}/etc/rc.setiathome.conf +set -a seti_wrkdir=/var/db/${rc_file%.sh} # primary working directory -seti_std_args=-email # command arguments for standard mode -seti_reg_args=-login # command arguments for register mode -seti_proxy_args= # proxy arguments -seti_user=setiathome # user id to run as -seti_group=${seti_user} # group id to run as +seti_std_args="-email -graphics" # startup command line arguments +seti_reg_args=-login # command line arguments to register +seti_proxy_server= # HTTP proxy server (hostname:port) +seti_socks_server= # SOCKS proxy server (hostname:port) +seti_socks_user= # SOCKS proxy user name +seti_socks_passwd= # SOCKS proxy password +seti_user=setiathome # user name to run as +seti_group=${seti_user} # group name to run as seti_nice=15 # nice level to run at seti_maxprocs=$(sysctl -n hw.ncpu) # max. number of processes to start -seti_sleep=21600 # time to sleep between restarts +seti_sleep_time=21600 # time to sleep between restarts +set +a if ! PREFIX=$(expr ${rc_path} : "\(/.*\)/etc/rc\.d/${rc_file}\$"); then echo "${rc_file}: Cannot determine PREFIX." >&2 @@ -35,12 +40,30 @@ rcconf_path=${rcconf_dir}/${rcconf_file} if [ -f ${rcconf_path} ]; then + set -a . ${rcconf_path} + set +a fi program_dir=${PREFIX}/sbin program_file=${rc_file%.sh} program_path=${program_dir}/${program_file} +export program_path + +program_args="\ +${seti_std_args} \ +${seti_proxy_server:+-proxy} ${seti_proxy_server} \ +${seti_socks_server:+-socks_server} ${seti_socks_server} \ +${seti_socks_user:+-socks_user} ${seti_socks_user} \ +${seti_socks_passwd:+-socks_passwd} ${seti_socks_passwd} \ +${seti_nice:+-nice} ${seti_nice} \ +" +export program_args + + +wrapper_dir=${PREFIX}/libexec +wrapper_file=${rc_file%.sh}.bin +wrapper_path=${wrapper_dir}/${wrapper_file} syslog_facility=daemon.err @@ -50,6 +73,7 @@ seti_wrksuff="${seti_wrksuff} ${i}" i=$((${i} - 1)) done +export seti_wrksuff case "$rc_arg" in start) @@ -73,38 +97,44 @@ exit 72 fi done - for i in ${seti_wrksuff}; do - su -fm ${seti_user} -c "exec /bin/sh -T" << EOF > /dev/null & - cd ${seti_wrkdir}/${i} || exit - echo \$\$ > shpid.sah - trap 'kill \$pid;exit' 15 - while :; do - ${program_path} \ - ${seti_std_args} ${seti_proxy_args} \ - ${seti_nice:+-nice} ${seti_nice} & - pid=\$!; wait \$pid - sleep ${seti_sleep} & - pid=\$!; wait \$pid - done -EOF - done + if ps axo comm | egrep ${program_file}; then + logger -sp ${syslog_facility} -t ${program_file} \ + "unable to start: ${program_file} is already running." + exit 72 + fi + su -fm ${seti_user} -c "exec ${wrapper_path} > /dev/null &" echo -n " SETI@home" ;; stop) + pid_path=${seti_wrkdir}/shpid.sah + if [ -f ${pid_path} ]; then + pid=$(cat ${pid_path}) + [ -n "${pid}" ] && ps p ${pid} > /dev/null && kill ${pid} + rm -f ${pid_path} + fi for i in ${seti_wrksuff}; do - for pid_path in ${seti_wrkdir}/${i}/pid.sah \ - ${seti_wrkdir}/${i}/shpid.sah; do - if [ -f ${pid_path} ]; then - kill $(cat ${pid_path}) 2> /dev/null - fi - done + pid_path=${seti_wrkdir}/${i}/pid.sah + if [ -f ${pid_path} ]; then + pid=$(cat ${pid_path}) + [ -n "${pid}" ] && ps p ${pid} > /dev/null && kill ${pid} + fi done if [ ! -f ${seti_wrkdir}/pid.sah ]; then killall ${program_file} 2> /dev/null fi ;; +gracefull) + for i in ${seti_wrksuff}; do + pid_path=${seti_wrkdir}/${i}/pid.sah + stop_path=${seti_wrkdir}/${i}/stop_after_send.txt + if [ -f ${pid_path} ]; then + touch ${stop_path} + fi + done + ;; + restart) $0 stop $0 start @@ -187,7 +217,7 @@ ;; *) - echo "usage: ${rc_file} {start|stop|restart|status|register}" >&2 + echo "usage: ${rc_file} {start|stop|gracefull|restart|status|register}" >&2 exit 64 ;; esac >Release-Note: >Audit-Trail: >Unformatted: