[debian-mysql] Bug#497702: mysql-server-5.0: mysql_setpermissions does not quote user names
Ansgar Burchardt
ansgar at mathi.uni-heidelberg.de
Wed Sep 3 19:08:40 UTC 2008
Package: mysql-server-5.0
Version: 5.0.51a-12
Severity: normal
Hi,
mysql_setpermissions does not quote user name. This makes it impossible
to use with names such as `www-data'.
I changed some of these (see attached patch), but I think I missed some
others. Other values are also not always put inside quotes (I think I
did see several `$host' without quotes).
Regards,
Ansgar
-- System Information:
Debian Release: lenny/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.26-1-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages mysql-server-5.0 depends on:
ii adduser 3.110 add and remove users and groups
ii debconf [debconf-2.0] 1.5.22 Debian configuration management sy
ii libc6 2.7-13 GNU C Library: Shared libraries
ii libdbi-perl 1.605-1 Perl5 database interface by Tim Bu
ii libgcc1 1:4.3.1-9 GCC support library
ii libmysqlclient15off 5.0.51a-12 MySQL database client library
ii libncurses5 5.6+20080804-1 shared libraries for terminal hand
ii libreadline5 5.2-3 GNU readline and history libraries
ii libstdc++6 4.3.1-9 The GNU Standard C++ Library v3
ii libwrap0 7.6.q-16 Wietse Venema's TCP wrappers libra
ii lsb-base 3.2-19 Linux Standard Base 3.2 init scrip
ii mysql-client-5.0 5.0.51a-12 MySQL database client binaries
ii mysql-common 5.0.51a-12 MySQL database common files
ii passwd 1:4.1.1-3 change and administer password and
ii perl 5.10.0-13 Larry Wall's Practical Extraction
ii psmisc 22.6-1 Utilities that use the proc filesy
ii zlib1g 1:1.2.3.3.dfsg-12 compression library - runtime
Versions of packages mysql-server-5.0 recommends:
pn libhtml-template-perl <none> (no description available)
pn mailx <none> (no description available)
Versions of packages mysql-server-5.0 suggests:
pn tinyca <none> (no description available)
-- debconf information excluded
-------------- next part --------------
--- mysql_setpermission.orig 2008-09-03 19:25:21.000000000 +0200
+++ mysql_setpermission 2008-09-03 19:27:15.000000000 +0200
@@ -177,7 +177,7 @@
{
$pass = "PASSWORD(". $dbh->quote($pass) . ")";
}
- my $sth = $dbh->prepare("update user set Password=$pass where User = $user and Host = $host") || die $dbh->errstr;
+ my $sth = $dbh->prepare("update user set Password=$pass where User = \"$user\" and Host = \"$host\"") || die $dbh->errstr;
$sth->execute || die $dbh->errstr;
$sth->finish;
print "The password is set for user $user.\n\n";
@@ -245,13 +245,13 @@
foreach $host (@hosts) {
# user privileges: SELECT
if (($todo == 2) || ($todo == 3)) {
- $sth = $dbh->do("GRANT SELECT ON $db.* TO $user@\"$host\" IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
+ $sth = $dbh->do("GRANT SELECT ON $db.* TO \"$user\"@\"$host\" IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
} elsif ($todo == 4) {
# user privileges: SELECT,INSERT,UPDATE,DELETE
- $sth = $dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE ON $db.* TO $user@\"$host\" IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
+ $sth = $dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE ON $db.* TO \"$user\"@\"$host\" IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
} elsif ($todo == 5) {
# user privileges: SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES
- $sth = $dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES ON $db.* TO $user@\"$host\" IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
+ $sth = $dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES ON $db.* TO \"$user\"@\"$host\" IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
} elsif ($todo == 6) {
# all privileges
$sth = $dbh->do("GRANT ALL ON $db.* TO \'$user\'\@\'$host\' IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
@@ -520,7 +520,7 @@
print "We now need to know which host for $user we have to change.\n";
print "Choose from the following hosts: \n";
$user = $dbh->quote($user);
- my $sth = $dbh->prepare("select Host,User from user where User = $user") || die $dbh->errstr;
+ my $sth = $dbh->prepare("select Host,User from user where User = \"$user\"") || die $dbh->errstr;
$sth->execute || die $dbh->errstr;
while (my @r = $sth->fetchrow_array)
{
@@ -533,7 +533,7 @@
chomp($answer);
if ($answer)
{
- $sth = $dbh->prepare("select Host,User from user where Host = '$answer' and User = $user") || die $dbh->errstr;
+ $sth = $dbh->prepare("select Host,User from user where Host = '$answer' and User = '$user'") || die $dbh->errstr;
$sth->execute || die $dbh->errstr;
my @r = $sth->fetchrow_array;
if ($r[0])
More information about the pkg-mysql-maint
mailing list