mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 16:43:03 +01:00
Improvement CORE-2551 - Interpret DPB items as now the database name parameter is interpreted and change MON$ filenames fields from NONE to UNICODE_FSS.
This commit is contained in:
parent
d89088de1f
commit
e26c3083f8
@ -44,3 +44,8 @@ than v2.5.
|
||||
The OS codepage used for conversions is:
|
||||
- Windows: The Windows ANSI code page
|
||||
- Others: UTF-8
|
||||
|
||||
|
||||
Updated for 2.5 Beta 2: 2008-07-11
|
||||
|
||||
These rules are now valid for string DPB items too.
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "../jrd/tra.h"
|
||||
#include "../jrd/blb_proto.h"
|
||||
#include "../jrd/isc_proto.h"
|
||||
#include "../jrd/isc_f_proto.h"
|
||||
#include "../jrd/isc_s_proto.h"
|
||||
#include "../jrd/lck_proto.h"
|
||||
#include "../jrd/met_proto.h"
|
||||
@ -460,7 +461,10 @@ DatabaseSnapshot::DatabaseSnapshot(thread_db* tdbb, MemoryPool& pool)
|
||||
|
||||
const Attachment* const attachment = tdbb->getAttachment();
|
||||
fb_assert(attachment);
|
||||
const PathName& databaseName = dbb->dbb_database_name;
|
||||
|
||||
string databaseName(dbb->dbb_database_name.c_str());
|
||||
ISC_systemToUtf8(databaseName);
|
||||
|
||||
const string& userName = attachment->att_user->usr_user_name;
|
||||
const bool locksmith = attachment->locksmith();
|
||||
|
||||
@ -551,6 +555,7 @@ DatabaseSnapshot::DatabaseSnapshot(thread_db* tdbb, MemoryPool& pool)
|
||||
{
|
||||
if (fid == f_mon_att_user)
|
||||
{
|
||||
attachment_charset = ttype_none;
|
||||
att_allowed = locksmith || !userName.compare(source, length);
|
||||
}
|
||||
else if (fid == f_mon_att_charset_id)
|
||||
@ -787,8 +792,11 @@ void DatabaseSnapshot::putDatabase(const Database* database, Writer& writer, int
|
||||
|
||||
DumpRecord record(rel_mon_database);
|
||||
|
||||
PathName databaseName(*getDefaultMemoryPool(), database->dbb_database_name);
|
||||
ISC_systemToUtf8(databaseName);
|
||||
|
||||
// database name or alias (MUST BE ALWAYS THE FIRST ITEM PASSED!)
|
||||
record.storeString(f_mon_db_name, database->dbb_database_name);
|
||||
record.storeString(f_mon_db_name, databaseName);
|
||||
// page size
|
||||
record.storeInteger(f_mon_db_page_size, database->dbb_page_size);
|
||||
// major ODS version
|
||||
@ -895,6 +903,9 @@ bool DatabaseSnapshot::putAttachment(const Attachment* attachment, Writer& write
|
||||
}
|
||||
}
|
||||
|
||||
PathName attName(*getDefaultMemoryPool(), attachment->att_filename);
|
||||
ISC_systemToUtf8(attName);
|
||||
|
||||
// user (MUST BE ALWAYS THE FIRST ITEM PASSED!)
|
||||
record.storeString(f_mon_att_user, attachment->att_user->usr_user_name);
|
||||
// attachment id
|
||||
@ -904,7 +915,7 @@ bool DatabaseSnapshot::putAttachment(const Attachment* attachment, Writer& write
|
||||
// state
|
||||
record.storeInteger(f_mon_att_state, temp);
|
||||
// attachment name
|
||||
record.storeString(f_mon_att_name, attachment->att_filename);
|
||||
record.storeString(f_mon_att_name, attName);
|
||||
// role
|
||||
record.storeString(f_mon_att_role, attachment->att_user->usr_sql_role_name);
|
||||
// remote protocol
|
||||
|
@ -54,6 +54,7 @@
|
||||
FIELD(fld_class , nam_class , dtype_text , MAX_SQL_IDENTIFIER_LEN , dsc_text_type_metadata, 0 , NULL)
|
||||
FIELD(fld_acl , nam_acl , dtype_blob , BLOB_SIZE , isc_blob_acl , 0 , NULL)
|
||||
FIELD(fld_file_name , nam_file_name , dtype_varying , 255 , 0 , 0 , NULL)
|
||||
FIELD(fld_file_name2 , nam_file_name2 , dtype_varying , 255 , dsc_text_type_metadata, 0 , NULL)
|
||||
FIELD(fld_file_seq , nam_file_seq , dtype_short , sizeof(SSHORT) , 0 , 0 , NULL)
|
||||
FIELD(fld_file_start , nam_file_start , dtype_long , sizeof(SLONG) , 0 , 0 , NULL)
|
||||
FIELD(fld_file_length , nam_file_length , dtype_long , sizeof(SLONG) , 0 , 0 , NULL)
|
||||
|
@ -457,6 +457,23 @@ public:
|
||||
reinterpret_cast<char*>(&this->dpb_sys_user_name) - reinterpret_cast<char*>(this));
|
||||
}
|
||||
void get(const UCHAR*, USHORT, bool&);
|
||||
|
||||
private:
|
||||
void getPath(ClumpletReader& reader, PathName& s)
|
||||
{
|
||||
reader.getPath(s);
|
||||
if (!dpb_utf8_filename)
|
||||
ISC_systemToUtf8(s);
|
||||
ISC_unescape(s);
|
||||
}
|
||||
|
||||
void getString(ClumpletReader& reader, string& s)
|
||||
{
|
||||
reader.getString(s);
|
||||
if (!dpb_utf8_filename)
|
||||
ISC_systemToUtf8(s);
|
||||
ISC_unescape(s);
|
||||
}
|
||||
};
|
||||
|
||||
/// trace manager support
|
||||
@ -780,17 +797,22 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
|
||||
return ex.stuff_exception(user_status);
|
||||
}
|
||||
|
||||
PathName file_name = options.dpb_org_filename.hasData() ? options.dpb_org_filename : filename;
|
||||
PathName file_name;
|
||||
|
||||
if (options.dpb_utf8_filename)
|
||||
ISC_utf8ToSystem(file_name);
|
||||
if (options.dpb_org_filename.hasData())
|
||||
file_name = options.dpb_org_filename;
|
||||
else
|
||||
{
|
||||
ISC_systemToUtf8(file_name);
|
||||
file_name = filename;
|
||||
|
||||
if (!options.dpb_utf8_filename)
|
||||
ISC_systemToUtf8(file_name);
|
||||
|
||||
ISC_unescape(file_name);
|
||||
ISC_utf8ToSystem(file_name);
|
||||
}
|
||||
|
||||
ISC_utf8ToSystem(file_name);
|
||||
|
||||
PathName expanded_name;
|
||||
|
||||
// Resolve given alias name
|
||||
@ -1793,17 +1815,22 @@ ISC_STATUS GDS_CREATE_DATABASE(ISC_STATUS* user_status,
|
||||
return ex.stuff_exception(user_status);
|
||||
}
|
||||
|
||||
PathName file_name = options.dpb_org_filename.hasData() ? options.dpb_org_filename : filename;
|
||||
PathName file_name;
|
||||
|
||||
if (options.dpb_utf8_filename)
|
||||
ISC_utf8ToSystem(file_name);
|
||||
if (options.dpb_org_filename.hasData())
|
||||
file_name = options.dpb_org_filename;
|
||||
else
|
||||
{
|
||||
ISC_systemToUtf8(file_name);
|
||||
file_name = filename;
|
||||
|
||||
if (!options.dpb_utf8_filename)
|
||||
ISC_systemToUtf8(file_name);
|
||||
|
||||
ISC_unescape(file_name);
|
||||
ISC_utf8ToSystem(file_name);
|
||||
}
|
||||
|
||||
ISC_utf8ToSystem(file_name);
|
||||
|
||||
PathName expanded_name;
|
||||
|
||||
// Resolve given alias name
|
||||
@ -4379,12 +4406,14 @@ void DatabaseOptions::get(const UCHAR* dpb, USHORT dpb_length, bool& invalid_cli
|
||||
Arg::Gds(isc_wrodpbver));
|
||||
}
|
||||
|
||||
for (; !(rdr.isEof()); rdr.moveNext())
|
||||
dpb_utf8_filename = rdr.find(isc_dpb_utf8_filename);
|
||||
|
||||
for (rdr.rewind(); !(rdr.isEof()); rdr.moveNext())
|
||||
{
|
||||
switch (rdr.getClumpTag())
|
||||
{
|
||||
case isc_dpb_working_directory:
|
||||
rdr.getPath(dpb_working_directory);
|
||||
getPath(rdr, dpb_working_directory);
|
||||
break;
|
||||
|
||||
case isc_dpb_set_page_buffers:
|
||||
@ -4479,22 +4508,22 @@ void DatabaseOptions::get(const UCHAR* dpb, USHORT dpb_length, bool& invalid_cli
|
||||
break;
|
||||
|
||||
case isc_dpb_sys_user_name:
|
||||
rdr.getString(dpb_sys_user_name);
|
||||
getString(rdr, dpb_sys_user_name);
|
||||
break;
|
||||
|
||||
case isc_dpb_sql_role_name:
|
||||
if (! dpb_trusted_role)
|
||||
{
|
||||
rdr.getString(dpb_role_name);
|
||||
getString(rdr, dpb_role_name);
|
||||
}
|
||||
break;
|
||||
|
||||
case isc_dpb_user_name:
|
||||
rdr.getString(dpb_user_name);
|
||||
getString(rdr, dpb_user_name);
|
||||
break;
|
||||
|
||||
case isc_dpb_password:
|
||||
rdr.getString(dpb_password);
|
||||
getString(rdr, dpb_password);
|
||||
break;
|
||||
|
||||
case isc_dpb_password_enc:
|
||||
@ -4502,12 +4531,12 @@ void DatabaseOptions::get(const UCHAR* dpb, USHORT dpb_length, bool& invalid_cli
|
||||
break;
|
||||
|
||||
case isc_dpb_trusted_auth:
|
||||
rdr.getString(dpb_trusted_login);
|
||||
getString(rdr, dpb_trusted_login);
|
||||
break;
|
||||
|
||||
case isc_dpb_trusted_role:
|
||||
dpb_trusted_role = true;
|
||||
rdr.getString(dpb_role_name);
|
||||
getString(rdr, dpb_role_name);
|
||||
break;
|
||||
|
||||
case isc_dpb_encrypt_key:
|
||||
@ -4646,7 +4675,7 @@ void DatabaseOptions::get(const UCHAR* dpb, USHORT dpb_length, bool& invalid_cli
|
||||
break;
|
||||
|
||||
case isc_dpb_set_db_charset:
|
||||
rdr.getString(dpb_set_db_charset);
|
||||
getString(rdr, dpb_set_db_charset);
|
||||
break;
|
||||
|
||||
case isc_dpb_address_path:
|
||||
@ -4684,7 +4713,7 @@ void DatabaseOptions::get(const UCHAR* dpb, USHORT dpb_length, bool& invalid_cli
|
||||
break;
|
||||
|
||||
case isc_dpb_process_name:
|
||||
rdr.getPath(dpb_remote_process);
|
||||
getPath(rdr, dpb_remote_process);
|
||||
break;
|
||||
|
||||
case isc_dpb_no_db_triggers:
|
||||
@ -4692,11 +4721,7 @@ void DatabaseOptions::get(const UCHAR* dpb, USHORT dpb_length, bool& invalid_cli
|
||||
break;
|
||||
|
||||
case isc_dpb_org_filename:
|
||||
rdr.getPath(dpb_org_filename);
|
||||
break;
|
||||
|
||||
case isc_dpb_utf8_filename:
|
||||
dpb_utf8_filename = true;
|
||||
getPath(rdr, dpb_org_filename);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -4705,9 +4730,7 @@ void DatabaseOptions::get(const UCHAR* dpb, USHORT dpb_length, bool& invalid_cli
|
||||
}
|
||||
|
||||
if (! rdr.isEof())
|
||||
{
|
||||
ERR_post(Arg::Gds(isc_bad_dpb_form));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5972,7 +5995,10 @@ static void getUserInfo(UserId& user, const DatabaseOptions& options)
|
||||
options.dpb_network_protocol.isEmpty() && // This 2 checks ensure that we are not remote server
|
||||
options.dpb_remote_address.isEmpty()) // process, i.e. can use unix OS auth.
|
||||
{
|
||||
wheel = ISC_get_user(&name, &id, &group, options.dpb_sys_user_name.nullStr());
|
||||
string s(options.dpb_sys_user_name);
|
||||
ISC_utf8ToSystem(s);
|
||||
wheel = ISC_get_user(&name, &id, &group, s.nullStr());
|
||||
ISC_systemToUtf8(name);
|
||||
}
|
||||
|
||||
if (options.dpb_user_name.hasData() || (id == -1))
|
||||
|
@ -95,6 +95,7 @@ NAME("RDB$FILES", nam_files)
|
||||
NAME("RDB$FILE_FLAGS", nam_file_flags)
|
||||
NAME("RDB$FILE_LENGTH", nam_file_length)
|
||||
NAME("RDB$FILE_NAME", nam_file_name)
|
||||
NAME("RDB$FILE_NAME2", nam_file_name2)
|
||||
NAME("RDB$FILE_PARTITIONS", nam_file_partitions)
|
||||
NAME("RDB$FILE_P_OFFSET", nam_file_p_offset)
|
||||
NAME("RDB$FILE_SEQUENCE", nam_file_seq)
|
||||
|
@ -348,7 +348,7 @@ END_RELATION
|
||||
// Virtual tables
|
||||
|
||||
RELATION(nam_mon_database, rel_mon_database, ODS_11_1, rel_virtual)
|
||||
FIELD(f_mon_db_name, nam_mon_db_name, fld_file_name, 0, 0, 0, 0)
|
||||
FIELD(f_mon_db_name, nam_mon_db_name, fld_file_name2, 0, 0, 0, 0)
|
||||
FIELD(f_mon_db_page_size, nam_mon_page_size, fld_page_size, 0, 0, 0, 0)
|
||||
FIELD(f_mon_db_ods_major, nam_mon_ods_major, fld_ods_number, 0, 0, 0, 0)
|
||||
FIELD(f_mon_db_ods_minor, nam_mon_ods_minor, fld_ods_number, 0, 0, 0, 0)
|
||||
@ -372,7 +372,7 @@ RELATION(nam_mon_attachments, rel_mon_attachments, ODS_11_1, rel_virtual)
|
||||
FIELD(f_mon_att_id, nam_mon_att_id, fld_att_id, 0, 0, 0, 0)
|
||||
FIELD(f_mon_att_server_pid, nam_mon_server_pid, fld_pid, 0, 0, 0, 0)
|
||||
FIELD(f_mon_att_state, nam_mon_state, fld_state, 0, 0, 0, 0)
|
||||
FIELD(f_mon_att_name, nam_mon_att_name, fld_file_name, 0, 0, 0, 0)
|
||||
FIELD(f_mon_att_name, nam_mon_att_name, fld_file_name2, 0, 0, 0, 0)
|
||||
FIELD(f_mon_att_user, nam_mon_user, fld_user, 0, 0, 0, 0)
|
||||
FIELD(f_mon_att_role, nam_mon_role, fld_user, 0, 0, 0, 0)
|
||||
FIELD(f_mon_att_remote_proto, nam_mon_remote_proto, fld_remote_proto, 0, 0, 0, 0)
|
||||
@ -381,7 +381,7 @@ RELATION(nam_mon_attachments, rel_mon_attachments, ODS_11_1, rel_virtual)
|
||||
FIELD(f_mon_att_charset_id, nam_mon_charset_id, fld_charset_id, 0, 0, 0, 0)
|
||||
FIELD(f_mon_att_timestamp, nam_mon_timestamp, fld_time, 0, 0, 0, 0)
|
||||
FIELD(f_mon_att_gc, nam_mon_gc, fld_flag, 0, 0, 0, 0)
|
||||
FIELD(f_mon_att_remote_process, nam_mon_remote_process, fld_file_name, 0, 0, 0, 0)
|
||||
FIELD(f_mon_att_remote_process, nam_mon_remote_process, fld_file_name2, 0, 0, 0, 0)
|
||||
FIELD(f_mon_att_stat_id, nam_mon_stat_id, fld_stat_id, 0, 0, 0, 0)
|
||||
END_RELATION
|
||||
RELATION(nam_mon_transactions, rel_mon_transactions, ODS_11_1, rel_virtual)
|
||||
|
@ -1302,8 +1302,35 @@ ISC_STATUS API_ROUTINE GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
|
||||
if (utfFilename)
|
||||
ISC_utf8ToSystem(org_filename);
|
||||
else
|
||||
{
|
||||
newDpb.insertTag(isc_dpb_utf8_filename);
|
||||
|
||||
for (newDpb.rewind(); !newDpb.isEof(); newDpb.moveNext())
|
||||
{
|
||||
UCHAR tag = newDpb.getClumpTag();
|
||||
switch (tag)
|
||||
{
|
||||
case isc_dpb_sys_user_name:
|
||||
case isc_dpb_user_name:
|
||||
case isc_dpb_password:
|
||||
case isc_dpb_sql_role_name:
|
||||
case isc_dpb_trusted_auth:
|
||||
case isc_dpb_trusted_role:
|
||||
case isc_dpb_working_directory:
|
||||
case isc_dpb_set_db_charset:
|
||||
case isc_dpb_process_name:
|
||||
{
|
||||
string s;
|
||||
newDpb.getString(s);
|
||||
ISC_systemToUtf8(s);
|
||||
newDpb.deleteClumplet();
|
||||
newDpb.insertString(tag, s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setLogin(newDpb);
|
||||
org_filename.rtrim();
|
||||
|
||||
|
@ -4578,8 +4578,17 @@ static void add_other_params(rem_port* port, ClumpletWriter& dpb, const Paramete
|
||||
dpb.deleteWithTag(par.process_id);
|
||||
dpb.insertInt(par.process_id, getpid());
|
||||
|
||||
if (!dpb.find(par.process_name)) {
|
||||
dpb.insertPath(par.process_name, fb_utils::get_process_name());
|
||||
if (!dpb.find(par.process_name))
|
||||
{
|
||||
PathName path = fb_utils::get_process_name();
|
||||
|
||||
ISC_systemToUtf8(path);
|
||||
ISC_escape(path);
|
||||
|
||||
if (!dpb.find(isc_dpb_utf8_filename))
|
||||
ISC_utf8ToSystem(path);
|
||||
|
||||
dpb.insertPath(par.process_name, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4609,7 +4618,14 @@ static void add_working_directory(ClumpletWriter& dpb, const PathName& node_name
|
||||
if (node_name == "localhost")
|
||||
{
|
||||
fb_utils::getCwd(cwd);
|
||||
|
||||
ISC_systemToUtf8(cwd);
|
||||
ISC_escape(cwd);
|
||||
|
||||
if (!dpb.find(isc_dpb_utf8_filename))
|
||||
ISC_utf8ToSystem(cwd);
|
||||
}
|
||||
|
||||
dpb.insertPath(isc_dpb_working_directory, cwd);
|
||||
}
|
||||
|
||||
@ -5564,6 +5580,11 @@ static bool get_new_dpb(ClumpletWriter& dpb, string& user_string, const Paramete
|
||||
string password;
|
||||
dpb.getString(password);
|
||||
dpb.deleteClumplet();
|
||||
|
||||
if (!dpb.find(isc_dpb_utf8_filename))
|
||||
ISC_systemToUtf8(password);
|
||||
ISC_unescape(password);
|
||||
|
||||
TEXT pwt[MAX_PASSWORD_LENGTH + 2];
|
||||
ENC_crypt(pwt, sizeof pwt, password.c_str(), PASSWORD_SALT);
|
||||
password = pwt + 2;
|
||||
@ -5748,18 +5769,35 @@ static bool init(ISC_STATUS* user_status,
|
||||
|
||||
if (port->port_protocol < PROTOCOL_VERSION12)
|
||||
{
|
||||
// This is FB < 2.5. Lets remove that not recognized DPB and convert the filename
|
||||
// to the OS codepage.
|
||||
// This is FB < 2.5. Lets remove that not recognized DPB and convert the UTF8
|
||||
// strings to the OS codepage.
|
||||
dpb.deleteWithTag(isc_dpb_utf8_filename);
|
||||
ISC_utf8ToSystem(file_name);
|
||||
|
||||
if (dpb.find(isc_dpb_org_filename))
|
||||
for (dpb.rewind(); !dpb.isEof(); dpb.moveNext())
|
||||
{
|
||||
PathName orgFilename;
|
||||
dpb.getPath(orgFilename);
|
||||
ISC_utf8ToSystem(orgFilename);
|
||||
dpb.deleteClumplet();
|
||||
dpb.insertPath(isc_dpb_org_filename, orgFilename);
|
||||
UCHAR tag = dpb.getClumpTag();
|
||||
switch (tag)
|
||||
{
|
||||
case isc_dpb_org_filename:
|
||||
case isc_dpb_sys_user_name:
|
||||
case isc_dpb_user_name:
|
||||
case isc_dpb_password:
|
||||
case isc_dpb_sql_role_name:
|
||||
case isc_dpb_trusted_auth:
|
||||
case isc_dpb_trusted_role:
|
||||
case isc_dpb_working_directory:
|
||||
case isc_dpb_set_db_charset:
|
||||
case isc_dpb_process_name:
|
||||
{
|
||||
string s;
|
||||
dpb.getString(s);
|
||||
ISC_utf8ToSystem(s);
|
||||
dpb.deleteClumplet();
|
||||
dpb.insertString(tag, s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user