8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-02-02 10:00:38 +01:00

Fixed an issue with missing auth source info when using trusted auth

This commit is contained in:
alexpeshkoff 2015-07-26 18:23:50 +00:00
parent 6608009f80
commit be3823bc92
3 changed files with 24 additions and 13 deletions

View File

@ -862,6 +862,7 @@ bool AuthReader::getInfo(Info& info)
erase(info.name);
erase(info.plugin);
erase(info.secDb);
erase(info.origPlug);
ClumpletReader internal(WideUnTagged, getBytes(), getClumpLength());
for (internal.rewind(); !internal.isEof(); internal.moveNext())
@ -880,6 +881,9 @@ bool AuthReader::getInfo(Info& info)
case AUTH_SECURE_DB:
set(info.secDb, internal);
break;
case AUTH_ORIG_PLUG:
set(info.origPlug, internal);
break;
default:
break;
}

View File

@ -190,11 +190,13 @@ public:
static const unsigned char AUTH_TYPE = 3; // it can be user/group/role/etc. - what plugin sets
static const unsigned char AUTH_SECURE_DB = 4; // sec. db in which context record was added
// missing when plugin is server-wide
static const unsigned char AUTH_ORIG_PLUG = 5; // original plugin that added a mapped record
// (human information reasons only)
typedef Array<UCHAR> AuthBlock;
struct Info
{
NoCaseString type, name, plugin, secDb;
NoCaseString type, name, plugin, secDb, origPlug;
unsigned found, current;
Info()

View File

@ -108,6 +108,7 @@ public:
add(to, AuthReader::AUTH_NAME, info.name);
add(to, AuthReader::AUTH_PLUGIN, info.plugin);
add(to, AuthReader::AUTH_SECURE_DB, info.secDb);
add(to, AuthReader::AUTH_ORIG_PLUG, info.origPlug);
if (to.getBufferLength())
{
@ -361,18 +362,19 @@ public:
for (Map* to = lookup(from); to; to = to->next(from))
{
MAP_DEBUG(fprintf(stderr, "Match!!\n"));
unsigned flagRole = to->toRole ? FLAG_ROLE : FLAG_USER;
if (info.found & flagRole)
unsigned flagRolUsr = to->toRole ? FLAG_ROLE : FLAG_USER;
if (info.found & flagRolUsr)
continue;
if (info.current & flagRole)
if (info.current & flagRolUsr)
(Arg::Gds(isc_map_multi) << originalUserName).raise();
info.current |= flagRole;
info.current |= flagRolUsr;
AuthReader::Info newInfo;
newInfo.type = to->toRole ? NM_ROLE : NM_USER;
newInfo.name = to->to == "*" ? originalUserName : to->to;
newInfo.secDb = this->name;
newInfo.origPlug = info.origPlug.hasData() ? info.origPlug : info.plugin;
newBlock.add(newInfo);
}
}
@ -509,15 +511,18 @@ public:
: found(FND_NOTHING)
{ }
void set(What find, NoCaseString& val, NoCaseString& m)
void set(What find, const AuthReader::Info& val)
{
if (find == found && value != val)
if (find == found && value != val.name)
Arg::Gds(isc_map_undefined).raise();
if (find > found)
{
found = find;
value = val;
method = m;
value = val.name;
if (val.plugin.hasData())
method = val.plugin;
else
method = "Mapped from " + val.origPlug;
}
}
@ -1079,8 +1084,8 @@ void mapUser(string& name, string& trusted_role, Firebird::string* auth_method,
MAP_DEBUG(fprintf(stderr, "Starting newblock scan\n"));
for (AuthReader scan(newBlock); scan.getInfo(info); scan.moveNext())
{
MAP_DEBUG(fprintf(stderr, "Newblock info: secDb=%s plugin=%s type=%s name=%s\n",
info.secDb.c_str(), info.plugin.c_str(), info.type.c_str(), info.name.c_str()));
MAP_DEBUG(fprintf(stderr, "Newblock info: secDb=%s plugin=%s type=%s name=%s origPlug=%s\n",
info.secDb.c_str(), info.plugin.c_str(), info.type.c_str(), info.name.c_str(), info.origPlug.c_str()));
Found::What recordWeight =
(db && info.secDb == db) ? Found::FND_DB :
@ -1090,9 +1095,9 @@ void mapUser(string& name, string& trusted_role, Firebird::string* auth_method,
if (recordWeight != Found::FND_NOTHING)
{
if (info.type == NM_USER)
fName.set(recordWeight, info.name, info.plugin);
fName.set(recordWeight, info);
else if (info.type == NM_ROLE)
fRole.set(recordWeight, info.name, info.plugin);
fRole.set(recordWeight, info);
}
}