[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Samba security-update probleem



Diederik de Haas schreef:
> On 2010-03-04 Paul van der Vlis wrote:
>> dpkg: error processing samba-common (--configure):
>>  subprocess post-installation script returned error exit status 4
>> ----------
>>
>> Wat opvalt is dat als ik het nog eens doe, de tekst achter
>> "etc/samba//sed" veranderd in b.v. "IB9WZt:".
>>
>> Iemand een idee wat dit kan zijn?
>>
> Open de samba-common deb file in een archive programma (ik gebruik ark) en open vervolgens de 
> control.tar.gz file. In die archive kan je de scripts die bij het installeren worden gebruikt 
> bekijken en zo de oorzaak van de fout achterhalen.

Hartelijk bedankt voor je hulp.

Het lijkt dat ik het postinst script moet hebben gezien de foutmelding.
Het vinden van de oorzaak vind ik echter nog niet heel eenvoudig, sed is
niet mijn sterke kant.

Ik wil het script debuggen door er wat output bij in te zetten zodat ik
 kan achterhalen waar het precies mis gaat.

Iemand een idee of ik het script gewoon kan uitvoeren op een moment dat
Samba uit staat?
Ik neem aan dat eerst postinst wordt uitgevoerd, en dan config?
Ik zie de volgende scripts: postinst, config, postrm.

Ik zal het postinst script toevoegen, maar ben niet zeker of deze
mailinglist bijlages accepteert.

Met vriendelijke groet,
Paul van der Vlis.
#!/bin/sh
#
#

set -e

# Do debconf stuff here
. /usr/share/debconf/confmodule

TEMPDIR=/var/run/samba/upgrades
NEWFILE=$TEMPDIR/smb.conf
CONFIG=/etc/samba/smb.conf

# ------------------------- Debconf questions start ---------------------

configure_smb_conf() {
	local CONFIG
	CONFIG="$1"

	# Is the user configuring with debconf, or he/she prefers
	# swat/manual config?
	db_get samba-common/do_debconf || true
	if [ "${RET}" != "true" ]; then
		return 0
	fi

	# Get workgroup name
	db_get samba-common/workgroup || true
	WORKGROUP="${RET}"

	# Oh my GOD, this is ugly.  Why would anyone put these
	# characters in a workgroup name?  Why, Lord, why???
	WORKGROUP=`echo $WORKGROUP | \
	           sed -e's/\\\\/\\\\\\\\/g
	                  s#/#\\\\/#g
	                  s/&/\\\&/g
	                  s/\\\$/\\\\\\\$/g'`

	sed -i -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
		/^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ \
			s/^\([[:space:]]*\)workgroup[[:space:]]*=.*/\1workgroup = ${WORKGROUP}/i" \
		"$CONFIG"

	# Encrypt passwords?
	db_get samba-common/encrypt_passwords || true
	ENCRYPT_PASSWORDS="${RET}"

	sed -i -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
		/^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ \
		        s/^\([[:space:]]*\)encrypt passwords[[:space:]]*=.*/\1encrypt passwords = ${ENCRYPT_PASSWORDS}/i" \
		"$CONFIG"

	# Install DHCP support
	db_get samba-common/dhcp
	if [ "$RET" = true ] && \
	   ! grep -q dhcp.conf "$CONFIG"
	then
		sed -i -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
			/^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ {
				/wins server[[:space:]]*=/a \\
\\
# If we receive WINS server info from DHCP, override the options above. \\
   include = /etc/samba/dhcp.conf
}" "$CONFIG"
	elif [ "$RET" != true ]; then
		sed -i -e '
		/^#[[:space:]]*If we receive WINS server info from DHCP, override the options above/d
		/^#*[[:space:]]*include[[:space:]]*=[[:space:]]*\/etc\/samba\/dhcp.conf/,/[^[:space:]]/ {
			/^#*[[:space:]]*include[[:space:]]*=[[:space:]]*\/etc\/samba\/dhcp.conf/d
			/^[[:space:]]*$/d
		}' "$CONFIG"
	fi

	if [ -n "$2" ] && dpkg --compare-versions "$2" lt 3.0.23b-2 \
	   && grep -qi "^[[:space:]]*passdb backend[[:space:]]*=.*guest" "$CONFIG"
	then
		sed -i -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
			/^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ \
			        s/^\([[:space:]]*passdb backend[[:space:]]*=[^,]*\),\?[[:space:]]*guest[[:space:]]*$/\1/i" \
			"$CONFIG"
	fi
}


if [ -e "$CONFIG" ]; then
	configure_smb_conf "$CONFIG"
fi

mkdir -p "$TEMPDIR"

if [ -n "$2" ] && dpkg --compare-versions "$2" lt 3.0.28-3; then
	if dpkg --compare-versions "$2" lt 3.0.26a-1 && [ "$2" != "${2%ubuntu*}" ]
	then
		base=dapper
	elif [ "$2" != "${2%ubuntu*}" ]
	then
		base=gutsy
	else
		base=etch
	fi

	TEMPLATE=/usr/share/samba/smb.conf.${base}

	cp "$TEMPLATE" "$NEWFILE"
	configure_smb_conf "$NEWFILE"

	if [ -e "$CONFIG" ]; then
		sed -e '1,/^[;#[:space:]]*\[cdrom\]/ { d }
			1,/^[[:space:]]*\[/ { /^[^[]/d; /^$/d }
		' "$CONFIG" >> "$NEWFILE"
	fi

	ucf --three-way --debconf-ok "$NEWFILE" "$CONFIG"
fi

cp /usr/share/samba/smb.conf "$NEWFILE"
configure_smb_conf "$NEWFILE"

if [ -e "$CONFIG" ]; then
	sed -e '1,/^[;#[:space:]]*\[cdrom\]/ { d }
		1,/^[[:space:]]*\[/ { /^[^[]/d; /^$/d }
	' "$CONFIG" >> "$NEWFILE"
fi

ucf --three-way --debconf-ok "$NEWFILE" "$CONFIG"
ucfr samba-common "$CONFIG"

chmod a+r "$CONFIG"

# ------------------------- Debconf questions end ---------------------

db_stop



Reply to: