From ef4930caf9edaece9645ab3fd509687fd181a15f Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Thu, 6 Oct 2022 17:25:26 -0400 Subject: [PATCH] 2022-10-06 Fred Gleason * Changed the type of the 'SWITCHER_NODES.PASSWORD` field in the database to 'text'. * Applied Base64 encoding to the 'SWITCHER_NODES.PASSWORD' field in the database. * Incremented the database version to 361. Signed-off-by: Fred Gleason --- ChangeLog | 6 ++++++ docs/tables/switcher_nodes.txt | 2 +- lib/dbversion.h | 2 +- rdadmin/edit_node.cpp | 9 +++++---- ripcd/livewire_lwrpaudio.cpp | 11 ++++++----- utils/rddbmgr/revertschema.cpp | 30 ++++++++++++++++++++++++++++++ utils/rddbmgr/schemamap.cpp | 2 +- utils/rddbmgr/updateschema.cpp | 32 ++++++++++++++++++++++++++++++++ 8 files changed, 82 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7bdc3564..1c6e35df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23470,3 +23470,9 @@ database to 'text'. * Applied Base64 encoding to the 'REPLICATORS.URL_PASSWORD' field in the database. +2022-10-06 Fred Gleason + * Changed the type of the 'SWITCHER_NODES.PASSWORD` field in the + database to 'text'. + * Applied Base64 encoding to the 'SWITCHER_NODES.PASSWORD' field in + the database. + * Incremented the database version to 361. diff --git a/docs/tables/switcher_nodes.txt b/docs/tables/switcher_nodes.txt index 3090b013..7034bc86 100644 --- a/docs/tables/switcher_nodes.txt +++ b/docs/tables/switcher_nodes.txt @@ -10,6 +10,6 @@ STATION_NAME varchar(64) MATRIX int(11) BASE_OUTPUT int(11) HOSTNAME varchar(64) -PASSWORD varchar(64) +PASSWORD text Base64 encoded TCP_PORT int(11) DESCRIPTION varchar(191) diff --git a/lib/dbversion.h b/lib/dbversion.h index cedd9214..e8af6a4f 100644 --- a/lib/dbversion.h +++ b/lib/dbversion.h @@ -24,7 +24,7 @@ /* * Current Database Version */ -#define RD_VERSION_DATABASE 360 +#define RD_VERSION_DATABASE 361 #endif // DBVERSION_H diff --git a/rdadmin/edit_node.cpp b/rdadmin/edit_node.cpp index 9403e84c..62292a73 100644 --- a/rdadmin/edit_node.cpp +++ b/rdadmin/edit_node.cpp @@ -2,7 +2,7 @@ // // Edit a Rivendell LiveWire Node // -// (C) Copyright 2002-2021 Fred Gleason +// (C) Copyright 2002-2022 Fred Gleason // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as @@ -149,7 +149,7 @@ EditNode::EditNode(int *id,RDMatrix *matrix,QWidget *parent) edit_hostname_edit->setText(q->value(0).toString()); edit_tcpport_spin->setValue(q->value(1).toInt()); edit_description_edit->setText(q->value(2).toString()); - edit_password=q->value(3).toString(); + edit_password=QByteArray::fromBase64(q->value(3).toString().toUtf8()); edit_output_spin->setValue(q->value(4).toInt()); } delete q; @@ -229,7 +229,7 @@ void EditNode::okData() QString::asprintf("`TCP_PORT`=%d,",edit_tcpport_spin->value())+ "`DESCRIPTION`='"+RDEscapeString(edit_description_edit->text())+"',"+ QString::asprintf("`BASE_OUTPUT`=%d,",edit_output_spin->value())+ - "`PASSWORD`='"+RDEscapeString(edit_password)+"'"; + "`PASSWORD`='"+RDEscapeString(edit_password.toUtf8().toBase64())+"'"; RDSqlQuery::apply(sql); } else { @@ -238,7 +238,8 @@ void EditNode::okData() QString::asprintf("`TCP_PORT`=%d,",edit_tcpport_spin->value())+ "`DESCRIPTION`='"+RDEscapeString(edit_description_edit->text())+"',"+ QString::asprintf("`BASE_OUTPUT`=%d,",edit_output_spin->value())+ - "`PASSWORD`='"+RDEscapeString(edit_password)+"' where "+ + "`PASSWORD`='"+RDEscapeString(edit_password.toUtf8().toBase64())+ + "' where "+ QString::asprintf("`ID`=%d",*edit_id); q=new RDSqlQuery(sql); delete q; diff --git a/ripcd/livewire_lwrpaudio.cpp b/ripcd/livewire_lwrpaudio.cpp index 78d14c7e..34d66808 100644 --- a/ripcd/livewire_lwrpaudio.cpp +++ b/ripcd/livewire_lwrpaudio.cpp @@ -2,7 +2,7 @@ // // A Rivendell LWRP audio switcher driver for LiveWire networks. // -// (C) Copyright 2002-2021 Fred Gleason +// (C) Copyright 2002-2022 Fred Gleason // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as @@ -64,10 +64,11 @@ LiveWireLwrpAudio::LiveWireLwrpAudio(RDMatrix *matrix,QObject *parent) connect(livewire_nodes.back(), SIGNAL(watchdogStateChanged(unsigned,const QString &)), this,SLOT(watchdogStateChangedData(unsigned,const QString &))); - livewire_nodes.back()->connectToHost(q->value(0).toString(), - q->value(1).toInt(), - q->value(2).toString(), - q->value(3).toUInt()); + livewire_nodes.back()-> + connectToHost(q->value(0).toString(), + q->value(1).toInt(), + QByteArray::fromBase64(q->value(2).toString().toUtf8()), + q->value(3).toUInt()); } delete q; } diff --git a/utils/rddbmgr/revertschema.cpp b/utils/rddbmgr/revertschema.cpp index 150b4f7d..2e33c13e 100644 --- a/utils/rddbmgr/revertschema.cpp +++ b/utils/rddbmgr/revertschema.cpp @@ -41,6 +41,36 @@ bool MainObject::RevertSchema(int cur_schema,int set_schema,QString *err_msg) // NEW SCHEMA REVERSIONS GO HERE... + // + // Revert 361 + // + if((cur_schema==361)&&(set_schemanext()) { + if(!q->value(1).isNull()) { + sql=QString("update `SWITCHER_NODES` set ")+ + "`PASSWORD`='"+ + RDEscapeString(QByteArray::fromBase64(q->value(1).toString().toUtf8()))+"' "+ + QString::asprintf("where `ID`=%d",q->value(0).toInt()); + if(!RDSqlQuery::apply(sql,err_msg)) { + return false; + } + } + } + delete q; + sql=QString("alter table `REPLICATORS` ")+ + "modify column `URL_PASSWORD` varchar(64)"; + if(!RDSqlQuery::apply(sql,err_msg)) { + return false; + } + + WriteSchemaVersion(--cur_schema); + } + // // Revert 360 // diff --git a/utils/rddbmgr/schemamap.cpp b/utils/rddbmgr/schemamap.cpp index 4bb347a6..da37bde4 100644 --- a/utils/rddbmgr/schemamap.cpp +++ b/utils/rddbmgr/schemamap.cpp @@ -160,7 +160,7 @@ void MainObject::InitializeSchemaMap() { global_version_map["3.4"]=317; global_version_map["3.5"]=346; global_version_map["3.6"]=347; - global_version_map["4.0"]=360; + global_version_map["4.0"]=361; } diff --git a/utils/rddbmgr/updateschema.cpp b/utils/rddbmgr/updateschema.cpp index fcb40727..cd471b34 100644 --- a/utils/rddbmgr/updateschema.cpp +++ b/utils/rddbmgr/updateschema.cpp @@ -11114,6 +11114,38 @@ bool MainObject::UpdateSchema(int cur_schema,int set_schema,QString *err_msg) WriteSchemaVersion(++cur_schema); } + if((cur_schema<361)&&(set_schema>cur_schema)) { + sql=QString("alter table `SWITCHER_NODES` ")+ + "modify column `PASSWORD` text"; + if(!RDSqlQuery::apply(sql,err_msg)) { + return false; + } + sql=QString("select ")+ + "`ID`,"+ // 00 + "`PASSWORD` "+ // 01 + "from `SWITCHER_NODES`"; + q=new RDSqlQuery(sql); + while(q->next()) { + if(q->value(1).toString().isEmpty()) { + sql=QString("update `SWITCHER_NODES` set ")+ + "`PASSWORD`=null "; + } + else { + sql=QString("update `SWITCHER_NODES` set ")+ + "`PASSWORD`='"+ + RDEscapeString(q->value(1).toString().toUtf8().toBase64())+"' "; + } + sql+=QString::asprintf("where `ID`=%d",q->value(0).toInt()); + + if(!RDSqlQuery::apply(sql,err_msg)) { + return false; + } + } + delete q; + + WriteSchemaVersion(++cur_schema); + } + // NEW SCHEMA UPDATES GO HERE...