mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 06:43:04 +01:00
Fixed mapping errors reported by Claudio & Treeve
This commit is contained in:
parent
6fcd20e73f
commit
82a3a54896
@ -4438,8 +4438,7 @@ processing_state SHOW_maps(bool extract, const SCHAR* map_name)
|
||||
}
|
||||
END_FOR
|
||||
ON_ERROR
|
||||
ISQL_errmsg(fbStatus);
|
||||
return ps_ERR;
|
||||
ISQL_errmsg(fbStatus); // report error but not return error on it
|
||||
END_ERROR;
|
||||
|
||||
return first ? OBJECT_NOT_FOUND : SKIP;
|
||||
|
@ -229,8 +229,8 @@ public:
|
||||
class Cache : public MapHash, public GlobalStorage
|
||||
{
|
||||
public:
|
||||
explicit Cache(const NoCaseString& db)
|
||||
: name(getPool(), db), dataFlag(false)
|
||||
Cache(const NoCaseString& aliasDb, const NoCaseString& db)
|
||||
: alias(getPool(), aliasDb), name(getPool(), db), dataFlag(false)
|
||||
{ }
|
||||
|
||||
void populate()
|
||||
@ -254,9 +254,16 @@ public:
|
||||
MAX_DPB_SIZE, isc_dpb_version1);
|
||||
embeddedSysdba.insertString(isc_dpb_user_name, SYSDBA_USER_NAME,
|
||||
strlen(SYSDBA_USER_NAME));
|
||||
att = prov->attachDatabase(&st, name.c_str(),
|
||||
embeddedSysdba.insertByte(isc_dpb_sec_attach, TRUE);
|
||||
att = prov->attachDatabase(&st, alias.c_str(),
|
||||
embeddedSysdba.getBufferLength(), embeddedSysdba.getBuffer());
|
||||
check("IProvider::attachDatabase", &st);
|
||||
if (!st.isSuccess())
|
||||
{
|
||||
// missing DB is not a reason to fail mapping at once
|
||||
if (st.get()[1] == isc_io_error)
|
||||
return;
|
||||
check("IProvider::attachDatabase", &st);
|
||||
}
|
||||
|
||||
ClumpletWriter readOnly(ClumpletWriter::Tpb, MAX_DPB_SIZE, isc_tpb_version1);
|
||||
readOnly.insertTag(isc_tpb_read);
|
||||
@ -278,7 +285,15 @@ public:
|
||||
" RDB$MAP_FROM, RDB$MAP_TO_TYPE, RDB$MAP_TO "
|
||||
"FROM RDB$MAP",
|
||||
3, NULL, NULL, mMap.getMetadata());
|
||||
check("IAttachment::openCursor", &st);
|
||||
// check("IAttachment::openCursor", &st);
|
||||
if (!st.isSuccess())
|
||||
{
|
||||
// errors when opening cursor - soomer of all table RDB$MAP is missing
|
||||
// in non-FB3 security DB
|
||||
tra->release();
|
||||
att->detach(&st);
|
||||
return;
|
||||
}
|
||||
|
||||
while (curs->fetchNext(&st, mMap.getBuffer()))
|
||||
{
|
||||
@ -343,6 +358,9 @@ public:
|
||||
const NoCaseString& originalUserName)
|
||||
{
|
||||
MAP_DEBUG(fprintf(stderr, "Key = %s\n", from.makeHashKey().c_str()));
|
||||
if (!dataFlag)
|
||||
return;
|
||||
|
||||
Map* to = lookup(from);
|
||||
if (! to)
|
||||
return;
|
||||
@ -454,7 +472,7 @@ public:
|
||||
|
||||
public:
|
||||
SyncObject syncObject;
|
||||
NoCaseString name;
|
||||
NoCaseString alias, name;
|
||||
bool dataFlag;
|
||||
};
|
||||
|
||||
@ -465,16 +483,20 @@ GlobalPtr<Mutex> treeMutex;
|
||||
|
||||
void setupIpc();
|
||||
|
||||
Cache* locate(const NoCaseString& target, bool flagAdd)
|
||||
Cache* locate(const NoCaseString& target)
|
||||
{
|
||||
fb_assert(treeMutex->locked());
|
||||
Cache* c;
|
||||
if (!tree().get(target, c))
|
||||
{
|
||||
if (!flagAdd)
|
||||
return NULL;
|
||||
return tree().get(target, c) ? c : NULL;
|
||||
}
|
||||
|
||||
c = new Cache(target);
|
||||
Cache* locate(const NoCaseString& alias, const NoCaseString& target)
|
||||
{
|
||||
fb_assert(treeMutex->locked());
|
||||
Cache* c = locate(target);
|
||||
if (!c)
|
||||
{
|
||||
c = new Cache(alias, target);
|
||||
*(tree().put(target)) = c;
|
||||
|
||||
setupIpc();
|
||||
@ -512,7 +534,7 @@ void resetMap(const char* securityDb)
|
||||
{
|
||||
MutexLockGuard g(treeMutex, FB_FUNCTION);
|
||||
|
||||
Cache* cache = locate(securityDb, false);
|
||||
Cache* cache = locate(securityDb);
|
||||
if (!cache)
|
||||
{
|
||||
MAP_DEBUG(fprintf(stderr, "Cache not found for %s\n", securityDb));
|
||||
@ -793,11 +815,11 @@ namespace Jrd {
|
||||
|
||||
void mapUser(string& name, string& trusted_role, Firebird::string* auth_method,
|
||||
AuthReader::AuthBlock* newAuthBlock, const AuthReader::AuthBlock& authBlock,
|
||||
const char* db, const char* securityDb)
|
||||
const char* alias, const char* db, const char* securityAlias)
|
||||
{
|
||||
AuthReader::Info info;
|
||||
|
||||
if (!securityDb)
|
||||
if (!securityAlias)
|
||||
{
|
||||
// We are in the error handler - perform minimum processing
|
||||
trusted_role = "";
|
||||
@ -817,8 +839,8 @@ void mapUser(string& name, string& trusted_role, Firebird::string* auth_method,
|
||||
|
||||
// expand security database name (db is expected to be expanded)
|
||||
PathName secExpanded;
|
||||
expandDatabaseName(securityDb, secExpanded, NULL);
|
||||
securityDb = secExpanded.c_str();
|
||||
expandDatabaseName(securityAlias, secExpanded, NULL);
|
||||
const char* securityDb = secExpanded.c_str();
|
||||
|
||||
// Create new writer
|
||||
AuthWriter newBlock;
|
||||
@ -846,8 +868,8 @@ void mapUser(string& name, string& trusted_role, Firebird::string* auth_method,
|
||||
|
||||
Cache* cDb = NULL;
|
||||
if (db)
|
||||
cDb = locate(db, true);
|
||||
Cache* cSec = locate(securityDb, true);
|
||||
cDb = locate(alias, db);
|
||||
Cache* cSec = locate(securityAlias, securityDb);
|
||||
|
||||
SyncObject dummySync;
|
||||
Sync sDb((!(flags & FLAG_DB)) ? &cDb->syncObject : &dummySync, FB_FUNCTION);
|
||||
|
@ -39,7 +39,7 @@ namespace Jrd {
|
||||
|
||||
void mapUser(Firebird::string& name, Firebird::string& trusted_role, Firebird::string* auth_method,
|
||||
Firebird::AuthReader::AuthBlock* newAuthBlock, const Firebird::AuthReader::AuthBlock& authBlock,
|
||||
const char* db, const char* securityDb);
|
||||
const char* alias, const char* db, const char* securityDb);
|
||||
void clearMap(const char* dbName);
|
||||
|
||||
class GlobalMappingScan: public VirtualTableScan
|
||||
|
@ -959,7 +959,7 @@ static void release_attachment(thread_db*, Jrd::Attachment*);
|
||||
static void rollback(thread_db*, jrd_tra*, const bool);
|
||||
static void strip_quotes(string&);
|
||||
static void purge_attachment(thread_db* tdbb, JAttachment* jAtt, unsigned flags = 0);
|
||||
static void getUserInfo(UserId&, const DatabaseOptions&, const char*, const RefPtr<Config>*);
|
||||
static void getUserInfo(UserId&, const DatabaseOptions&, const char*, const char*, const RefPtr<Config>*);
|
||||
|
||||
static THREAD_ENTRY_DECLARE shutdown_thread(THREAD_ENTRY_PARAM);
|
||||
|
||||
@ -971,7 +971,7 @@ TraceFailedConnection::TraceFailedConnection(const char* filename, const Databas
|
||||
m_filename(filename),
|
||||
m_options(options)
|
||||
{
|
||||
getUserInfo(m_id, *m_options, m_filename, NULL);
|
||||
getUserInfo(m_id, *m_options, m_filename, m_filename, NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -1288,7 +1288,7 @@ JAttachment* FB_CARG JProvider::attachDatabase(IStatus* user_status, const char*
|
||||
}
|
||||
|
||||
// Check for correct credentials supplied
|
||||
getUserInfo(userId, options, expanded_name.c_str(), &config);
|
||||
getUserInfo(userId, options, org_filename.c_str(), expanded_name.c_str(), &config);
|
||||
|
||||
#ifdef WIN_NT
|
||||
guardDbInit.enter(); // Required to correctly expand name of just created database
|
||||
@ -2394,7 +2394,7 @@ JAttachment* FB_CARG JProvider::createDatabase(IStatus* user_status, const char*
|
||||
}
|
||||
|
||||
// Check for correct credentials supplied
|
||||
getUserInfo(userId, options, NULL, &config);
|
||||
getUserInfo(userId, options, NULL, NULL, &config);
|
||||
|
||||
#ifdef WIN_NT
|
||||
guardDbInit.enter(); // Required to correctly expand name of just created database
|
||||
@ -7003,7 +7003,7 @@ static VdnResult verifyDatabaseName(const PathName& name, ISC_STATUS* status, bo
|
||||
|
||||
**/
|
||||
static void getUserInfo(UserId& user, const DatabaseOptions& options,
|
||||
const char* dbName, const RefPtr<Config>* config)
|
||||
const char* aliasName, const char* dbName, const RefPtr<Config>* config)
|
||||
{
|
||||
bool wheel = false;
|
||||
int id = -1, group = -1; // CVC: This var contained trash
|
||||
@ -7027,7 +7027,7 @@ static void getUserInfo(UserId& user, const DatabaseOptions& options,
|
||||
else if (options.dpb_auth_block.hasData())
|
||||
{
|
||||
mapUser(name, trusted_role, &auth_method, &user.usr_auth_block, options.dpb_auth_block,
|
||||
dbName, config ? (*config)->getSecurityDatabase() : NULL);
|
||||
aliasName, dbName, config ? (*config)->getSecurityDatabase() : NULL);
|
||||
ISC_systemToUtf8(name);
|
||||
ISC_systemToUtf8(trusted_role);
|
||||
}
|
||||
|
@ -774,7 +774,7 @@ Service::Service(const TEXT* service_name, USHORT spb_length, const UCHAR* spb_d
|
||||
|
||||
string trusted_role;
|
||||
mapUser(svc_username, trusted_role, NULL, &svc_auth_block, svc_auth_block,
|
||||
NULL, config->getSecurityDatabase());
|
||||
NULL, NULL, config->getSecurityDatabase());
|
||||
|
||||
// to be changed after refsoft special roles patch!!!
|
||||
trusted_role.upper();
|
||||
|
Loading…
Reference in New Issue
Block a user