The patch file was not complete.

-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1
=== added file 'debian/conf/dbconfig.inc.php'
--- debian/conf/dbconfig.inc.php	1970-01-01 00:00:00 +0000
+++ debian/conf/dbconfig.inc.php	2009-05-21 10:12:35 +0000
@@ -0,0 +1,5 @@
+<?php 
+$_SESSION["SERVEUR_SQL"]="_DBC_DBSERVER_";
+$_SESSION["COMPTE_BASE"]="_DBC_DBUSER_";
+$_SESSION["PSWD_BASE"]="_DBC_DBPASS_";
+?>

=== modified file 'debian/conf/ocsreports.conf'
--- debian/conf/ocsreports.conf	2009-05-19 05:39:42 +0000
+++ debian/conf/ocsreports.conf	2009-05-21 09:51:41 +0000
@@ -11,21 +11,10 @@
        Options Indexes FollowSymLinks
        DirectoryIndex index.php
 
-       # Authorize for setup
+       # Disable install.php
        <Files install.php>
-            # For Apache 1.3 and 2.0
-            <IfModule mod_auth.c>
-                AuthType Basic
-                AuthName "OCS Reports Setup"
-                AuthUserFile /etc/ocsinventory/htpasswd.setup
-            </IfModule>
-            # For Apache 2.2
-            <IfModule mod_authn_file.c>
-                AuthType Basic
-                AuthName "OCS Reports Setup"
-                AuthUserFile /etc/ocsinventory/htpasswd.setup
-            </IfModule>
-            Require valid-user
+            Order deny,allow
+	    Deny from all
        </Files>
 
        <IfModule mod_php4.c>

=== modified file 'debian/ocsinventory-reports.config'
--- debian/ocsinventory-reports.config	2009-05-19 05:39:42 +0000
+++ debian/ocsinventory-reports.config	2009-05-22 08:54:08 +0000
@@ -1,16 +1,23 @@
-#!/bin/sh
+#!/bin/bash 
 
 set -e
 
-# Only on new install
-if [ "$2" = "" ]; then
-        . /usr/share/debconf/confmodule
-        db_version 2.0
-
-        if [ ! -f /etc/ocsinventory/htpasswd.setup ]; then
-                db_input low ocsinventory-reports/setup-username || true
-                db_input low ocsinventory-reports/setup-password || true
-        fi
-
-        db_go || true
+action=$1
+version=$2
+
+# Source debconf library.
+. /usr/share/debconf/confmodule
+db_version 2.0 || [ 0 -lt 30 ]
+
+if [ -f /usr/share/dbconfig-common/dpkg/frontend.config.mysql ]; then
+  . /usr/share/dbconfig-common/dpkg/frontend.config.mysql
+
+  # hints for dbconfig
+  dbc_dbname="ocsweb"
+  dbc_dbuser="ocs"
+
+  dbc_go ocsinventory-server $@
 fi
+
+db_go
+

=== modified file 'debian/ocsinventory-reports.install'
--- debian/ocsinventory-reports.install	2009-05-19 05:39:42 +0000
+++ debian/ocsinventory-reports.install	2009-05-21 10:02:51 +0000
@@ -1,3 +1,4 @@
 ocsreports                              usr/share/ocsinventory-server
 #ipdiscover-util/ipdiscover-util.pl      usr/share/ocsinventory-server/ocsreports
 debian/conf/ocsreports.conf             etc/ocsinventory
+debian/conf/dbconfig.inc.php		usr/share/ocsinventory-server/files

=== modified file 'debian/ocsinventory-reports.links'
--- debian/ocsinventory-reports.links	2009-05-19 05:39:42 +0000
+++ debian/ocsinventory-reports.links	2009-05-21 10:13:34 +0000
@@ -1,3 +1,3 @@
-var/lib/ocsinventory-server/config/dbconfig.inc.php    usr/share/ocsinventory-server/ocsreports/dbconfig.inc.php
-var/lib/ocsinventory-server/config/dbconfig.inc.php    etc/ocsinventory/dbconfig.inc.php
-var/lib/ocsinventory-server/ipd                        usr/share/ocsinventory-server/ocsreports/ipd
+etc/ocsinventory/dbconfig.inc.php    usr/share/ocsinventory-server/ocsreports/dbconfig.inc.php
+etc/ocsinventory/dbconfig.inc.php    var/lib/ocsinventory-server/config/dbconfig.inc.php
+var/lib/ocsinventory-server/ipd      usr/share/ocsinventory-server/ocsreports/ipd

=== modified file 'debian/ocsinventory-reports.postinst'
--- debian/ocsinventory-reports.postinst	2009-05-19 05:39:42 +0000
+++ debian/ocsinventory-reports.postinst	2009-05-22 08:54:08 +0000
@@ -12,34 +12,39 @@
 
   # only on a new install
   if [ "$2" = "" ]; then
+    pkgpath="/usr/share/ocsinventory-server"
     varpath="/var/lib/ocsinventory-server"
     confpath="/etc/ocsinventory"
     conffile="ocsreports.conf"
+    dbconffile="dbconfig.inc.php"
 
     # Allow php to write there
-    for dirname in config ipd download; do
+    for dirname in ipd download; do
       chown www-data:www-data $varpath/$dirname
       chmod g+w               $varpath/$dirname
     done
   
-    # Generate an htpasswd file for the web based setup
-    if [ ! -f $confpath/htpasswd.setup ]; then
-      touch $confpath/htpasswd.setup
-      chgrp www-data $confpath/htpasswd.setup
-      chmod 0640 $confpath/htpasswd.setup
-      db_get ocsinventory-reports/setup-username
-      setup_username=${RET:-admin}
-      db_get ocsinventory-reports/setup-password
-      if [ -n "$RET" ]; then
-        setup_password=`perl -le 'print crypt($ARGV[0], join("", map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..2)))' "$RET"`
-      else
-        setup_password="*"
-      fi
-      echo "$setup_username:$setup_password" > $confpath/htpasswd.setup
-      db_reset ocsinventory-reports/setup-username || true
-      db_reset ocsinventory-reports/setup-password || true
+    # use dbconfig to setup vars in apache config file
+    . /usr/share/dbconfig-common/dpkg/frontend.postinst.mysql
+    dbc_generate_include=template:$confpath/$dbconffile
+    dbc_generate_include_args="-U -o template_infile='$pkgpath/files/$dbconffile'"
+    dbc_generate_include_owner="root:www-data"
+    dbc_generate_include_perms="0640"
+
+    dbc_go ocsinventory-server $@
+
+    # if not using dbconfig, set default values to have a valid config file
+    db_get ocsinventory-server/dbconfig-install
+    use_dbconfig=${RET:-false}
+    if [ "x$use_dbconfig" != "xtrue" ]; then
+        sed -i -e 's/^\([^]]*\["SERVEUR_SQL"\]="\).*/\1localhost";/' \
+	    -e 's/^\([^]]*\["COMPTE_BASE"\]="\).*/\1ocs";/' \
+	    -e 's/^\([^]]*\["PSWD_BASE"\]="\).*/\1ocs";/' \
+        $confpath/$conffile
     fi
 
+    db_stop
+
     # link apache config files in apache's conf.d dir
     webservers="apache2"
     for webserver in $webservers; do

=== modified file 'debian/ocsinventory-reports.postrm'
--- debian/ocsinventory-reports.postrm	2009-05-19 05:39:42 +0000
+++ debian/ocsinventory-reports.postrm	2009-05-22 08:54:08 +0000
@@ -8,13 +8,19 @@
 varpath="/var/lib/ocsinventory-server"
 confpath="/etc/ocsinventory"
 conffile="ocsreports.conf"
+dbconffile="dbconfig.inc.php"
 
 . /usr/share/debconf/confmodule
 db_version 2.0 || [ $? -lt 30 ]
 
+if [ -f /usr/share/dbconfig-common/dpkg/frontend.postrm.mysql ]; then
+    . /usr/share/dbconfig-common/dpkg/frontend.postrm.mysql
+    dbc_go ocsinventory-server $@
+fi
+
 if [ "$1" = "purge" ]; then
 
-  for FILE in $confpath/$conffile $confpath/htpasswd.setup; do
+  for FILE in $confpath/$conffile $confpath/$dbconffile; do
       # Taken from the ucf example postrm
       for ext in '~' '%' .bak .dpkg-tmp .dpkg-new .dpkg-old .dpkg-dist .ucf-old;  do
           rm -f $FILE$ext
@@ -22,9 +28,6 @@
       rm -f $FILE
   done
 
-  # remove dbconfig.inc.php (created by install.php)
-  rm -f /var/lib/ocsinventory-server/config/dbconfig.inc.php || true
-
   rmdir --ignore-fail-on-non-empty /etc/ocsinventory || true
 fi
 

Reply via email to