Index: installers/debian/dotlrn/postinst
===================================================================
RCS file: /usr/local/cvsroot/installers/debian/dotlrn/postinst,v
diff -u -r1.7 -r1.8
--- installers/debian/dotlrn/postinst	6 Aug 2008 06:08:54 -0000	1.7
+++ installers/debian/dotlrn/postinst	18 Sep 2008 18:29:35 -0000	1.8
@@ -39,6 +39,13 @@
 
     db_get dotlrn/dbu_password
     dbu_password="$RET"
+    
+    db_get dotlrn/pg_grant_access
+    if [ ! -z "$RET" ]; then
+        grant_access="$RET"
+    else
+        grant_access="false"
+    fi
 }
 
 db_not_installed() {
@@ -85,7 +92,7 @@
 	dbadmin=$dba_name
 	dbadmpass=$dba_password
 	dbuser=$dbu_name
-	dbpass=$dbu_password
+        dbpass=$dbu_password
 
 	. /usr/share/wwwconfig-common/pgsql-createuser.sh
 	if [ "$status" = "error" ]
@@ -100,8 +107,44 @@
 		echo $error
 	fi
 	
+	# Modify the pg_hba.conf to grant dotlrn user access to postgresql
+	# 1- Do we want to do that?
+	if [ "$grant_access" = true ]; then
+
+		# 2- Where is the pg_hba.conf from this database instance?
+		dbuser=$dba_name
+                dbpass=$dba_password
+		. /usr/share/wwwconfig-common/pgsql.get
+		pg_hba_file=$($pgsqlcmd -c "SELECT * from pg_settings where name='hba_file';" 2>/dev/null | grep hba | cut -d\| -f2)
+		pg_version=$(echo "$pg_hba_file" | cut -d\/ -f4)
+		if [ "$status" = "error" ]
+          		then
+                	err=1
+                	echo $error
+          	else
+			# 3- Modify the file
+			# Select connection method
+			if [ "A$dbu_password" != "A" ]; then 	
+				# No Blank Password
+				pg_conn_method="md5"
+			else
+				# Blank Password
+				pg_conn_method="trust"
+			fi
+			# Delete all lines between ## dotLRN ... ## and ########### from previous configurations.
+			# Insert connection line after the first local connection line (the postgres user connection line).
+			sed -i "/^## dotLRN package debconf changes (DO NOT EDIT BYHAND) ##/,/^#########################################################/d;1,/^local/{
+        /^local/a ## dotLRN package debconf changes (DO NOT EDIT BYHAND) ##\nlocal   dotlrn     $dbu_name                              $pg_conn_method\n#########################################################
+} " $pg_hba_file
+			
+			# 4-Reload postgresql conf
+			/etc/init.d/postgresql-"$pg_version" reload
+		fi
+	fi
+
 	# Modify config.tcl with debconf values
-	
+	dbuser=$dbu_name
+        dbpass=$dbu_password	
 	sed -i "/^    set db_host/,/^    set db_user/d;s/## Debconf changes (DO NOT EDIT BYHAND) ##/&\n    set db_host               $dbserver\n    set db_password           \"$dbpass\"\n    set db_port               \"5432\"\n    set db_user               $dbuser/" /etc/dotlrn/config.tcl
 
 	# Install plpgsql on database and enable compatibility options