mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-02-02 10:00:38 +01:00
Misc.
This commit is contained in:
parent
d1f9bce0d6
commit
359f74e73a
@ -359,7 +359,7 @@ $(NBACKUP): $(NBACKUP_Objects) $(COMMON_LIB)
|
||||
# plugins - some of them are required to build examples, use separate entry for them
|
||||
#
|
||||
|
||||
.PHONY: udr legacy_user_management trace auth_debug
|
||||
.PHONY: udr legacy_user_management trace auth_debug
|
||||
makePluginName= $(PLUGINS)/$(LIB_PREFIX)$(1).$(SHRLIB_EXT)
|
||||
UDR_PLUGIN = $(call makePluginName,udr_engine)
|
||||
LEGACY_USER_MANAGER = $(call makePluginName,Legacy_UserManager)
|
||||
|
@ -247,7 +247,7 @@ Format:
|
||||
CHAR_TO_UUID( <string> )
|
||||
|
||||
Notes:
|
||||
If you have not used this function before, its usage is discouraged. CHAR_TO_UUID2 superseds it.
|
||||
If you have not used this function before, its usage is discouraged. CHAR_TO_UUID2 supersedes it.
|
||||
|
||||
Example:
|
||||
select char_to_uuid('93519227-8D50-4E47-81AA-8F6678C096A1') from rdb$database;
|
||||
@ -268,7 +268,7 @@ Format:
|
||||
CHAR_TO_UUID2( <string> )
|
||||
|
||||
Notes:
|
||||
This function superseds CHAR_TO_UUID. The difference between them is that CHAR_TO_UUID does a
|
||||
This function supersedes CHAR_TO_UUID. The difference between them is that CHAR_TO_UUID does a
|
||||
byte-by-byte conversion of the ASCII string to the OCTETS one, while CHAR_TO_UUID2 converts
|
||||
a RFC-4122 compliant ASCII UUID to a compliant OCTETS string.
|
||||
|
||||
@ -874,7 +874,7 @@ Format:
|
||||
UUID_TO_CHAR( <string> )
|
||||
|
||||
Notes:
|
||||
If you have not used this function before, its usage is discouraged. UUID_TO_CHAR2 superseds it.
|
||||
If you have not used this function before, its usage is discouraged. UUID_TO_CHAR2 supersedes it.
|
||||
|
||||
Example:
|
||||
select uuid_to_char(gen_uuid()) from rdb$database;
|
||||
@ -894,7 +894,7 @@ Format:
|
||||
UUID_TO_CHAR2( <string> )
|
||||
|
||||
Notes:
|
||||
This function superseds UUID_TO_CHAR. The difference between them is that UUID_TO_CHAR does a
|
||||
This function supersedes UUID_TO_CHAR. The difference between them is that UUID_TO_CHAR does a
|
||||
byte-by-byte conversion of the OCTETS string to the ASCII one, while UUID_TO_CHAR2 converts
|
||||
a RFC-4122 compliant OCTETS UUID to a compliant ASCII string.
|
||||
|
||||
|
@ -34,18 +34,17 @@ using namespace Firebird;
|
||||
|
||||
namespace Auth {
|
||||
|
||||
class SrpClient : public Firebird::StdPlugin<IClient, FB_AUTH_CLIENT_VERSION>
|
||||
class SrpClient : public StdPlugin<IClient, FB_AUTH_CLIENT_VERSION>
|
||||
{
|
||||
public:
|
||||
explicit SrpClient(Firebird::IPluginConfig*)
|
||||
explicit SrpClient(IPluginConfig*)
|
||||
: client(NULL), data(getPool()),
|
||||
sessionKey(getPool())
|
||||
{ }
|
||||
|
||||
// IClient implementation
|
||||
Result FB_CARG authenticate(Firebird::IStatus*, IClientBlock* cb);
|
||||
Result FB_CARG getSessionKey(Firebird::IStatus* status,
|
||||
const unsigned char** key, unsigned int* keyLen);
|
||||
Result FB_CARG authenticate(IStatus*, IClientBlock* cb);
|
||||
Result FB_CARG getSessionKey(IStatus* status, const unsigned char** key, unsigned int* keyLen);
|
||||
int FB_CARG release();
|
||||
|
||||
private:
|
||||
@ -54,14 +53,14 @@ private:
|
||||
UCharBuffer sessionKey;
|
||||
};
|
||||
|
||||
Result SrpClient::authenticate(Firebird::IStatus* status, IClientBlock* cb)
|
||||
Result SrpClient::authenticate(IStatus* status, IClientBlock* cb)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sessionKey.hasData())
|
||||
{
|
||||
// Why are we called when auth is completed?
|
||||
(Firebird::Arg::Gds(isc_random) << "Auth sync failure - SRP's authenticate called more times than supported").raise();
|
||||
(Arg::Gds(isc_random) << "Auth sync failure - SRP's authenticate called more times than supported").raise();
|
||||
}
|
||||
|
||||
if (!client)
|
||||
@ -91,7 +90,7 @@ Result SrpClient::authenticate(Firebird::IStatus* status, IClientBlock* cb)
|
||||
|
||||
string salt, key;
|
||||
unsigned charSize = *saltAndKey++;
|
||||
charSize += ((unsigned)*saltAndKey++) << 8;
|
||||
charSize += ((unsigned) *saltAndKey++) << 8;
|
||||
if (charSize > RemotePassword::SRP_SALT_SIZE * 2)
|
||||
{
|
||||
string msg;
|
||||
@ -104,7 +103,7 @@ Result SrpClient::authenticate(Firebird::IStatus* status, IClientBlock* cb)
|
||||
length -= (charSize + 2);
|
||||
|
||||
charSize = *saltAndKey++;
|
||||
charSize += ((unsigned)*saltAndKey++) << 8;
|
||||
charSize += ((unsigned) *saltAndKey++) << 8;
|
||||
if (charSize + 2 != length)
|
||||
{
|
||||
string msg;
|
||||
@ -125,7 +124,7 @@ Result SrpClient::authenticate(Firebird::IStatus* status, IClientBlock* cb)
|
||||
|
||||
cb->putData(data.length(), data.c_str());
|
||||
}
|
||||
catch(const Exception& ex)
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
ex.stuffException(status);
|
||||
return AUTH_FAILED;
|
||||
@ -135,8 +134,7 @@ Result SrpClient::authenticate(Firebird::IStatus* status, IClientBlock* cb)
|
||||
}
|
||||
|
||||
|
||||
Result SrpClient::getSessionKey(Firebird::IStatus*,
|
||||
const unsigned char** key, unsigned int* keyLen)
|
||||
Result SrpClient::getSessionKey(IStatus*, const unsigned char** key, unsigned int* keyLen)
|
||||
{
|
||||
if (!sessionKey.hasData())
|
||||
{
|
||||
@ -161,13 +159,12 @@ int SrpClient::release()
|
||||
|
||||
namespace
|
||||
{
|
||||
Firebird::SimpleFactory<SrpClient> factory;
|
||||
SimpleFactory<SrpClient> factory;
|
||||
}
|
||||
|
||||
void registerSrpClient(Firebird::IPluginManager* iPlugin)
|
||||
void registerSrpClient(IPluginManager* iPlugin)
|
||||
{
|
||||
iPlugin->registerPluginFactory(PluginType::AuthClient, RemotePassword::plugName, &factory);
|
||||
}
|
||||
|
||||
} // namespace Auth
|
||||
|
||||
|
@ -115,23 +115,25 @@ public:
|
||||
|
||||
void prepareDataStructures()
|
||||
{
|
||||
const char* script[] = {
|
||||
"CREATE TABLE PLG$SRP (PLG$USER_NAME SEC$USER_NAME NOT NULL PRIMARY KEY, "
|
||||
"PLG$VERIFIER VARCHAR(128) CHARACTER SET OCTETS NOT NULL, "
|
||||
"PLG$SALT VARCHAR(32) CHARACTER SET OCTETS NOT NULL, "
|
||||
"PLG$COMMENT RDB$DESCRIPTION, PLG$FIRST SEC$NAME_PART, "
|
||||
"PLG$MIDDLE SEC$NAME_PART, PLG$LAST SEC$NAME_PART)" ,
|
||||
|
||||
"CREATE VIEW PLG$SRP_VIEW AS "
|
||||
"SELECT PLG$USER_NAME, PLG$VERIFIER, PLG$SALT, PLG$COMMENT, PLG$FIRST, PLG$MIDDLE, PLG$LAST "
|
||||
"FROM PLG$SRP WHERE CURRENT_USER = 'SYSDBA' OR CURRENT_ROLE = 'RDB$ADMIN' OR CURRENT_USER = PLG$SRP.PLG$USER_NAME",
|
||||
|
||||
"GRANT ALL ON PLG$SRP to VIEW PLG$SRP_VIEW",
|
||||
|
||||
"GRANT SELECT ON PLG$SRP_VIEW to PUBLIC",
|
||||
|
||||
"GRANT UPDATE(PLG$VERIFIER, PLG$SALT, PLG$FIRST, PLG$MIDDLE, PLG$LAST) ON PLG$SRP_VIEW TO PUBLIC",
|
||||
NULL };
|
||||
const char* script[] = {
|
||||
"CREATE TABLE PLG$SRP (PLG$USER_NAME SEC$USER_NAME NOT NULL PRIMARY KEY, "
|
||||
"PLG$VERIFIER VARCHAR(128) CHARACTER SET OCTETS NOT NULL, "
|
||||
"PLG$SALT VARCHAR(32) CHARACTER SET OCTETS NOT NULL, "
|
||||
"PLG$COMMENT RDB$DESCRIPTION, PLG$FIRST SEC$NAME_PART, "
|
||||
"PLG$MIDDLE SEC$NAME_PART, PLG$LAST SEC$NAME_PART)"
|
||||
,
|
||||
"CREATE VIEW PLG$SRP_VIEW AS "
|
||||
"SELECT PLG$USER_NAME, PLG$VERIFIER, PLG$SALT, PLG$COMMENT, PLG$FIRST, PLG$MIDDLE, PLG$LAST "
|
||||
"FROM PLG$SRP WHERE CURRENT_USER = 'SYSDBA' OR CURRENT_ROLE = 'RDB$ADMIN' OR CURRENT_USER = PLG$SRP.PLG$USER_NAME"
|
||||
,
|
||||
"GRANT ALL ON PLG$SRP to VIEW PLG$SRP_VIEW"
|
||||
,
|
||||
"GRANT SELECT ON PLG$SRP_VIEW to PUBLIC"
|
||||
,
|
||||
"GRANT UPDATE(PLG$VERIFIER, PLG$SALT, PLG$FIRST, PLG$MIDDLE, PLG$LAST) ON PLG$SRP_VIEW TO PUBLIC"
|
||||
,
|
||||
NULL
|
||||
};
|
||||
|
||||
Firebird::LocalStatus s;
|
||||
Firebird::RefPtr<Firebird::ITransaction> ddlTran(att->startTransaction(&s, 0, NULL));
|
||||
@ -506,7 +508,7 @@ public:
|
||||
Firebird::status_exception::raise(status->get());
|
||||
}
|
||||
}
|
||||
catch(const Firebird::Exception&)
|
||||
catch (const Firebird::Exception&)
|
||||
{
|
||||
printf("Exception\n");
|
||||
if (stmt.hasData())
|
||||
@ -518,8 +520,8 @@ public:
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
@ -527,7 +529,7 @@ public:
|
||||
ex.stuffException(status);
|
||||
return -1;
|
||||
|
||||
/*
|
||||
/*
|
||||
switch(user->operation())
|
||||
{
|
||||
case ADD_OPER:
|
||||
@ -550,7 +552,7 @@ public:
|
||||
default:
|
||||
return GsecMsg17;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -62,8 +62,7 @@ public:
|
||||
|
||||
// IServer implementation
|
||||
Result FB_CARG authenticate(IStatus* status, IServerBlock* sBlock, IWriter* writerInterface);
|
||||
Result FB_CARG getSessionKey(Firebird::IStatus* status,
|
||||
const unsigned char** key, unsigned int* keyLen);
|
||||
Result FB_CARG getSessionKey(IStatus* status, const unsigned char** key, unsigned int* keyLen);
|
||||
int FB_CARG release();
|
||||
|
||||
private:
|
||||
@ -75,7 +74,7 @@ private:
|
||||
string salt;
|
||||
UCharBuffer sessionKey;
|
||||
RefPtr<IFirebirdConf> config;
|
||||
const char *secDbName;
|
||||
const char* secDbName;
|
||||
};
|
||||
|
||||
Result SrpServer::authenticate(IStatus* status, IServerBlock* sb, IWriter* writerInterface)
|
||||
@ -158,25 +157,29 @@ Result SrpServer::authenticate(IStatus* status, IServerBlock* sb, IWriter* write
|
||||
|
||||
const char* sql = "SELECT PLG$VERIFIER, PLG$SALT FROM PLG$SRP WHERE PLG$USER_NAME = ?";
|
||||
stmt->prepare(status, tra, 0, sql, 3, 0);
|
||||
|
||||
if (!status->isSuccess())
|
||||
{
|
||||
const ISC_STATUS* v = status->get();
|
||||
|
||||
while (v[0] == isc_arg_gds)
|
||||
{
|
||||
if (v[1] == isc_dsql_relation_err)
|
||||
{
|
||||
Arg::Gds(isc_missing_data_structures).raise();
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
v += 2;
|
||||
} while (v[0] != isc_arg_warning && v[0] != isc_arg_gds && v[0] != isc_arg_end);
|
||||
}
|
||||
|
||||
status_exception::raise(status->get());
|
||||
}
|
||||
|
||||
Message par;
|
||||
Field <VarChar<SZ_LOGIN> > login(par);
|
||||
Field<VarChar<SZ_LOGIN> > login(par);
|
||||
login() = account.c_str();
|
||||
login.null() = 0;
|
||||
HANDSHAKE_DEBUG(fprintf(stderr, "Srv SRP1: Ready to run statement with login '%s'\n", account.c_str()));
|
||||
@ -283,8 +286,7 @@ Result SrpServer::authenticate(IStatus* status, IServerBlock* sb, IWriter* write
|
||||
return AUTH_FAILED;
|
||||
}
|
||||
|
||||
Result SrpServer::getSessionKey(Firebird::IStatus*,
|
||||
const unsigned char** key, unsigned int* keyLen)
|
||||
Result SrpServer::getSessionKey(IStatus*, const unsigned char** key, unsigned int* keyLen)
|
||||
{
|
||||
if (!sessionKey.hasData())
|
||||
{
|
||||
@ -318,4 +320,3 @@ void registerSrpServer(IPluginManager* iPlugin)
|
||||
}
|
||||
|
||||
} // namespace Auth
|
||||
|
||||
|
@ -218,4 +218,3 @@ void dumpIt(const char* name, const BigInteger& bi)
|
||||
#endif
|
||||
|
||||
} // namespace Auth
|
||||
|
||||
|
@ -13,35 +13,35 @@ namespace Auth {
|
||||
|
||||
/*
|
||||
* Order of battle for SRP handshake:
|
||||
*
|
||||
*
|
||||
* 0. At account creation, the server generates
|
||||
* a random salt and computes a password
|
||||
* a random salt and computes a password
|
||||
* verifier from the account name, password,
|
||||
* and salt.
|
||||
*
|
||||
*
|
||||
* 1. Client generates random number
|
||||
* as private key, computes public
|
||||
* key.
|
||||
*
|
||||
* 2. Client sends server the account
|
||||
*
|
||||
* 2. Client sends server the account
|
||||
* name and its public key.
|
||||
* 3. Server receives account name, looks up
|
||||
* salt and password verifier. Server
|
||||
* generates random number as private key.
|
||||
* Server computes public key from private
|
||||
* key, account name, verifier, and salt.
|
||||
*
|
||||
*
|
||||
* 4. Server sends client public key and salt
|
||||
*
|
||||
*
|
||||
* 3. Client receives server public
|
||||
* key and computes session key
|
||||
* from server key, salt, account
|
||||
* name, and password.
|
||||
* 5. Server computes session key from client
|
||||
* public key, client name, and verifier
|
||||
*
|
||||
*
|
||||
* For full details, see http://www.ietf.org/rfc/rfc5054.txt
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
class RemoteGroup;
|
||||
|
@ -41,7 +41,6 @@ const size_t SALT_LENGTH = 12; // measured after base64 coding
|
||||
class LegacyHash
|
||||
{
|
||||
public:
|
||||
|
||||
static void hash(Firebird::string& h, const Firebird::string& userName, const TEXT* passwd)
|
||||
{
|
||||
Firebird::string salt;
|
||||
|
@ -451,7 +451,8 @@ int SecurityDatabase::shutdown(const int, const int, void*)
|
||||
const static unsigned int INIT_KEY = ((~0) - 1);
|
||||
static unsigned int secDbKey = INIT_KEY;
|
||||
|
||||
Result SecurityDatabaseServer::authenticate(Firebird::IStatus* status, IServerBlock* sBlock, IWriter* writerInterface)
|
||||
Result SecurityDatabaseServer::authenticate(Firebird::IStatus* status, IServerBlock* sBlock,
|
||||
IWriter* writerInterface)
|
||||
{
|
||||
status->init();
|
||||
|
||||
@ -512,7 +513,7 @@ Result SecurityDatabaseServer::authenticate(Firebird::IStatus* status, IServerBl
|
||||
}
|
||||
|
||||
Result SecurityDatabaseServer::getSessionKey(Firebird::IStatus*,
|
||||
const unsigned char** key, unsigned int* keyLen)
|
||||
const unsigned char** key, unsigned int* keyLen)
|
||||
{
|
||||
*key = NULL;
|
||||
*keyLen = 0;
|
||||
|
@ -47,8 +47,9 @@ public:
|
||||
{
|
||||
LocalStatus status;
|
||||
pluginSet = pluginInterface->getPlugins(&status, interfaceType,
|
||||
namesList ? namesList : Config::getPlugins(interfaceType),
|
||||
desiredVersion, ui, NULL);
|
||||
(namesList ? namesList : Config::getPlugins(interfaceType)),
|
||||
desiredVersion, ui, NULL);
|
||||
|
||||
if (!pluginSet)
|
||||
{
|
||||
fb_assert(!status.isSuccess());
|
||||
@ -66,8 +67,9 @@ public:
|
||||
{
|
||||
LocalStatus status;
|
||||
pluginSet = pluginInterface->getPlugins(&status, interfaceType,
|
||||
namesList ? namesList : Config::getPlugins(interfaceType),
|
||||
desiredVersion, ui, new FirebirdConf(knownConfig));
|
||||
(namesList ? namesList : Config::getPlugins(interfaceType)),
|
||||
desiredVersion, ui, new FirebirdConf(knownConfig));
|
||||
|
||||
if (!pluginSet)
|
||||
{
|
||||
fb_assert(!status.isSuccess());
|
||||
|
@ -345,7 +345,7 @@ void sha_final(unsigned char digest[SHA_DIGESTSIZE], SHA_INFO *sha_info)
|
||||
|
||||
namespace Firebird {
|
||||
|
||||
void Sha1::hashBased64(Firebird::string& hash, const Firebird::string& data)
|
||||
void Sha1::hashBased64(string& hash, const string& data)
|
||||
{
|
||||
SHA_INFO si;
|
||||
sha_init(&si);
|
||||
@ -395,4 +395,3 @@ namespace Firebird {
|
||||
}
|
||||
|
||||
} // namespace Firebird
|
||||
|
||||
|
@ -5660,29 +5660,17 @@ current_role
|
||||
|
||||
internal_info
|
||||
: CURRENT_CONNECTION
|
||||
{
|
||||
$$ = newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_CONNECTION_ID));
|
||||
}
|
||||
{ $$ = newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_CONNECTION_ID)); }
|
||||
| CURRENT_TRANSACTION
|
||||
{
|
||||
$$ = newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_TRANSACTION_ID));
|
||||
}
|
||||
{ $$ = newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_TRANSACTION_ID)); }
|
||||
| GDSCODE
|
||||
{
|
||||
$$ = newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_GDSCODE));
|
||||
}
|
||||
{ $$ = newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_GDSCODE)); }
|
||||
| SQLCODE
|
||||
{
|
||||
$$ = newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_SQLCODE));
|
||||
}
|
||||
{ $$ = newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_SQLCODE)); }
|
||||
| SQLSTATE
|
||||
{
|
||||
$$ = newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_SQLSTATE));
|
||||
}
|
||||
{ $$ = newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_SQLSTATE)); }
|
||||
| ROW_COUNT
|
||||
{
|
||||
$$ = newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_ROWS_AFFECTED));
|
||||
}
|
||||
{ $$ = newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_ROWS_AFFECTED)); }
|
||||
;
|
||||
|
||||
sql_string
|
||||
|
@ -115,7 +115,7 @@ class IStatement : public IRefCounted
|
||||
{
|
||||
public:
|
||||
// Prepare flags.
|
||||
static const unsigned PREPARE_PREFETCH_NONE = 0x0;
|
||||
static const unsigned PREPARE_PREFETCH_NONE = 0x00;
|
||||
static const unsigned PREPARE_PREFETCH_TYPE = 0x01;
|
||||
static const unsigned PREPARE_PREFETCH_INPUT_PARAMETERS = 0x02;
|
||||
static const unsigned PREPARE_PREFETCH_OUTPUT_PARAMETERS = 0x04;
|
||||
|
@ -3581,7 +3581,6 @@ void LockManager::validate_lock(const SRQ_PTR lock_ptr, USHORT freed, const SRQ_
|
||||
CHECK(found == 1); // request is in lock's queue
|
||||
}
|
||||
|
||||
|
||||
if (freed == EXPECT_inuse)
|
||||
{
|
||||
CHECK(found_pending == lock->lbl_pending_lrq_count);
|
||||
|
Loading…
Reference in New Issue
Block a user