mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 04:43:03 +01:00
Fixed CORE-4996: Need some SECURITY2.FDB --> SECURITY3.FDB upgrade feature
This commit is contained in:
parent
bd8a101090
commit
626b8cdfa3
75
src/misc/upgrade/v3.0/security_database.sql
Normal file
75
src/misc/upgrade/v3.0/security_database.sql
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* PROGRAM: Firebird users migration.
|
||||
* MODULE: security_database.sql
|
||||
* DESCRIPTION: Migrate users from fb2.x format into fb3
|
||||
* with random passwords.
|
||||
*
|
||||
* The contents of this file are subject to the Initial
|
||||
* Developer's Public License Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
* http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
|
||||
*
|
||||
* Software distributed under the License is distributed AS IS,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing rights
|
||||
* and limitations under the License.
|
||||
*
|
||||
* The Original Code was created by Alex Peshkov
|
||||
* for the Firebird Open Source RDBMS project.
|
||||
*
|
||||
* Copyright (c) 2016 Alex Peshkov <peshkoff at mail.ru>
|
||||
* and all contributors signed below.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
set term ^;
|
||||
|
||||
execute block returns(usr varchar(31), passwd varchar(36))
|
||||
as
|
||||
declare variable frst varchar(32);
|
||||
declare variable mddl varchar(32);
|
||||
declare variable lst varchar(32);
|
||||
declare variable attr varchar(4096);
|
||||
declare variable sql varchar(4096);
|
||||
declare variable uid int;
|
||||
declare variable gid int;
|
||||
|
||||
begin
|
||||
for select rdb$user_name, rdb$first_name, rdb$middle_name, rdb$last_name, rdb$uid, rdb$gid,
|
||||
uuid_to_char(gen_uuid()) from rdb$users
|
||||
where rdb$user_name is not null and upper(rdb$user_name) != 'SYSDBA'
|
||||
into :usr, :frst, :mddl, :lst, :uid, :gid, :passwd
|
||||
do begin
|
||||
-- basic fields
|
||||
sql = 'create or alter user ' || usr || ' password ''' || passwd || '''';
|
||||
if (frst is not null) then sql = sql || ' firstname ''' || frst || '''';
|
||||
if (mddl is not null) then sql = sql || ' middlename ''' || mddl || '''';
|
||||
if (lst is not null) then sql = sql || ' lastname ''' || lst || '''';
|
||||
sql = sql || ' active';
|
||||
|
||||
-- attributes
|
||||
attr = '';
|
||||
if (uid is not null) then attr = 'uid=''' || uid || '''';
|
||||
if (gid is not null) then begin
|
||||
if (char_length(attr) > 0) then attr = attr || ', ';
|
||||
attr = attr || 'gid=''' || gid || '''';
|
||||
end
|
||||
if (char_length(attr) > 0) then begin
|
||||
sql = sql || ' tags (' || attr || ')';
|
||||
end
|
||||
|
||||
-- create it
|
||||
execute statement sql;
|
||||
-- and show password to admin
|
||||
suspend;
|
||||
end
|
||||
end^
|
||||
|
||||
commit^
|
||||
|
||||
exit^
|
23
src/misc/upgrade/v3.0/security_database.txt
Normal file
23
src/misc/upgrade/v3.0/security_database.txt
Normal file
@ -0,0 +1,23 @@
|
||||
*** How to migrate existaing users from firebird 2.X to firebird 3? ***
|
||||
|
||||
Firebird 3 is using new method to validate users on the server.
|
||||
Direct upgrade of security database is therefore impossible.
|
||||
Described procedure will let you keep the list of firebird 2.X users
|
||||
and all related information (firstname, lastname, etc.) except
|
||||
password - new passwords will be generated randomly. Pay attention
|
||||
that SYSDBA user is not touched - i.e. it will remain as was after
|
||||
execution of upgrade procedure. In the commands below replace
|
||||
'masterkey' with actual SYSDBA password for appropriate (2.X/3.0)
|
||||
firebird server.
|
||||
|
||||
In firebird 2.5 backup security database:
|
||||
gbak -user sysdba -pas masterkey -b {host/path}security2.fdb security.fbk
|
||||
|
||||
In firebird 3 restore copy of 2.5 security database:
|
||||
gbak -user sysdba -pas masterkey -c security.fbk {host/path}security2.5
|
||||
And run users upgrade sql script:
|
||||
isql -user sysdba -pas masterkey -i security_database.sql {host/path}security2.5
|
||||
"security2.5" is a sample database name - you may use any other if you wish.
|
||||
|
||||
Script will create users with new random passwords and type them to you.
|
||||
It's your responsibility to notify users about new passwords.
|
Loading…
Reference in New Issue
Block a user