Package: request-tracker3
Version: 3.0.12-7

When I invoke '/usr/sbin/rt-setup-database' to initialize or drop a MySQL 
database for RT and the name of this database is a string with hyphens (for 
instance "my-rt-database"), the script dies.

8<-------------------------
% sudo /usr/sbin/rt-setup-database --action init --dba rtuser 
--prompt-for-dba-password
In order to create a new database and grant RT access to that database,
this script needs to connect to your mysql instance on localhost as rtuser.
Please specify that user's database password below. If the user has no 
database
password, just press return.

Password: Now creating a database for RT.
Creating mysql database my-rt-database.
DBD::mysql::db do failed: You have an error in your SQL syntax.  Check the 
manual that corresponds to your MySQL server version for the right syntax to 
use near '-rt-database' at line 1 at /usr/sbin/rt-setup-database line 258, 
<STDIN> line 1.
You have an error in your SQL syntax.  Check the manual that corresponds to 
your MySQL server version for the right syntax to use near '-rt-database' at 
line 1 at /usr/sbin/rt-setup-database line 258, <STDIN> line 1.
8<-------------------------

The same behaviour for the drop action :

8<-------------------------
/usr/sbin/rt-setup-database --action drop --dba rtuser 
--prompt-for-dba-password
In order to create a new database and grant RT access to that database,
this script needs to connect to your mysql instance on localhost as rtuser.
Please specify that user's database password below. If the user has no 
database
password, just press return.

Password: 
About to drop mysql database my-rt-database on localhost.
WARNING: This will erase all data in my-rt-database.

Proceed [y/N]:y
Dropping mysql database my-rt-database.
DBD::mysql::db do failed: You have an error in your SQL syntax.  Check the 
manual that corresponds to your MySQL server version for the right syntax to 
use near '-rt-database' at line 1 at /usr/sbin/rt-setup-database line 233, 
<STDIN> line 2.
You have an error in your SQL syntax.  Check the manual that corresponds to 
your MySQL server version for the right syntax to use near '-rt-database' at 
line 1 at /usr/sbin/rt-setup-database line 233, <STDIN> line 2.
8<-------------------------

The name of the database to use is given in 
"/etc/request-tracker3/RT_SiteConfig.pm". It is then referred in  
"/usr/sbin/rt-setup-database" as "$RT::DatabaseName".

8<-------------------------
Set($DatabaseName , "my-rt-database");
8<-------------------------

After taking a look at "/usr/sbin/rt-setup-database", I found that the name of 
the database is not protected according to the protection rules of MySQL with 
"`".

I'm using Debian GNU/Linux 3.1 with :
request-tracker3  3.0.12-7
mysql-server      4.0.24-10
mysql-client      4.0.24-10
libmysqlclient12  4.0.24-10
libdbd-mysql-perl 2.9006-1

I suggest that the database name, "/usr/sbin/rt-setup-database", be protected.

Here is a patch made from the changes I wrote :
8<-------------------------
232,240d231
<     if ( $RT::DatabaseType eq 'Pg' or  $RT::DatabaseType eq 'Informix' ) {
<         $dbh->do("Drop DATABASE $RT::DatabaseName") or warn $DBI::errstr;
<     }
<     elsif ($RT::DatabaseType eq 'mysql' ) {
<         $dbh->do("Drop DATABASE `$RT::DatabaseName`") or warn $DBI::errstr;
<     }
<     else {
<         die "Unknown database type : $RT::DatabaseType" ;
<     }
241a233
>     $dbh->do("Drop DATABASE $RT::DatabaseName") or warn $DBI::errstr;
265,267d256
<     elsif ($RT::DatabaseType eq 'mysql' ) {
<         $dbh->do("CREATE DATABASE `$RT::DatabaseName`") or die $DBI::errstr;
<     }
269c258
<         die "Unknown database type : $RT::DatabaseType" ;
---
>         $dbh->do("CREATE DATABASE $RT::DatabaseName") or die $DBI::errstr;
8<-------------------------


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to