Bug 8162: allow packages to work on Ubuntu Precise
The newer version of MySQL in Ubuntu 12.04 installs a default
'localhost' user with no username. Due to the way that MySQL looks up
user details when you connect, if you connect from localhost and the
user was only created with a wildcard host (%), the anonymous localhost
user will be found instead. This means that your username is lost for
the connection, and you have no privileges.
This patch creates a second user with a hostname of 'localhost'. This
will not work if your database is on a remote server, but you probably
know what you are doing if that's the case. Patches to determine this
server's name relative to the MySQL server are welcome (or even ideas on
how to do it.)
It also fixes up a couple of other small things:
* make koha-remove stop zebra properly
* stop the warning that the password file is missing on create
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Works as promised.
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Allows 3.8.4 packages to work on Ubuntu 12.04
(cherry picked from commit 7d8078472d)
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
This commit is contained in:
parent
b376d97661
commit
89a3cbff92
|
|
@ -163,7 +163,7 @@ opacdomain="$OPACPREFIX$name$OPACSUFFIX$DOMAIN"
|
|||
intradomain="$INTRAPREFIX$name$INTRASUFFIX$DOMAIN"
|
||||
|
||||
|
||||
if [ `cat $PASSWDFILE | grep "^$name:"` ]
|
||||
if [ -f $PASSWDFILE ] && [ `cat $PASSWDFILE | grep "^$name:"` ]
|
||||
then
|
||||
passwdline=`cat $PASSWDFILE | grep "^$name:"`
|
||||
mysqluser=`echo $passwdline | cut -d ":" -f 2`
|
||||
|
|
@ -221,11 +221,15 @@ then
|
|||
|
||||
# Generate Zebra database password.
|
||||
zebrapwd="$(pwgen -s 12 1)"
|
||||
# Future enhancement: make this configurable for when your db is on
|
||||
# another server.
|
||||
mysql_hostname="localhost"
|
||||
# Set up MySQL database for this instance.
|
||||
if [ "$op" = create ]
|
||||
then
|
||||
mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof
|
||||
CREATE DATABASE \`$mysqldb\`;
|
||||
CREATE USER \`$mysqluser\`@'$mysql_hostname' IDENTIFIED BY '$mysqlpwd';
|
||||
CREATE USER \`$mysqluser\`@'%' IDENTIFIED BY '$mysqlpwd';
|
||||
GRANT ALL PRIVILEGES ON \`$mysqldb\`.* TO \`$mysqluser\`;
|
||||
FLUSH PRIVILEGES;
|
||||
|
|
@ -235,6 +239,7 @@ eof
|
|||
if [ "$op" = use ]
|
||||
then
|
||||
mysql --defaults-extra-file=/etc/mysql/koha-common.cnf --force <<eof
|
||||
CREATE USER \`$mysqluser\`@'$mysql_hostname' IDENTIFIED BY '$mysqlpwd';
|
||||
CREATE USER \`$mysqluser\`@'%' IDENTIFIED BY '$mysqlpwd';
|
||||
GRANT ALL PRIVILEGES ON \`$mysqldb\`.* TO \`$mysqluser\`;
|
||||
FLUSH PRIVILEGES;
|
||||
|
|
|
|||
|
|
@ -52,20 +52,22 @@ do
|
|||
fi
|
||||
|
||||
echo "Removing Koha instance $name"
|
||||
|
||||
mysql_hostname="localhost"
|
||||
if [ "$keepmysql" != "1" ]
|
||||
then
|
||||
# The grant creates the user in case it isn't, we don't want our loop to fail if it has already being deleted.
|
||||
mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof
|
||||
GRANT USAGE ON \`koha_$name\`.* TO \`koha_$name\`@\`%\`;
|
||||
DROP USER \`koha_$name\`;
|
||||
GRANT USAGE ON \`koha_$name\`.* TO \`koha_$name\`@\`$mysql_hostname\`;
|
||||
DROP USER \`koha_$name\`@\`%\`;
|
||||
DROP USER \`koha_$name\`@\`$mysql_hostname\`;
|
||||
DROP DATABASE IF EXISTS \`koha_$name\`;
|
||||
FLUSH PRIVILEGES;
|
||||
eof
|
||||
fi #`
|
||||
|
||||
# If the daemon is not running already, we don't want to fail this loop. So bin the result code if this fails.
|
||||
koha-stop-zebra $name | /bin/true
|
||||
koha-stop-zebra $name || /bin/true
|
||||
[ -f "/etc/apache2/sites-available/$name" ] && \
|
||||
rm "/etc/apache2/sites-available/$name"
|
||||
[ -f "/etc/koha/sites/$name/koha-conf.xml" ] && \
|
||||
|
|
@ -89,7 +91,7 @@ eof
|
|||
rm -r "/var/run/koha/$name"
|
||||
getent passwd "$name-koha" > /dev/null && deluser --quiet "$name-koha"
|
||||
# in case the site has already been disabled, we don't want to break the loop now.
|
||||
a2dissite "$name" | /bin/true
|
||||
a2dissite "$name" || /bin/true
|
||||
done
|
||||
|
||||
service apache2 restart
|
||||
|
|
|
|||
Loading…
Reference in New Issue