[Pkg-nagios-changes] [SCM] Debian packaging of icinga-web branch, master, updated. debian/1.7.1-1-8-gd0b47cf

Markus Frosch markus at lazyfrosch.de
Wed Jun 27 18:23:16 UTC 2012


The following commit has been merged in the master branch:
commit 728bbccd11bdc8c677998d95ac9eedf992008c28
Author: Markus Frosch <markus at lazyfrosch.de>
Date:   Wed Jun 27 19:24:01 2012 +0200

    now using dbconfig-common functions for updating the root password - better database support

diff --git a/debian/icinga-web.postinst b/debian/icinga-web.postinst
index e495492..890385b 100644
--- a/debian/icinga-web.postinst
+++ b/debian/icinga-web.postinst
@@ -126,22 +126,34 @@ setpassword() {
     export PW="$password"
     pwhash=$(php5 -r 'echo hash_hmac("sha256", getenv("PW"), getenv("SALT"));')
 
+    salt_e=${salt/\'/\\\'}
+    pwhash_e=${pwhash/\'/\\\'}
+    
     if [ "$dbc_dbtype" = "mysql" ]; then
         # query the database to update
-        salt_e=${salt/\'/\\\'}
-        pwhash_e=${pwhash/\'/\\\'}
+        query="UPDATE nsm_user SET user_password='""$pwhash_e""', user_salt = '""$salt_e""', user_modified = NOW() WHERE user_name = 'root';"
+        
+        # use app user and password for the command
+        dbc_dbadmin="$dbc_dbuser"
+        dbc_dbadmpass="$dbc_dbpass"
         
-        export MYSQL_PWD="$dbc_dbpass"
-        echo "UPDATE nsm_user SET user_password='""$pwhash_e""', user_salt = '""$salt_e""', user_modified = NOW() WHERE user_name = 'root';" \
-           | mysql --defaults-file=/dev/null -B -h "${dbc_dbhost:=localhost}" -u "$dbc_dbuser" "$dbc_dbname"
-        echo "root password updated in database!"
+        if dbc_mysql_exec_command "$query"; then
+            echo "root password updates successfully!"
+        else
+            echo "setting root password failed: $dbc_error" >&2
+        fi
     elif [ "$dbc_dbtype" = "pgsql" ]; then
         # query the database to update
-        salt_e=${salt/\'/\\\'}
-        pwhash_e=${pwhash/\'/\\\'}
+        query="UPDATE nsm_user SET user_password='""$pwhash_e""', user_salt = '""$salt_e""', user_modified = NOW() WHERE user_name = 'root';"
+        
+        # use the app user
+        _dbc_asuser=1
         
-        su -c "echo \"UPDATE nsm_user SET user_password='""$pwhash_e""', user_salt = '""$salt_e""', user_modified = NOW() WHERE user_name = 'root';\" | psql '$dbc_dbname'" postgres >/dev/null
-        echo "root password updated in database!"
+        if _dbc_pgsql_exec_command "$query"; then
+            echo "root password updates successfully!"
+        else
+            echo "setting root password failed: $dbc_error" >&2
+        fi
     else
         echo "db type '$dbc_dbtype' not implemented for setting root password!" >&2
     fi

-- 
Debian packaging of icinga-web



More information about the Pkg-nagios-changes mailing list