Debian Bug report logs - #497107
uninstallation deletes MySQL database with no warning

version graph

Package: zoneminder; Maintainer for zoneminder is Dmitry Smirnov <onlyjob@debian.org>; Source for zoneminder is src:zoneminder (PTS, buildd, popcon).

Reported by: Jerome Haltom <wasabi@larvalstage.net>

Date: Fri, 29 Aug 2008 22:09:02 UTC

Severity: serious

Tags: patch

Found in version zoneminder/1.22.3-10

Fixed in version zoneminder/1.24.2-6

Done: Vagrant Cascadian <vagrant@debian.org>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Peter Howard <pjh@northern-ridge.com.au>:
Bug#497107; Package zoneminder. (full text, mbox, link).


Acknowledgement sent to Jerome Haltom <wasabi@larvalstage.net>:
New Bug report received and forwarded. Copy sent to Peter Howard <pjh@northern-ridge.com.au>. (full text, mbox, link).


Message #5 received at submit@bugs.debian.org (full text, mbox, reply):

From: Jerome Haltom <wasabi@larvalstage.net>
To: submit@bugs.debian.org
Subject: uninstallation deletes MySQL database with no warning
Date: Fri, 29 Aug 2008 17:06:36 -0500
Package: zoneminder
Version: 1.22.3-10

When uninstalling zoneminder, not purging, it removed the MySQL database
instantly. No questions asked. This sucked. I was just trying to
reinstall the package. This should be prompted for using debconf.





Information forwarded to debian-bugs-dist@lists.debian.org, Peter Howard <pjh@northern-ridge.com.au>:
Bug#497107; Package zoneminder. (Fri, 25 Jun 2010 20:03:03 GMT) (full text, mbox, link).


Acknowledgement sent to Vagrant Cascadian <vagrant+debianbugs@freegeek.org>:
Extra info received and forwarded to list. Copy sent to Peter Howard <pjh@northern-ridge.com.au>. (Fri, 25 Jun 2010 20:03:03 GMT) (full text, mbox, link).


Message #10 received at 497107@bugs.debian.org (full text, mbox, reply):

From: Vagrant Cascadian <vagrant+debianbugs@freegeek.org>
To: Debian Bug Tracking System <497107@bugs.debian.org>
Cc: control@bugs.debian.org
Subject: #497107: uninstallation deletes MySQL database with no warning
Date: Fri, 25 Jun 2010 12:59:29 -0700
tags 497107 patch
thanks

Package: zoneminder
Version: 1.24.2-4
Followup-For: Bug #497107

seems like the database should only be removed on purge. the following one-line
patch should do:

--- postrm.orig 2010-06-25 12:36:21.000000000 -0700
+++ postrm      2010-06-25 12:36:31.000000000 -0700
@@ -1,7 +1,7 @@
 #! /bin/sh
 # set -e # to be reinstated later

-if [ "$1" = "remove" ]; then
+if [ "$1" = "purge" ]; then
        echo 'delete from user where User="zmuser";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql
        echo 'delete from db where User="zmuser";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql
        mysqladmin --defaults-file=/etc/mysql/debian.cnf -f drop zm

live well,
  vagrant




Added tag(s) patch. Request was from Vagrant Cascadian <vagrant+debianbugs@freegeek.org> to control@bugs.debian.org. (Fri, 25 Jun 2010 20:03:08 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Peter Howard <pjh@northern-ridge.com.au>:
Bug#497107; Package zoneminder. (Tue, 31 Aug 2010 22:51:02 GMT) (full text, mbox, link).


Acknowledgement sent to Vagrant Cascadian <vagrant@freegeek.org>:
Extra info received and forwarded to list. Copy sent to Peter Howard <pjh@northern-ridge.com.au>. (Tue, 31 Aug 2010 22:51:02 GMT) (full text, mbox, link).


Message #17 received at 497107@bugs.debian.org (full text, mbox, reply):

From: Vagrant Cascadian <vagrant@freegeek.org>
To: Debian Bug Tracking System <497107@bugs.debian.org>
Subject: Re: deletes MySQL database with no warning
Date: Tue, 31 Aug 2010 15:50:09 -0700
severity 497107 serious
thanks

Package: zoneminder
Version: 1.24.2-5
Severity: normal

this problem causes data loss in unexpected situations (removing, not purging
package). it also may contribute to problems when re-installing the package.

raising the severity.

apparently the patch i provided earlier, while solving this problem, will
introduce other problems with re-install. seems like we'll need to fix this
properly... long-term perhaps by using dbconfig-common.

live well,
  vagrant




Severity set to 'serious' from 'normal' Request was from Vagrant Cascadian <vagrant@freegeek.org> to control@bugs.debian.org. (Tue, 31 Aug 2010 22:51:06 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Peter Howard <pjh@northern-ridge.com.au>:
Bug#497107; Package zoneminder. (Tue, 07 Sep 2010 04:00:03 GMT) (full text, mbox, link).


Acknowledgement sent to Vagrant Cascadian <vagrant@freegeek.org>:
Extra info received and forwarded to list. Copy sent to Peter Howard <pjh@northern-ridge.com.au>. (Tue, 07 Sep 2010 04:00:03 GMT) (full text, mbox, link).


Message #24 received at 497107@bugs.debian.org (full text, mbox, reply):

From: Vagrant Cascadian <vagrant@freegeek.org>
To: 497107@bugs.debian.org
Subject: uninstallation deletes MySQL database with no warning
Date: Mon, 6 Sep 2010 20:56:38 -0700
tags 497107 patch
thanks

i think this should fix the issue and not break anything else... i tested
install, remove, purge, upgrade from an older version...

changeset:   42:49836da188a6
tag:         tip
user:        Vagrant Cascadian <vagrant@freegeek.org>
date:        Mon Sep 06 19:58:58 2010 -0700
files:       debian/postinst debian/postrm
description:
Only remove database on purge, which requires only creating the database if it
doesn't already exist, and upgrading the database if the version is old enough.
hopefully, this fixes: http://bugs.debian.org/497107

changeset:   43:3f6ff8237340
tag:         tip
user:        Vagrant Cascadian <vagrant@freegeek.org>
date:        Mon Sep 06 20:51:43 2010 -0700
files:       debian/postinst
description:
only grant the user privledges if the upgraded is needed.


diff -r 28d4a228d6e7 debian/postinst
--- a/debian/postinst	Mon Sep 06 14:11:24 2010 -0700
+++ b/debian/postinst	Mon Sep 06 20:53:07 2010 -0700
@@ -5,7 +5,6 @@
 VERSION=1.24.2
 
 if [ "$1" = "configure" ]; then
-	if [ -z "$2" ]; then
 		#
 		# Get mysql started if it isn't
 		#
@@ -14,25 +13,28 @@
 		fi
 		if $(/etc/init.d/mysql status >/dev/null 2>&1); then
 			mysqladmin --defaults-file=/etc/mysql/debian.cnf -f reload
-			cat /usr/share/zoneminder/db/zm_create.sql | mysql --defaults-file=/etc/mysql/debian.cnf
-			echo 'grant lock tables, alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql
+			# test if database if already present...
+			if ! $(echo quit | mysql --defaults-file=/etc/mysql/debian.cnf zm > /dev/null) ; then
+			    cat /usr/share/zoneminder/db/zm_create.sql | mysql --defaults-file=/etc/mysql/debian.cnf
+			    echo 'grant lock tables, alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql
+			fi
+
+			# get old version from upgrade...
+			OLD_ZM_VERSION=${2%-*}
+			if [ -z "$OLD_ZM_VERSION" ]; then
+				# fall back to getting version from database itself, which may not necessarily be accurate?
+				OLD_ZM_VERSION=$(echo 'select Value from Config where Name = "ZM_DYN_CURR_VERSION";' | mysql --defaults-file=/etc/mysql/debian.cnf zm)
+			fi
+			if [ "$OLD_ZM_VERSION" != "$VERSION" ] ; then
+				echo 'grant lock tables, alter on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql
+				zmupdate.pl --version $OLD_ZM_VERSION 
+			fi
+
 		else
 			echo 'NOTE: mysql not running, please start mysql and run dpkg-reconfigure zoneminder when it is running.'
 		fi
 		chown www-data:www-data /var/log/zm
 		chown www-data:www-data /var/lib/zm/
 		chown www-data:www-data -R /var/cache/zoneminder
-    else
-		chown www-data:www-data /var/log/zm
-		if $(/etc/init.d/mysql status >/dev/null 2>&1); then
-	        echo 'grant lock tables, alter on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql
-            OLD_ZM_VERSION=${2%-*}
-            if [ "$OLD_ZM_VERSION" != "$VERSION" ] ; then
-                zmupdate.pl --version $OLD_ZM_VERSION 
-            fi
-		else
-			echo 'NOTE: mysql not running, please start mysql and run dpkg-reconfigure zoneminder when it is running.'
-		fi
-	fi
 fi
 #DEBHELPER#
diff -r 28d4a228d6e7 debian/postrm
--- a/debian/postrm	Mon Sep 06 14:11:24 2010 -0700
+++ b/debian/postrm	Mon Sep 06 20:53:07 2010 -0700
@@ -1,7 +1,7 @@
 #! /bin/sh
 # set -e # to be reinstated later
 
-if [ "$1" = "remove" ]; then
+if [ "$1" = "purge" ]; then
 	echo 'delete from user where User="zmuser";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql 
 	echo 'delete from db where User="zmuser";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql
 	mysqladmin --defaults-file=/etc/mysql/debian.cnf -f drop zm




Information forwarded to debian-bugs-dist@lists.debian.org, Peter Howard <pjh@northern-ridge.com.au>:
Bug#497107; Package zoneminder. (Tue, 07 Sep 2010 05:22:13 GMT) (full text, mbox, link).


Acknowledgement sent to Vagrant Cascadian <vagrant@freegeek.org>:
Extra info received and forwarded to list. Copy sent to Peter Howard <pjh@northern-ridge.com.au>. (Tue, 07 Sep 2010 05:22:13 GMT) (full text, mbox, link).


Message #29 received at 497107@bugs.debian.org (full text, mbox, reply):

From: Vagrant Cascadian <vagrant@freegeek.org>
To: 497107@bugs.debian.org
Subject: Re: Bug#497107: uninstallation deletes MySQL database with no warning
Date: Mon, 6 Sep 2010 22:08:00 -0700
On Mon, Sep 06, 2010 at 08:56:38PM -0700, Vagrant Cascadian wrote:
> i think this should fix the issue and not break anything else... i tested
> install, remove, purge, upgrade from an older version...

also tested reinstall...

apparently, i didn't *really* test install... updated patch after *really*
testing it:

diff -r 447830338800 debian/postinst
--- a/debian/postinst	Mon Sep 06 14:12:17 2010 -0700
+++ b/debian/postinst	Mon Sep 06 21:50:27 2010 -0700
@@ -5,7 +5,6 @@
 VERSION=1.24.2
 
 if [ "$1" = "configure" ]; then
-	if [ -z "$2" ]; then
 		#
 		# Get mysql started if it isn't
 		#
@@ -14,25 +13,30 @@
 		fi
 		if $(/etc/init.d/mysql status >/dev/null 2>&1); then
 			mysqladmin --defaults-file=/etc/mysql/debian.cnf -f reload
-			cat /usr/share/zoneminder/db/zm_create.sql | mysql --defaults-file=/etc/mysql/debian.cnf
-			echo 'grant lock tables, alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql
+			# test if database if already present...
+			if ! $(echo quit | mysql --defaults-file=/etc/mysql/debian.cnf zm > /dev/null) ; then
+			    cat /usr/share/zoneminder/db/zm_create.sql | mysql --defaults-file=/etc/mysql/debian.cnf
+			    echo 'grant lock tables, alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql
+			fi
+
+			# get old version from upgrade...
+			OLD_ZM_VERSION=${2%-*}
+			if [ -z "$OLD_ZM_VERSION" ]; then
+				# fall back to getting version from database itself, which may not necessarily be accurate?
+				OLD_ZM_VERSION=$(echo 'select Value from Config where Name = "ZM_DYN_CURR_VERSION";' | mysql --defaults-file=/etc/mysql/debian.cnf zm | egrep -v Value)
+			fi
+			if [ -n "$OLD_ZM_VERSION" ] && [ "$OLD_ZM_VERSION" != "$VERSION" ] ; then
+				echo 'grant lock tables, alter on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql
+				# stop zoneminder before performing database upgrade.
+				invoke-rc.d zoneminder stop || true
+				zmupdate.pl --version $OLD_ZM_VERSION 
+			fi
+
 		else
 			echo 'NOTE: mysql not running, please start mysql and run dpkg-reconfigure zoneminder when it is running.'
 		fi
 		chown www-data:www-data /var/log/zm
 		chown www-data:www-data /var/lib/zm/
 		chown www-data:www-data -R /var/cache/zoneminder
-    else
-		chown www-data:www-data /var/log/zm
-		if $(/etc/init.d/mysql status >/dev/null 2>&1); then
-	        echo 'grant lock tables, alter on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql
-            OLD_ZM_VERSION=${2%-*}
-            if [ "$OLD_ZM_VERSION" != "$VERSION" ] ; then
-                zmupdate.pl --version $OLD_ZM_VERSION 
-            fi
-		else
-			echo 'NOTE: mysql not running, please start mysql and run dpkg-reconfigure zoneminder when it is running.'
-		fi
-	fi
 fi
 #DEBHELPER#
diff -r 447830338800 debian/postrm
--- a/debian/postrm	Mon Sep 06 14:12:17 2010 -0700
+++ b/debian/postrm	Mon Sep 06 21:50:27 2010 -0700
@@ -1,7 +1,7 @@
 #! /bin/sh
 # set -e # to be reinstated later
 
-if [ "$1" = "remove" ]; then
+if [ "$1" = "purge" ]; then
 	echo 'delete from user where User="zmuser";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql 
 	echo 'delete from db where User="zmuser";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql
 	mysqladmin --defaults-file=/etc/mysql/debian.cnf -f drop zm


live well,
  vagrant




Reply sent to Vagrant Cascadian <vagrant@debian.org>:
You have taken responsibility. (Fri, 10 Sep 2010 18:06:03 GMT) (full text, mbox, link).


Notification sent to Jerome Haltom <wasabi@larvalstage.net>:
Bug acknowledged by developer. (Fri, 10 Sep 2010 18:06:03 GMT) (full text, mbox, link).


Message #34 received at 497107-close@bugs.debian.org (full text, mbox, reply):

From: Vagrant Cascadian <vagrant@debian.org>
To: 497107-close@bugs.debian.org
Subject: Bug#497107: fixed in zoneminder 1.24.2-6
Date: Fri, 10 Sep 2010 18:02:47 +0000
Source: zoneminder
Source-Version: 1.24.2-6

We believe that the bug you reported is fixed in the latest version of
zoneminder, which is due to be installed in the Debian FTP archive:

zoneminder_1.24.2-6.debian.tar.gz
  to main/z/zoneminder/zoneminder_1.24.2-6.debian.tar.gz
zoneminder_1.24.2-6.dsc
  to main/z/zoneminder/zoneminder_1.24.2-6.dsc
zoneminder_1.24.2-6_i386.deb
  to main/z/zoneminder/zoneminder_1.24.2-6_i386.deb



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 497107@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Vagrant Cascadian <vagrant@debian.org> (supplier of updated zoneminder package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Fri, 10 Sep 2010 10:06:06 -0700
Source: zoneminder
Binary: zoneminder
Architecture: source i386
Version: 1.24.2-6
Distribution: unstable
Urgency: low
Maintainer: Peter Howard <pjh@northern-ridge.com.au>
Changed-By: Vagrant Cascadian <vagrant@debian.org>
Description: 
 zoneminder - Linux video camera security and surveillance solution
Closes: 497107 595902
Changes: 
 zoneminder (1.24.2-6) unstable; urgency=low
 .
   * Only remove database on purge. This requires only creating the database if
     it doesn't already exist, and upgrading the database only if the database
     is an older version (closes: #497107).
 .
   * Do not prompt the user on database upgrades by using the --nointeractive
     flag when calling zmupdate.pl from postinst (closes: #595902).
Checksums-Sha1: 
 cabf604be19acb21caa47542e7e12edb3cd6c1d2 2127 zoneminder_1.24.2-6.dsc
 77c9982e7b893eadf7c7cc2b2350344e972d1c94 13783 zoneminder_1.24.2-6.debian.tar.gz
 3de96c37f1e66c62936f92c9ab2513e2f567353e 1460202 zoneminder_1.24.2-6_i386.deb
Checksums-Sha256: 
 9f7b8c4830a2475fbe3bddfc04df514db6f0d264a94e54804a76cd9a0dbc0af8 2127 zoneminder_1.24.2-6.dsc
 a27b3e449252e50be2d100329dacf7c2202989a2b1cb2fcd15477f0492457143 13783 zoneminder_1.24.2-6.debian.tar.gz
 4f729308ab0beafd7bceab592d89e5465ba0e10cd9f3aa5f316a2f15db5d77d5 1460202 zoneminder_1.24.2-6_i386.deb
Files: 
 a788080e8c741ef54872e8bd6fb0a05e 2127 net optional zoneminder_1.24.2-6.dsc
 bb474b70d43e21a478ecb887706fdd19 13783 net optional zoneminder_1.24.2-6.debian.tar.gz
 25225dfa0fdc6fe295156ecae9cb0b95 1460202 net optional zoneminder_1.24.2-6_i386.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQIcBAEBCAAGBQJMim8HAAoJEAMEK/Djv2x4KNEP/jubNpbWJ6fgIsVyO3ybXTSs
BdJxoRwUqIC9wF28JTpbF6BXsK0eUjOsLrNTmKkxS2M8Ymi8ww2nh06UdD93AFX6
YTv2cBBqHsmQMYDUgGne7FQ4wbOofv3ZICNBm27zEPAKbVwWSZzUb9EDBsIiKcXi
mt4SKi1x1oJZ+kdLQHfa6BMpK2PZH399a6kUtlLKUs5mo48HhT9+w+u998IW2ErF
DtklRNcEyCLLVZ8DGSdE5QCS6NnxYoS2M5XYjjEyzH+4mCblu1v/rlZpLEFUCRKL
bAXvaiKn7byNojDxCDngq1jGnhTGOBdFTw/1jOUR+PwFcaKLrApmA0ModlurTbM2
JcsldLx9IxvOWYozsNuLbyk010MB2Xg17l7Clxe24XMiXUnxR4hNF+KD0mYn+OQj
MPgcc4XwQgT9+YWVxiNTYssBiwLGoJntph8PnlFDtcv7cuH+m8bT8q8jw5mlAbrB
LCJ7Y6k5weVd/Y5AlsX4YPMLprZFRMSyY3YriJQnMCb943lLwvqesfEy+BIRaMZS
teA9ZiMzCGVEaYIt/qNhxvEoJ0nHG0y4CrtT4Xq7I8jgux57tNr9AFbtzsTNSRY2
q6kI19NcrDEbpbob1mUbl7XQELdEPmX2AsITELBKYWmJc/z9RPkwgLogXIx6rafl
cXKUCHhrT4b2LZ4Bo718
=lJWU
-----END PGP SIGNATURE-----





Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Mon, 11 Oct 2010 07:30:40 GMT) (full text, mbox, link).


Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Sun Jan 7 12:55:04 2018; Machine Name: beach

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.