[Pkg-samba-maint] r1124 - trunk

Steve Langasek vorlon at costa.debian.org
Mon Aug 14 00:50:05 UTC 2006


Author: vorlon
Date: 2006-08-14 00:50:04 +0000 (Mon, 14 Aug 2006)
New Revision: 1124

Modified:
   trunk/samba-common.postinst
Log:
Refine the handling of "passdb backend = foo guest" on upgrade:  handle
additional whitespace before or after the 'guest' token, limit the action
to the [global] section of the config file which is the only section this
line should be valid in, permit other non-alpha characters in the
passdb backend value (who's to say they're not valid with some custom backend
name?), and only edit the file if we know it's safe or we've been given
permission by the admin.

Also, use a tempfile with sed as elsewhere in the maintainer script, to ensure
our config file overwrites are atomic.



Modified: trunk/samba-common.postinst
===================================================================
--- trunk/samba-common.postinst	2006-08-13 23:38:25 UTC (rev 1123)
+++ trunk/samba-common.postinst	2006-08-14 00:50:04 UTC (rev 1124)
@@ -84,6 +84,16 @@
 		mv -f ${TMPFILE} /etc/samba/smb.conf
 	fi
 
+	if [ -n "$2" ] && dpkg --compare-versions "$2" lt 3.0.23b-2 \
+	   && grep -qi "^[[:space:]]*passdb backend[[:space:]]*=.*guest" /etc/samba/smb.conf
+	then
+		sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
+			/^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ \
+			        s/^\([[:space:]]*passdb backend[[:space:]]*=.*\)[[:space:]]*guest[[:space:]]*$/\1/i" \
+			< /etc/samba/smb.conf >${TMPFILE}
+		mv -f ${TMPFILE} /etc/samba/smb.conf
+	fi
+
 	if dpkg --compare-versions "$2" lt 2.999+3.0.alpha20-4 \
 	   && ! grep -q "^[[:space:]]*panic action[[:space:]]*=" /etc/samba/smb.conf
 	then
@@ -103,8 +113,4 @@
 
 db_stop
 
-if [ -n "$2" ] && dpkg --compare-versions "$2" lt 3.0.23b-2; then
-	sed -i -e 's/^\([[:space:]]*passdb backend[[:space:]]*=[[:space:]]*[[:alpha:]][[:alpha:]]*\) guest$/\1/' /etc/samba/smb.conf
-fi
-
 #DEBHELPER#




More information about the Pkg-samba-maint mailing list