Package: geneweb
Version: 5.02~cvs20091031-3
Severity: serious
Tags: patch
Justification: broken upgrades from earlier versions

If one of the databases in /var/lib/geneweb has spaces in its name,
the package's postinst script will fail.

The attached postinst file fixes that problem. Until I update packages
in lenny, users affectedd by this bug can just replace
/var/lib/dpkg/info/geneweb.postinst by it and run dpkg-reconfigure to
complete the installation.

This bug was fixed in 5.02~cvs20091031-4. I open it lately so that
there is a reference to it in the BTS. I will try to upload a fixed
package to stable-proposed-updates in order to fix lenny.


-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.30-2-686 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages geneweb depends on:
ii  adduser                       3.111      add and remove users and groups
ii  cdebconf [debconf-2.0]        0.145      Debian Configuration Management Sy
ii  debconf [debconf-2.0]         1.5.28     Debian configuration management sy
ii  iso-codes                     3.12-1     ISO language, territory, currency,
ii  isoquery                      0.18-1     Search and display various ISO cod
ii  libc6                         2.10.2-2   GNU C Library: Shared libraries
ii  lsb-base                      3.2-23     Linux Standard Base 3.2 init scrip
ii  perl-base [perl5-base]        5.10.1-8   minimal Perl system

geneweb recommends no packages.

Versions of packages geneweb suggests:
pn  gwsetup                     <none>       (no description available)
pn  gwtp                        <none>       (no description available)
ii  iceweasel [www-browser]     3.5.6-1      lightweight web browser based on M
ii  konqueror [www-browser]     4:4.3.4-1    KDE 4's advanced file manager, web
ii  lynx                        2.8.8dev.2-1 Text-mode WWW Browser (transitiona
ii  lynx-cur [www-browser]      2.8.8dev.2-1 Text-mode WWW Browser with NLS sup
ii  menu                        2.1.42       generates programs menu for all me
ii  w3m [www-browser]           0.5.2-2.1    WWW browsable pager with excellent

-- debconf information excluded
#! /bin/sh
# postinst script for GeneWeb
#
# see: dh_installdeb(1)

set -e 

# Needs Depends: iso-codes, isoquery
ISOQUERY=/usr/bin/isoquery

# These will be used here and there below
SERVICES=/etc/services
OLDRCFILE=/etc/geneweb/genewebrc
NEWRCFILE=/etc/default/geneweb
INITFILE=/etc/init.d/geneweb
GENEWEBUSER=geneweb


# We we'll need some variables defined there
# We first define some defaults values...just in case
GENEWEBDB=/var/lib/geneweb
USERS_GROUP=geneweb
LOGFILE=/var/log/geneweb.log

# Default settings
DEFAULTLNG="en"
DEFAULTFULLLNG="English"
DEFAULTPORT=2317
DEFAULTRUNMODE="Always on"
DEFAULTREMOVE=false
DEFAULTOPTIONS=""


# Reads config file (will override defaults above)
[ -r $NEWRCFILE ] && . $NEWRCFILE

. /usr/share/debconf/confmodule
db_version 2.0

write_rcfile() {
   cat >$NEWRCFILE <<EOF
#
# GeneWeb Configuration Data
#
# This file may be changed manually, or by running "dpkg-reconfigure geneweb"

# The port which the daemon listens to
PORT="${PORT}"

# The default language
# Look at Geneweb documentation for valid values
# Versions prior to 4.10-9 used LANG which could mix up with
# the system's localisation settings
LNG="${LNG}"

# The run mode
# Two possible values: "Always on" or "Manual"
# You need to use quotes
RUN_MODE="${RUN_MODE}"

# Additionnal options for gwd
# Example: OPTIONS="-a 192.168.1.1" for binding the daemon to a given address
# This setting is not handled by debconf
OPTIONS="${OPTIONS}"
EOF
}

get_debconf() {
    db_get geneweb/port
    PORT=$RET
    # If not present, use default
    if [ "$PORT" = "" ]
    then
	PORT=$DEFAULTPORT
    fi


    db_get geneweb/lang
    FULLLNG=$RET
    # If not present, use default
    if [ "$FULLLNG" = "" ]
    then
	FULLLNG=$DEFAULTFULLLNG
    fi
    # Find the two letter code for language
    # LNG=`echo $FULLLNG | cut -f 2 -d "(" | cut -f 1 -d ")"`
    LNG=`$ISOQUERY --iso=639 | grep "${FULLLNG}\$" | cut -f3`


    db_get geneweb/run_mode
    RUN_MODE="$RET"
    # If not present, use default
    if [ "$RUN_MODE" = "" ]
    then
	RUN_MODE="$DEFAULTRUNMODE"
    fi
}




case "$1" in
    configure)

	# NEWRCFILE has to be world-readable if we want the entry menu to work
	[ -f $NEWRCFILE ] && chmod g+r,a+r $NEWRCFILE

	[ -f $INITFILE ] && chmod a+rx $INITFILE

	if [ -d "/usr/share/doc/geneweb/$LNG" ]; then
		ln -sf /usr/share/doc/geneweb/$LNG /usr/share/doc/geneweb/doc_choice
	else
		ln -sf /usr/share/doc/geneweb/en /usr/share/doc/geneweb/doc_choice
	fi

	if [ ! -x `which addgroup` ]; then
	    echo "addgroup(8) from the \'adduser\' package is needed...";
	    exit 1;
	fi

	# Make sure user group is available
	if ! getent group ${USERS_GROUP} >/dev/null
	then
	    echo "Adding $USERS_GROUP group ... "
	    addgroup --quiet --force-badname $USERS_GROUP
	fi
	
	if [ ! -x `which adduser` ]; then
	    echo "adduser(8) from the \'adduser\' package is needed...";
	    exit 1;
	fi

	# Make sure geneweb user exists
	if ! getent passwd ${GENEWEBUSER} >/dev/null
	then
	    echo "Adding $GENEWEBUSER user ... "
	    adduser --quiet --system --home /var/lib/geneweb --no-create-home --ingroup $USERS_GROUP $GENEWEBUSER
	fi
	
	# Permissions and groups changes come back
	# to the configure stage again.
	# Problems may remains if users previously messed up
	# the permissions...but more huge problems will
	# occur if this stage occurs _before_ the geneweb
	# group creation (was bug 171570 on 4.07-3 release)

	if [ ! -f $LOGFILE ]
	then
	    touch $LOGFILE
	fi

	# Thus all files created there will have geneweb as group
	chown root:$USERS_GROUP $GENEWEBDB $GENEWEBDB/images $GENEWEBDB/cnt $GENEWEBDB/etc
	# The database directory is writable by geneweb group
	chmod ug+rwx,o-rwx $GENEWEBDB $GENEWEBDB/images $GENEWEBDB/cnt $GENEWEBDB/etc
	# SetGID bit on the database directory owned by geneweb group
	chmod g+s $GENEWEBDB $GENEWEBDB/images $GENEWEBDB/cnt $GENEWEBDB/etc

	# The log file is written by gwd running as the geneweb user
	# Make it readable/writable by this user only
	chown $GENEWEBUSER:$USERS_GROUP $LOGFILE
	chmod 600 $LOGFILE

	# Fix incorrect database and images directories permissions
	# These directories have to be group-writable
	# as the daemon now runs with an unprivileged UID
	#
	# Thanks to Russell Sutherland for pointing this to me
	# Bug: 179918
	#
	# Deal properly with database names that contain spaces
	OLDIFS=${IFS}
	IFS='
'
	for base in `find $GENEWEBDB -type d -name \*.gwb`
	do
	    chgrp $USERS_GROUP "$base"
	    chmod g+w,g+s "$base"
	    # Fix files permissions. See #219779
	    for file in `find $base -type f`
	    do
		chgrp $USERS_GROUP "$file"
		chmod g+w "$file"
	    done
	done
	for imagedir in `find $GENEWEBDB/images -type d`
	do
	    chgrp $USERS_GROUP "$imagedir"
	    chmod g+w,g+s "$imagedir"
	done
	IFS=${OLDIFS}

	# Values are read from debconf
	# to update variables
	get_debconf
	# The settings file is written
	# Moved to postinst
	write_rcfile

	;;
    *)
	;;
esac

# Transition of init scripts links: we don't want them in runlevels
# 0 and 6 anymore
if dpkg --compare-versions "$2" lt "5.01-4"; then
	update-rc.d -f geneweb remove
fi

# Automatically added by dh_installmenu
if [ "$1" = "configure" ] && [ -x "`which update-menus 2>/dev/null`" ]; then
	update-menus
fi
# End automatically added section
# Automatically added by dh_installinit
if [ -x "/etc/init.d/geneweb" ]; then
	update-rc.d geneweb start 20 2 3 4 5 . stop 20 1 . >/dev/null
	if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
		invoke-rc.d geneweb start || exit $?
	else
		/etc/init.d/geneweb start || exit $?
	fi
fi
# End automatically added section

Reply via email to