Bug#440109: sympa: Trying to find a fix

2008-02-20 Thread Olivier Berger

Le mardi 19 février 2008 à 19:20 +0100, Olivier Berger a écrit :
> Hi.
> 
> I've tried and find what's going wrong here.
> 
> It seems to me that install-pg-db should not create the database, but only 
> create the user (with createdb rights maybe, instead of nocreatedb), or, 
> otherwise, create the full database and tables, by executing the whole 
> /usr/lib/sympa/bin/create_db.Pg, then.
> 
> Also, the /usr/lib/sympa/bin/sympa.pl --prepare_db cannot create the database 
> at the moment for postgresql from what I could see.
> 
> I need to do more tests to figure out what's happening, but this may be an 
> option to come to solution of this bug.
> 
> Hope this help
> 

I think I've indeed found a way to get it to install with postgresql-8.3
(current in testing).

The attached patch provides a way to go, at least from the first tests.
I'm not sure there wouldn't be problems on upgrade, and I'm not sure it
works in all cases, but more testing from others would be great.

Here's the idea to apply the workaround in testing :

1. install postgresql-8.3 and sympa (from unstable package), selecting
"no database" mode for sympa

2. don't change the default postgresql setup : postgres user can connect
without a password, doing "su - postgres" then psql, for instance

3. Apply the provided patch to /usr/share/sympa/db files (prepare_db and
install-pg-db)

4. LANG=C dpkg-reconfigure sympa, and select :
 * database : postgresql
 * localhost, sympa database, sympa user, a password for sympa user
(twice), and nothing for admin password

The reconfigure/postinst should now :
1. create the sympa user
2. create the database as sympa unix user
3. create the database tables as sympa unix user
4. no longer try the sympa.pl --prepare_db

Then sympa should hopefully start and connect to the PostGres DB

Comments much welcome, of course.

-- 
Olivier BERGER <[EMAIL PROTECTED]> (*NEW ADDRESS*)
http://www-inf.it-sudparis.eu/~olberger/ - OpenPGP-Id: 1024D/6B829EEC
Ingénieur Recherche - Dept INF
Institut TELECOM / TELECOM & Management SudParis
(http://www.it-sudparis.eu/), Evry

diff -Naur db.orig/install-pg-db db/install-pg-db
--- db.orig/install-pg-db	2008-02-20 11:17:09.0 +0100
+++ db/install-pg-db	2008-02-20 11:14:44.0 +0100
@@ -4,6 +4,17 @@
 # Copyright 2000, 2001, 2002 Jérôme Marant <[EMAIL PROTECTED]>
 # Copyright 2003, 2004, 2005 Stefan Hornburg (Racke) <[EMAIL PROTECTED]>
 
+# Args :
+#  -d [database] : database to be created (mandatory)
+#  -w [user] : user to create database for (mandatory)
+#  -u [user_password_file] : provides the path to the file containing the user password (mandatory)
+#  -i : connect in Ident mode (-p ignored in this case)
+#  -a [admin_password_file] : provides the path to the file containing the admin password
+#  -h [host] : postgresql server to connect to (optionnal, by default localhost)
+#  -p [port] : port to contact (optionnal, by default 5432)
+#  -o [options] : additional connection options (optional)
+#
+
 use strict;
 use warnings;
 
@@ -73,24 +84,25 @@
 		{'RaiseError' => 1});
 }
 
-# Create database
-eval {$dbh->do("CREATE DATABASE $database")};
-
-if ($@) {
-	warn "Failed to create database $database: [EMAIL PROTECTED]";
-	exit 1;
-}
-
 # Create user sympa
 #$dbh->do("DELETE FROM pg_shadow WHERE usename='sympa'");
 
-eval {$dbh->do("CREATE USER $user with password '".$userpass."' nocreateuser nocreatedb");};
+#eval {$dbh->do("CREATE USER $user with password '".$userpass."' nocreateuser nocreatedb");};
+eval {$dbh->do("CREATE USER $user with password '".$userpass."' nocreateuser createdb");};
 
 if ($@) {
 	warn "Failed to create user $user: [EMAIL PROTECTED]";
 	exit 1;
 }
 
+# Create database
+#eval {$dbh->do("CREATE DATABASE $database")};
+
+#if ($@) {
+#	warn "Failed to create database $database: [EMAIL PROTECTED]";
+#	exit 1;
+#}
+
 $dbh->disconnect();
 
 exit 0;
diff -Naur db.orig/prepare_db db/prepare_db
--- db.orig/prepare_db	2008-02-20 11:17:09.0 +0100
+++ db/prepare_db	2008-02-20 11:19:16.0 +0100
@@ -66,7 +66,7 @@
 	if [ "$RET" ]; then
 		OPTS="-w $RET $OPTS"
 	fi
-
+#set -x
 	case $db_type in
 		"PostgreSQL")
 			db_get sympa/db_authtype
@@ -74,22 +74,28 @@
 OPTS="-i $OPTS"
 			fi
 			/usr/share/sympa/db/install-pg-db $OPTS -d "$db_name" -h "$db_hostname" -u "$userpassfile"
+			su -s /bin/sh sympa -- -c "/usr/bin/createdb -e -O sympa sympa"
+#			su -s /bin/sh sympa -- -c "cat /usr/lib/sympa/bin/create_db.Pg | psql -a"
+			su -s /bin/sh sympa -- -c "cat /usr/lib/sympa/bin/create_db.Pg | psql"
+			db_set sympa/db_configured true
 		;;
 		"MySQL")
 			/usr/share/sympa/db/install-mysql-db $OPTS -d "$db_name" -h "$db_hostname" -u "$userpassfile"
+
+			sympaerrors=`tempfile -m 0600`
+
+			if /usr/lib/sympa/bin/sympa.pl -f $conffile --prepare_db 2>$sympaerrors; then
+			db_set sympa/db_configured true
+			rm -f $sympaerrors
+			else 
+			cat $sympaerrors
+			echo "Sympa failed to prepare database."
+			rm -f $symp

Bug#440109: sympa: Trying to find a fix

2008-02-19 Thread Olivier Berger
Package: sympa
Followup-For: Bug #440109

Hi.

I've tried and find what's going wrong here.

It seems to me that install-pg-db should not create the database, but only 
create the user (with createdb rights maybe, instead of nocreatedb), or, 
otherwise, create the full database and tables, by executing the whole 
/usr/lib/sympa/bin/create_db.Pg, then.

Also, the /usr/lib/sympa/bin/sympa.pl --prepare_db cannot create the database 
at the moment for postgresql from what I could see.

I need to do more tests to figure out what's happening, but this may be an 
option to come to solution of this bug.

Hope this help

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

Kernel: Linux 2.6.22-3-vserver-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/bash

Versions of packages sympa depends on:
ii  adduser   3.105  add and remove users and groups
ii  debconf [debconf-2.0] 1.5.19 Debian configuration management sy
ii  exim4-daemon-light [mail-tran 4.69-2 lightweight Exim MTA (v4) daemon
pn  libarchive-zip-perl(no description available)
ii  libc6 2.7-6  GNU C Library: Shared libraries
pn  libcgi-fast-perl   (no description available)
pn  libcrypt-ciphersaber-perl  (no description available)
ii  libdbd-mysql-perl 4.006-1A Perl5 database interface to the 
ii  libdbi-perl   1.601-1Perl5 database interface by Tim Bu
ii  libfcgi-perl  0.67-2 FastCGI Perl module
ii  libintl-perl  1.16-4 Uniforum message translations syst
ii  libio-stringy-perl2.110-3Perl5 modules for IO from scalars 
ii  libmailtools-perl 1.77-1 Manipulate email in perl programs
pn  libmd5-perl(no description available)
ii  libmime-perl  5.425-2transitional dummy package
ii  libmime-tools-perl [libmime-p 5.425-2Perl5 modules for MIME-compliant m
pn  libmsgcat-perl (no description available)
pn  libnet-ldap-perl   (no description available)
pn  libtemplate-perl   (no description available)
ii  libxml-libxml-perl1.63-1.1   Perl module for using the GNOME li
pn  mhonarc(no description available)
ii  perl [libmime-base64-perl]5.8.8-12   Larry Wall's Practical Extraction 
pn  perl-suid  (no description available)
ii  sysklogd [system-log-daemon]  1.5-1.1System Logging Daemon

Versions of packages sympa recommends:
ii  doc-base  0.8.9  utilities to manage online documen
ii  logrotate 3.7.1-3Log rotation utility



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]