From 57aa913e6ff865ae8a324a31ddff5e13597db3ce Mon Sep 17 00:00:00 2001 From: Wayne Merricks Date: Tue, 24 May 2016 20:20:55 +0100 Subject: [PATCH 1/2] Fix rdairplay password and rdpanel segfault Removes the INSTANCE column from RDAIRPLAY and RDPANEL tables. This was removed in schema 219 but persists if you create a db from scratch. This makes rdairplay prompt for a password when exiting and seg faults rdpanel if not removed due to an attempt to insert a record into RDAIRPLAY/RDPANEL without setting a value for INSTANCE which is NOT NULL with no default. --- rdadmin/createdb.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/rdadmin/createdb.cpp b/rdadmin/createdb.cpp index 6eb6cb56..540418f8 100644 --- a/rdadmin/createdb.cpp +++ b/rdadmin/createdb.cpp @@ -1239,7 +1239,6 @@ bool CreateDb(QString name,QString pwd) sql="create table if not exists RDAIRPLAY (\ ID int not null primary key auto_increment,\ STATION char(40) not null,\ - INSTANCE int unsigned not null,\ CARD0 int default 0,\ PORT0 int default 0,\ START_RML0 char(255),\ @@ -1351,7 +1350,7 @@ bool CreateDb(QString name,QString pwd) LOG2_LOG_LINE int default -1,\ LOG2_NOW_CART int unsigned default 0,\ LOG2_NEXT_CART int unsigned default 0,\ - index STATION_IDX (STATION,INSTANCE))"; + index STATION_IDX (STATION))"; if(!RunQuery(sql)) { return false; } @@ -6048,7 +6047,6 @@ int UpdateDb(int ver) sql="create table if not exists RDPANEL (\ ID int not null primary key auto_increment,\ STATION char(40) not null,\ - INSTANCE int unsigned not null,\ CARD2 int default -1,\ PORT2 int default -1,\ START_RML2 char(255),\ @@ -6075,7 +6073,7 @@ int UpdateDb(int ver) FLASH_PANEL enum('N','Y') default 'N',\ PANEL_PAUSE_ENABLED enum('N','Y') default 'N',\ DEFAULT_SERVICE char(10),\ - index STATION_IDX (STATION,INSTANCE))"; + index STATION_IDX (STATION))"; q=new QSqlQuery(sql); delete q; From 5ff24a13741878add60270d44287bcaa1dab54e6 Mon Sep 17 00:00:00 2001 From: Wayne Merricks Date: Tue, 24 May 2016 20:24:31 +0100 Subject: [PATCH 2/2] Fix unable to create rduser in MySQL v5.7+ The original insert into user's method of creating rduser is not compatible with MySQL v5.7+. This moves to a standard create user statement. Also moved to grant statements rather than inserting directly into the db table to prevent possible changes to that causing issues in the future. --- rdadmin/opendb.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/rdadmin/opendb.cpp b/rdadmin/opendb.cpp index 13a7f932..70b3aab1 100644 --- a/rdadmin/opendb.cpp +++ b/rdadmin/opendb.cpp @@ -240,17 +240,13 @@ and we will try to get this straightened out."); if (check_remote_server(host)) { host=format_remote_host(host); } - sql=QString().sprintf("insert into user set Host=\"%s\",\ - User=\"%s\",Password=PASSWORD(\"%s\")", - (const char *)host, (const char *)login,(const char *)pwd); + sql=QString().sprintf("create user %s@'%s' identified by '%s'", + (const char *)login, (const char *)host, (const char *)pwd); q=new QSqlQuery(sql); delete q; - sql=QString(). - sprintf("insert into db set Host=\"%s\",Db=\"%s\",\ - User=\"%s\",Select_priv=\"Y\",Insert_priv=\"Y\",Update_priv=\"Y\",\ - Delete_priv=\"Y\",Create_priv=\"Y\",Drop_priv=\"Y\",\ - Index_priv=\"Y\",Alter_priv=\"Y\",Lock_tables_priv=\"Y\"", - (const char *)host, (const char *)dbname,(const char *)login); + sql=QString().sprintf("grant SELECT, INSERT, UPDATE, DELETE, CREATE, DROP,\ + INDEX, ALTER, LOCK TABLES on %s.* to %s@'%s'", + (const char *)dbname, (const char *)login, (const char *)host); q=new QSqlQuery(sql); delete q; q=new QSqlQuery("flush privileges");