Package: squid3
Version: 3.1.20-2.2+deb7u2
Severity: normal
Tags: patch

Dear Maintainer,

the squid3 init script fails to parse the cache_dir directive from our
squid3.conf. The reason is that our cache_dir directive is indented with
two spaces:

  cache_dir ufs /var/spool/squid3 10000 16 256

The sed expression that parses the config file doesn't allow for leading
white space:

s/^'$1'['"$w"']\+ ...

^ matches the beginning of the string and $1 matches cache_dir, and so
the expression will only parse lines that directly begin with cache_dir.

This prevents the init script from populating the cache dir; the
administrator has to resolve this by manually running squid3 -z. If the
cache dir is not populated, squid3 won't start and will instead log the
following error to cache.log:

2014/09/11 18:50:46| /var/spool/squid3/00: (2) No such file or directory
FATAL:  Failed to verify one of the swap directories, Check cache.log
        for details.  Run 'squid -z' to create swap directories
        if needed, or if running Squid for the first time.
Squid Cache (Version 3.1.20): Terminated abnormally.


I've attached a patch that fixes the following issues:
- consistent tab indentions in the init script
- fixes the w= line in find_cache_dir that is apparently supposed to
  contain a space followed by a tab, but currently just contains five
  spaces.
- allows for spaces before cache_dir in both find_cache_dir and
  find_cache_type.

-- System Information:
Debian Release: 7.6
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: i386 (x86_64)
Foreign Architectures: amd64

Kernel: Linux 3.14-0.bpo.2-amd64 (SMP w/8 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages squid3 depends on:
ii  adduser           3.113+nmu3
ii  libc6             2.13-38+deb7u4
ii  libcap2           1:2.22-1.2
ii  libcomerr2        1.42.5-1.1
ii  libdb5.1          5.1.29-5
ii  libexpat1         2.1.0-1+deb7u1
ii  libgcc1           1:4.7.2-5
ii  libgssapi-krb5-2  1.10.1+dfsg-5+deb7u2
ii  libk5crypto3      1.10.1+dfsg-5+deb7u2
ii  libkrb5-3         1.10.1+dfsg-5+deb7u2
ii  libldap-2.4-2     2.4.31-1+nmu2
ii  libltdl7          2.4.2-1.1
ii  libpam0g          1.1.3-7.1
ii  libsasl2-2        2.1.25.dfsg1-6+deb7u1
ii  libstdc++6        4.7.2-5
ii  libxml2           2.8.0+dfsg1-7+wheezy1
ii  logrotate         3.8.1-4
ii  lsb-base          4.1+Debian8+deb7u1
ii  netbase           5.0
ii  squid3-common     3.1.20-2.2+deb7u2

squid3 recommends no packages.

Versions of packages squid3 suggests:
ii  resolvconf   1.67
ii  smbclient    2:3.6.19-1~bpo70+1
pn  squid-cgi    <none>
ii  squidclient  3.1.20-2.2+deb7u2
pn  ufw          <none>

-- Configuration Files:
/etc/logrotate.d/squid3 changed:
/var/log/squid3/*.log {
        daily
        compress
        delaycompress
        rotate 7
        missingok
        nocreate
        sharedscripts
        prerotate
                /usr/lib/iserv/botdetector $1
        endscript
        postrotate
                test ! -e /var/run/squid3.pid || /usr/sbin/squid3 -k rotate
        endscript
}

/etc/squid3/squid.conf changed:
  http_port 10.0.0.13:3128 intercept
  http_port 127.0.0.1:3128
  cache_dir ufs /var/spool/squid3 10000 16 256
  maximum_object_size 1 GB


-- no debconf information
--- squid3.orig	2014-09-11 18:56:59.946223957 +0200
+++ squid3	2014-09-11 19:06:28.736129772 +0200
@@ -33,20 +33,20 @@
 ulimit -n 65535
 
 find_cache_dir () {
-        w="     " # space tab
-        res=`sed -ne '
-                s/^'$1'['"$w"']\+[^'"$w"']\+['"$w"']\+\([^'"$w"']\+\).*$/\1/p;
-                t end;
-                d;
-                :end q' < $CONFIG`
-        [ -n "$res" ] || res=$2
-        echo "$res"
+	w=" 	" # space tab
+	res=`sed -ne '
+		s/^['"$w"']\+'$1'['"$w"']\+[^'"$w"']\+['"$w"']\+\([^'"$w"']\+\).*$/\1/p;
+		t end;
+		d;
+		:end q' < $CONFIG`
+	[ -n "$res" ] || res=$2
+	echo "$res"
 }
 
 find_cache_type () {
 	w=" 	" # space tab
 	res=`sed -ne '
-		s/^'$1'['"$w"']\+\([^'"$w"']\+\).*$/\1/p;
+		s/^['"$w"']\+'$1'['"$w"']\+\([^'"$w"']\+\).*$/\1/p;
 		t end;
 		d;
 		:end q' < $CONFIG`
@@ -59,8 +59,8 @@
 	cache_type=`find_cache_type cache_dir`
 
 	#
-    # Create spool dirs if they don't exist.
-    #
+	# Create spool dirs if they don't exist.
+	#
 	if [ "$cache_type" = "coss" -a -d "$cache_dir" -a ! -f "$cache_dir/stripe" ] || [ "$cache_type" != "coss" -a -d "$cache_dir" -a ! -d "$cache_dir/00" ]
 	then
 		log_warning_msg "Creating $DESC cache structure"
@@ -106,7 +106,7 @@
 }
 
 case "$1" in
-    start)
+	start)
 	log_daemon_msg "Starting $DESC" "$NAME"
 	if start ; then
 		log_end_msg $?
@@ -114,7 +114,7 @@
 		log_end_msg $?
 	fi
 	;;
-    stop)
+	stop)
 	log_daemon_msg "Stopping $DESC" "$NAME"
 	if stop ; then
 		log_end_msg $?
@@ -122,13 +122,13 @@
 		log_end_msg $?
 	fi
 	;;
-    reload|force-reload)
+	reload|force-reload)
 	log_action_msg "Reloading $DESC configuration files"
 	start-stop-daemon --stop --signal 1 \
 		--pidfile $PIDFILE --quiet --exec $DAEMON
 	log_action_end_msg 0
 	;;
-    restart)
+	restart)
 	log_daemon_msg "Restarting $DESC" "$NAME"
 	stop
 	if start ; then
@@ -137,10 +137,10 @@
 		log_end_msg $?
 	fi
 	;;
-    status)
+	status)
 	status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit 3
 	;;
-    *)
+	*)
 	echo "Usage: /etc/init.d/$NAME {start|stop|reload|force-reload|restart|status}"
 	exit 3
 	;;

Reply via email to