FreeBSD Bugzilla – Attachment 215535 Details for
Bug 247247
www/squid: fails to start when dir for pidfile does not exist (e.g. /var/run is a tmpfs)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch for squid's service script
squid-4.10.diff (text/plain), 8.69 KB, created by
Walter von Entferndt
on 2020-06-14 08:06:03 UTC
(
hide
)
Description:
patch for squid's service script
Filename:
MIME Type:
Creator:
Walter von Entferndt
Created:
2020-06-14 08:06:03 UTC
Size:
8.69 KB
patch
obsolete
>--- etc/rc.d/squid.orig 2020-06-12 20:33:37.646456000 +0200 >+++ etc/rc.d/squid 2020-06-14 09:51:16.902922000 +0200 >@@ -1,148 +1,186 @@ > #!/bin/sh > # > # $FreeBSD: branches/2020Q2/www/squid/files/squid.in 474197 2018-07-08 20:46:45Z swills $ > # > # PROVIDE: squid >-# REQUIRE: LOGIN >+# REQUIRE: NETWORKING kdc > # KEYWORD: shutdown > # >-# Note: >-# Set "squid_enable=yes" in either /etc/rc.conf, /etc/rc.conf.local or >-# /etc/rc.conf.d/squid to activate Squid. >+# To enable Squid, type (in a console) >+# 'service squid enable' >+# or 'sysrc [-f /etc/rc.conf.local] squid_enable=yes' > # >-# Additional variables you can define in one of these files: >+# NOTE 'kdc' is not required to run Squid, but if Squid uses Kerberos, >+# the addition in REQUIRE ashures they are started in the right order. > # >-# squid_chdir: the directory into which the rc system moves into before >-# starting Squid. Default: /var/squid >+# Additional variables you can define in one of $rc_conf_files >+# (/etc/rc.conf[.local] & {/usr/local}/etc/rc.conf.d/$name): >+# to see them all, type 'sysrc squid rcvar', and to set one: 'sysrc var=value' > # >-# squid_conf: The configuration file that Squid should use. >-# Default: /usr/local/etc/squid/squid.conf >-# >-# squid_fib: The alternative routing table id that Squid should use. >-# Default: none >-# See setfib(1) for further details. Note that the setfib(2) >-# system call is not available in FreeBSD versions prior to 7.1. >-# >-# squid_user: The user id that should be used to run the Squid master >-# process. Default: squid. >-# Note that you probably need to define "squid_user=root" if >-# you want to run Squid in reverse proxy setups or if you want >-# Squid to listen on a "privileged" port < 1024. >-# >-# squid_pidfile: >-# The name (including the full path) of the Squid >-# master process' PID file. >-# Default: /var/run/squid/squid.pid. >-# You only need to change this if you changed the >-# corresponding entry in your Squid configuration. >-# >-# squid_flags: Additional commandline arguments for Squid you might want to >-# use. See squid(8) for further details. >-# >-# squid_krb5_ktname: >-# Alternative Kerberos 5 Key Table. >-# Default: none >-# squid_krb5_config: >-# Alternative Kerberos 5 config file >-# Default: none >- > . /etc/rc.subr > > name=squid > rcvar=squid_enable >- >-# Make sure that we invoke squid with "-f ${squid_conf}"; define this >-# variable early so reload_cmd and stop_precmd pick it up: >- > extra_commands="reload configtest" >+desc="(forward & reverse) HTTP/HTTPS/FTP caching proxy" > reload_cmd=squid_reload > start_precmd=squid_prestart > start_postcmd=squid_getpid > stop_precmd=squid_prestop > configtest_cmd=squid_configtest > reload_precmd=squid_configtest > restart_precmd=squid_configtest > >-# squid(8) will not start if ${squid_conf} is not present so try >-# to catch that beforehand via ${required_files} rather than make >-# squid(8) crash. >+rc_debug="yes" >+rc_info="yes" > >-squid_load_rc_config() >+# setup_vars() - set rc.subr(8) vars & defaults /before/ load_rc_config() >+#squid_setup_vars() >+#{ >+#local _var >+ >+set_rcvar ${name}_enable NO \ >+ "To enable $name, use 'service ${name} enable'^^ >+ or 'sysrc ${name}_enable=yes'^^ >+ To start $name, use 'service $name start'" >+set_rcvar ${name}_program /usr/local/sbin/${name} >+set_rcvar ${name}_chdir /var/${name} "$name's working (home) directory" >+set_rcvar ${name}_conf /usr/local/etc/${name}/${name}.conf \ >+ "$name's configuration file" >+set_rcvar ${name}_user ${name} \ >+ "${name}'s user id that runs the master process.^^ >+ NOTE that you most probably need to define '${name}_user=root'^^ >+ if you want to run $name in reverse proxy setups^^ >+ or if you want $name to listen on a privileged port < 1024." >+set_rcvar ${name}_flags NONE \ >+ "Additional command line arguments for $name.^^ >+ See ${name}(8) for further details.^^ >+ NOTE '-f \\\$${name}_conf' is always appended and can be ommited." >+set_rcvar ${name}_maxwait 15 \ >+ "Max. time [seconds] to wait for $name to start up" >+set_rcvar ${name}_pidfile /var/run/${name}/${name}.pid \ >+ "(OBSOLETE)^^ >+ Instead, it is read from $name's config file \\\$${name}_conf.^^ >+ This overrules the default and any setting in^^ >+ \\\$rc_conf_files (and {/usr/local}/etc/rc.conf.d/$name)." >+set_rcvar ${name}_fib NONE \ >+ "The alternative routing table id for $name.^^ >+ See setfib(1) for further details. Note that the setfib(2)^^ >+ system call is not available in FreeBSD versions prior to 7.1." >+set_rcvar ${name}_krb5_ktname NONE "Alternative Kerberos 5 Key Table" >+set_rcvar ${name}_krb5_config NONE "Alternative Kerberos 5 config file" >+#} >+ >+# setup_config() - /after/ our settings are read via load_rc_config() >+squid_setup_config() > { >- : ${squid_chdir:=/var/squid} >- : ${squid_conf:=/usr/local/etc/squid/squid.conf} >- : ${squid_enable:=NO} >- : ${squid_program:=/usr/local/sbin/squid} >- : ${squid_pidfile:=/var/run/squid/squid.pid} >- : ${squid_user:=squid} >+ # rc.subr(8):get_pidfile_from_conf() uses this variable: >+ local _pidfile_from_conf >+ local _var > >- required_args="-f ${squid_conf}" >- required_dirs=$chdir >+ # Squid will not start if $squid_conf is not present so try to catch >+ # that beforehand via $required_files rather than make it crash. > required_files=$squid_conf >- command_args="${required_args} ${squid_flags}" >-# We used to need it in squid3 to match pid and proc name >-# procname="?squid-*" >+ >+ # $pidfile: override default or setting from rc.conf >+ if get_pidfile_from_conf "pid_filename" ${squid_conf} \ >+ && [ -n "$_pidfile_from_conf" ]; then >+ squid_pidfile=$_pidfile_from_conf >+ fi > pidfile=$squid_pidfile >+ piddir=$(dirname ${pidfile}) >+ for _var in dir file; do >+ eval debug "pid${_var}=\$pid${_var}" >+ done >+ # Debug to check all went well - now the vars should be set >+ for _var in enable program "chdir" conf user flags maxwait pidfile \ >+ fib kbr5_ktname krb5_config; do >+ eval debug "${name}_${_var}=\$${name}_${_var}" >+ done >+ required_dirs="${squid_chdir} ${piddir}" >+ >+ # Make sure that we invoke squid with "-f ${squid_conf}"; define >+ # this variable early so reload_cmd and stop_precmd pick it up: >+ required_args="-f ${squid_conf}" >+ >+ for _var in args dirs files; do >+ eval debug "required_${_var}=\${required_${_var}}" >+ done >+ [ $squid_flags == "NONE" ] && squid_flags="" >+ command_args="${squid_flags} ${required_args}" >+ eval debug "command_args=\${command_args}" >+ >+ [ "${squid_fib}" == "NONE" ] && squid_fib="" >+ >+ # We used to need it in squid3 to match pid and proc name >+ # procname="?squid-*" > } > >+# prestart() - setup shell environment, create files & directories, if needed. > squid_prestart() > { >- # setup KRB5_KTNAME: >- squid_krb5_ktname=${squid_krb5_ktname:-"NONE"} >+ # if squid runs as non-root, we need to create the $pidfile >+ # XXX done by service(8) via required_dirs? >+ # [ -d $piddir ] || mkdir $piddir >+ info "creating pidfile: $pidfile" >+ [ -f $pidfile ] || touch $pidfile >+ >+ # the $piddir must be empty and should be owned by $squid_user >+ chown $squid_user $pidfile >+ chmod 600 $pidfile >+ >+ squid_configtest >+ > if [ "${squid_krb5_ktname}" != "NONE" ]; then > export KRB5_KTNAME=${squid_krb5_ktname} > fi >- >- # setup KRB5_CONFIG: >- squid_krb5_config=${squid_krb5_config:-"NONE"} > if [ "${squid_krb5_config}" != "NONE" ]; then > export KRB5_CONFIG=${squid_krb5_config} > fi >- >- # setup FIB tables: >+ # setup FIB tables > if command -v check_namevarlist > /dev/null 2>&1; then > check_namevarlist fib && return 0 > fi >- > ${SYSCTL} net.fibs >/dev/null 2>&1 || return 0 > >- squid_fib=${squid_fib:-"NONE"} >- if [ "${squid_fib}" != "NONE" ]; then >+ if [ -n "${squid_fib}" ]; then > command="setfib -F $squid_fib $command" >- else >- return 0 > fi >- >- squid_configtest > } > > squid_reload() > { >- $command $required_args $squid_flags -k reconfigure >+ $command $command_args -k reconfigure > } > > squid_configtest() > { >- echo "Performing sanity check on ${name} configuration." >- if $command $required_args $squid_flags -k check; then >- echo "Configuration for ${name} passes." >+ info "Performing sanity check on ${name} configuration." >+ if $command $command_args -k check; then >+ info "Configuration for ${name} is ok." > return 0 > else > return $? > fi > } > >+# squid_getpid() - wait for squid to start up completely > squid_getpid() > { >- # retrieve the PID of the Squid master process explicitly here >- # in case rc.subr was unable to determine it: > if [ -z "$rc_pid" ]; then >+ local _secs=0 > while ! [ -f ${pidfile} ]; do >+ if [ $squid_maxwait -le $_secs ]; then >+ warn "giving up" >+ break; >+ fi > sleep 1 >+ echo -n "." >+ : $((_secs+=1)) > done > read _pid _junk <${pidfile} > [ -z "${_pid}" ] || pid=${_pid} > else > pid=${rc_pid} > fi > } >@@ -150,9 +188,9 @@ > squid_prestop() > { > command_args="$command_args -k shutdown" > squid_configtest > } > > load_rc_config $name >-squid_load_rc_config >+squid_setup_config > run_rc_command $1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 247247
: 215535