Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore of encrypted backup of database with SQL dialect 1 fails [CORE6071] #6321

Closed
firebird-automations opened this issue May 30, 2019 · 10 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @AlexPeshkoff

gbak: ERROR:Dynamic SQL Error
gbak: ERROR: SQL error code = -817
gbak: ERROR: Metadata update statement is not allowed by the current database SQL dialect 1
gbak:Exiting before completion due to errors

Commits: f81ae05

====== Test Details ======

NB: bug was reproduced only when "gbak -keyholder <keyholder_name>" was used.

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

assignee: Alexander Peshkov [ alexpeshkoff ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

summary: Restore of dialect==1 database encrypted backup fails => Restore of encrypted backup of database with SQL dialect 1 fails

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 4.0 Beta 2 [ 10888 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Resolved [ 5 ]

QA Status: No test => Deferred

Test Details: Have question about implementation, sent it to Alex, 04.06.2019 16:48. Waiting for reply.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Resolved [ 5 ]

QA Status: Deferred => Done successfully

Test Details: Have question about implementation, sent it to Alex, 04.06.2019 16:48. Waiting for reply. => NB: bug was reproduced only when "gbak -keyholder <keyholder_name>" was used.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Closed [ 6 ]

@pavel-zotov
Copy link

Ticket must be RE-opened.
Please consider following .sh:

#!/bin/bash

FBHOME=/var/tmp/fb40tmp
BKNAME=/var/tmp/tmp4test.fbk
DBNAME=/var/tmp/tmp4test.fdb

export ISC_USER=SYSDBA
export ISC_PASSWORD=masterkey

# ::: NOTE :::
# firebird.conf must contain: KeyHolderPlugin = fbSampleKeyHolder

for f in libfbSampleDbCrypt.so libfbSampleKeyHolder.so
do
    cp --force --preserve $FBHOME/examples/prebuilt/plugins/${f} $FBHOME/plugins/
done

rm -f $DBNAME
crypt_plugin_name=\"fbSampleDbCrypt\"
echo "create database 'localhost:$DBNAME'; show version;" | $FBHOME/bin/isql -q
echo "alter database encrypt with $crypt_plugin_name key Red;shell sleep 2;show database;" | $FBHOME/bin/isql $DBNAME -q

$FBHOME/bin/gfix -sql_dialect 1 $DBNAME

$FBHOME/bin/gstat -h $DBNAME | grep -i dialect
$FBHOME/bin/gbak -b -KEYHOLDER fbSampleKeyHolder -crypt fbSampleDbCrypt $DBNAME $BKNAME
echo ----------- restore using backup ----------------
$FBHOME/bin/gbak -rep -KEYHOLDER fbSampleKeyHolder $BKNAME $DBNAME
echo ----------- restore using PIPE ------------------
$FBHOME/bin/gbak -b -KEYHOLDER fbSampleKeyHolder -crypt fbSampleDbCrypt $DBNAME stdout | $FBHOME/bin/gbak -rep -KEYHOLDER fbSampleKeyHolder stdin $DBNAME

If we comment out line "$FBHOME/bin/gfix -sql_dialect 1 $DBNAME" then this script works fine.
Otherwise it raises error:

  1. On FB 4.x:
gbak: ERROR:unsuccessful metadata update
gbak: ERROR:    ALTER DATABASE failed
gbak: ERROR:    Error loading plugin FBSAMPLEDBCRYPT
gbak: ERROR:    Module /var/tmp/fb40tmp/plugins/FBSAMPLEDBCRYPT does not contain plugin FBSAMPLEDBCRYPT type 9
gbak:Exiting before completion due to errors
  1. On FB 5.x:
gbak: ERROR:unsuccessful metadata update
gbak: ERROR:    ALTER DATABASE failed
gbak: ERROR:    Crypt plugin FBSAMPLEDBCRYPT failed to load
gbak:Exiting before completion due to errors

Checked on 4.0.2.2799, 5.0.0.590.
Problem exists only on Linux.

PS.

Steps to reproduce:

  1. firebird.conf must contain line
KeyHolderPlugin = fbSampleKeyHolder
  1. ensure that you have necessary rights to run .sh which will try to copy files from examples/prebuilt/ to $FB_HOME/plugins/

@hvlad
Copy link
Member

hvlad commented Jul 17, 2022

What exact command raises error ?
I see only ALTER DATABASE statement executed before sql dialect set to 1.

@pavel-zotov
Copy link

What exact command raises error ?

Both cases of 'gbak -rep ...' raise the same errors:

  1. $FBHOME/bin/gbak -rep -KEYHOLDER fbSampleKeyHolder $BKNAME $DBNAME
    and
  2. $FBHOME/bin/gbak -b -KEYHOLDER fbSampleKeyHolder -crypt fbSampleDbCrypt $DBNAME stdout | $FBHOME/bin/gbak -rep -KEYHOLDER fbSampleKeyHolder stdin $DBNAME

@pavel-zotov
Copy link

I see only ALTER DATABASE statement executed before sql dialect set to 1.

Yes, exactly: first we encrypt DB and after this we change its dialect:

echo "alter database encrypt with $crypt_plugin_name key Red;shell sleep 2;show database;" | $FBHOME/bin/isql $DBNAME -q

$FBHOME/bin/gfix -sql_dialect 1 $DBNAME

Of course, I could understand wrongly ticket subject, but - whats wrong here ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants