From 047e2d05beaa600a792434211bbc6461e4defd7a Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Fri, 8 Jun 2018 18:13:49 +0000 Subject: [PATCH] 2018-06-08 Fred Gleason * Added a sanity check to rddbmgr(8) to prevent reverting from an unknown schema. * Added a sanity check to rddbmgr(8) to prevent inadvertent reversion to an implied schema. --- ChangeLog | 5 +++++ utils/rddbmgr/rddbmgr.cpp | 47 +++++++++++++++++++++++++-------------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1deaccc0..eabf3688 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17033,3 +17033,8 @@ * Removed the 'Backup Database' and 'Restore Database' buttons from rdadmin(1). * Removed the database creation and updater code from rdadmin(1). +2018-06-08 Fred Gleason + * Added a sanity check to rddbmgr(8) to prevent reverting from an + unknown schema. + * Added a sanity check to rddbmgr(8) to prevent inadvertent + reversion to an implied schema. diff --git a/utils/rddbmgr/rddbmgr.cpp b/utils/rddbmgr/rddbmgr.cpp index 7e7fa763..2d858400 100644 --- a/utils/rddbmgr/rddbmgr.cpp +++ b/utils/rddbmgr/rddbmgr.cpp @@ -222,23 +222,6 @@ MainObject::MainObject(QObject *parent) fprintf(stderr,"rddbmgr: exactly one command must be specified\n"); exit(1); } - if(set_schema>0) { - if((set_schema<242)||(set_schema>RD_VERSION_DATABASE)) { - fprintf(stderr,"rddbmgr: unsupported schema\n"); - exit(1); - } - } - else { - if(set_version.isEmpty()) { - set_schema=RD_VERSION_DATABASE; - } - else { - if((set_schema=GetVersionSchema(set_version))==0) { - fprintf(stderr,"invalid/unsupported Rivendell version\n"); - exit(1); - } - } - } if(db_yes&&db_no) { fprintf(stderr,"rddbmgr: '--yes' and '--no' are mutually exclusive\n"); exit(1); @@ -318,6 +301,36 @@ MainObject::MainObject(QObject *parent) RDConfig::createTablePostfix(db_mysql_engine,db_mysql_charset, db_mysql_collation); + // + // Resolve Target Schema + // + int schema=GetCurrentSchema(); + if(schema>RD_VERSION_DATABASE) { + fprintf(stderr,"rddbmgr: unknown current schema [%d]\n",schema); + exit(1); + } + if(set_schema>0) { + if((set_schema<242)||(set_schema>RD_VERSION_DATABASE)) { + fprintf(stderr,"rddbmgr: unsupported schema\n"); + exit(1); + } + } + else { + if(set_version.isEmpty()) { + if(set_schema