[debian-mysql] Bug#829491: mariadb-server-10.0: Removes lost+found directory if purged, /var/lib/mysql is a mountpoint with an ext4 filesystem, and user requests to remove all databases
Axel Beckert
abe at debian.org
Sun Jul 3 19:42:08 UTC 2016
Control: tag -1 + patch
Hi Otto,
Otto Kekäläinen wrote:
> Thanks for your report. The problem is that the purge section in the
> postrm script does a simple rm, which works OK if the directory is a
> normal directory, but not if it is a mountpoint. The postrm script
> does not have any kind of mountpoint detection or conditional
> handling for that scenario.
>
> Would you want to give it a try and produce a patch?
Yes:
diff --git a/debian/mariadb-server-10.0.postrm b/debian/mariadb-server-10.0.postrm
index 1f7034c..43b68a0 100644
--- a/debian/mariadb-server-10.0.postrm
+++ b/debian/mariadb-server-10.0.postrm
@@ -56,7 +56,17 @@ if [ "$1" = "purge" -a ! \( -x /usr/sbin/mysqld -o -L /usr/sbin/mysqld \) ]; the
# never remove the debian.cnf when the databases are still existing
# else we ran into big trouble on the next install!
rm -f /etc/mysql/debian.cnf
- rm -rf /var/lib/mysql
+ # Remove all contents from /var/lib/mysql except if it's a
+ # directory with file system data. See #829491 for details and
+ # #608938 for potential mysql-server leftovers which erroneously
+ # had been renamed.
+ find /var/lib/mysql -mindepth 1 \
+ -not -path '*/lost+found/*' -not -name 'lost+found' \
+ -not -path '*/lost at 002bfound/*' -not -name 'lost at 002bfound' \
+ -delete
+ # "|| true" still needed as rmdir still exits with non-zero if
+ # /var/lib/mysql is a mount point
+ rmdir --ignore-fail-on-non-empty /var/lib/mysql || true
rm -rf /var/run/mysqld # this directory is created by the init script, don't leave behind
userdel mysql || true
fi
I tried to
* not use the existence of lost+found as indicator for /var/lib/mysql
being a mount point.
* to also keep erroneously renamed lost+found directories as they
might continue to exist after a switch from MySQL to MariaDB.
> If you provide a patch, I am happy to review it and help with testing.
> As this is only some scripting, you don't need to spend time building
> MariaDB at all, just unpack the deb and hack on the postrm script.
As you suggested I haven't tested the whole patch as you suggested,
but at least each line separately -- with quickly generated dummy
files and directories only, though. (That way I noticed that
--ignore-fail-on-non-empty doesn't suffice for mount points.) Hope,
that suffices.
Regards, Axel
--
,''`. | Axel Beckert <abe at debian.org>, http://people.debian.org/~abe/
: :' : | Debian Developer, ftp.ch.debian.org Admin
`. `' | 4096R: 2517 B724 C5F6 CA99 5329 6E61 2FF9 CD59 6126 16B5
`- | 1024D: F067 EA27 26B9 C3FC 1486 202E C09E 1D89 9593 0EDE
More information about the pkg-mysql-maint
mailing list