Bugzilla – Attachment 11038 Details for
Bug 8162
packaging scripts create user incorrectly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8162: allow packages to work on Ubuntu Precise
Bug-8162-allow-packages-to-work-on-Ubuntu-Precise.patch (text/plain), 4.09 KB, created by
Robin Sheat
on 2012-07-20 10:37:32 UTC
(
hide
)
Description:
Bug 8162: allow packages to work on Ubuntu Precise
Filename:
MIME Type:
Creator:
Robin Sheat
Created:
2012-07-20 10:37:32 UTC
Size:
4.09 KB
patch
obsolete
>From 8d5f765e1a5378ee95fc60dfcd50b9bfec75b47f Mon Sep 17 00:00:00 2001 >From: Robin Sheat <robin@catalyst.net.nz> >Date: Fri, 20 Jul 2012 12:20:47 +0200 >Subject: [PATCH] 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 >--- > debian/scripts/koha-create | 7 ++++++- > debian/scripts/koha-remove | 10 ++++++---- > 2 files changed, 12 insertions(+), 5 deletions(-) > >diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create >index bb2b642..b0c418c 100755 >--- a/debian/scripts/koha-create >+++ b/debian/scripts/koha-create >@@ -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; >diff --git a/debian/scripts/koha-remove b/debian/scripts/koha-remove >index 8d7fc50..d68aebc 100755 >--- a/debian/scripts/koha-remove >+++ b/debian/scripts/koha-remove >@@ -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 >-- >1.7.9.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8162
:
11038
|
11180