mirror of
https://github.com/anope/anope.git
synced 2026-06-30 07:16:38 +02:00
Correctly identify a user when they get autoidentified and made db_plain not crash if it gets a founderless channel
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2888 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
@@ -272,6 +272,19 @@ class ModuleException : public CoreException
|
||||
virtual ~ModuleException() throw() {}
|
||||
};
|
||||
|
||||
class DatabaseException : public CoreException
|
||||
{
|
||||
public:
|
||||
/** This constructor can be used to specify an error message before throwing.
|
||||
* @param mmessage The exception
|
||||
*/
|
||||
DatabaseException(const std::string &message) : CoreException(message, "A database module") { }
|
||||
|
||||
/** Destructor
|
||||
* @throws Nothing
|
||||
*/
|
||||
virtual ~DatabaseException() throw() { }
|
||||
};
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
+25
-14
@@ -127,9 +127,9 @@ static void ReadDatabase(Module *m = NULL)
|
||||
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(nc, key, params));
|
||||
}
|
||||
}
|
||||
catch (const char *err)
|
||||
catch (DatabaseException& ex)
|
||||
{
|
||||
Alog() << "[db_plain]: " << err;
|
||||
Alog() << "[db_plain]: " << ex.GetReason();
|
||||
}
|
||||
}
|
||||
else if (na && Type == MD_NA)
|
||||
@@ -143,9 +143,9 @@ static void ReadDatabase(Module *m = NULL)
|
||||
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(na, key, params));
|
||||
}
|
||||
}
|
||||
catch (const char *err)
|
||||
catch (DatabaseException& ex)
|
||||
{
|
||||
Alog() << "[db_plain]: " << err;
|
||||
Alog() << "[db_plain]: " << ex.GetReason();
|
||||
}
|
||||
}
|
||||
else if (bi && Type == MD_BI)
|
||||
@@ -159,9 +159,9 @@ static void ReadDatabase(Module *m = NULL)
|
||||
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(bi, key, params));
|
||||
}
|
||||
}
|
||||
catch (const char *err)
|
||||
catch (DatabaseException& ex)
|
||||
{
|
||||
Alog() << "[db_plain]: " << err;
|
||||
Alog() << "[db_plain]: " << ex.GetReason();
|
||||
}
|
||||
}
|
||||
else if (ci && Type == MD_CH)
|
||||
@@ -175,9 +175,14 @@ static void ReadDatabase(Module *m = NULL)
|
||||
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(ci, key, params));
|
||||
}
|
||||
}
|
||||
catch (const char *err)
|
||||
catch (DatabaseException& ex)
|
||||
{
|
||||
Alog() << "[db_plain]: " << err;
|
||||
Alog() << "[db_plain]: " << ex.GetReason();
|
||||
if (!ci->founder)
|
||||
{
|
||||
delete ci;
|
||||
ci = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -723,10 +728,9 @@ class DBPlain : public Module
|
||||
ci->founder = findcore(params[0].c_str());
|
||||
if (!ci->founder)
|
||||
{
|
||||
Alog() << "[db_plain]: Deleting founderless channel " << ci->name;
|
||||
delete ci;
|
||||
ci = NULL;
|
||||
throw "no founder";
|
||||
std::stringstream reason;
|
||||
reason << "Deleting founderless channel " << ci->name << " (founder: " << params[0] << ")";
|
||||
throw DatabaseException(reason.str());
|
||||
}
|
||||
}
|
||||
else if (key == "SUCCESSOR")
|
||||
@@ -766,7 +770,12 @@ class DBPlain : public Module
|
||||
{
|
||||
NickCore *nc = findcore(params[0].c_str());
|
||||
if (!nc)
|
||||
throw "access entry for nonexistant core";
|
||||
{
|
||||
std::stringstream reason;
|
||||
reason << "Access entry for nonexistant core " << params[0] << " on " << ci->name;
|
||||
throw DatabaseException(reason.str());
|
||||
}
|
||||
|
||||
int level = atoi(params[1].c_str());
|
||||
time_t last_seen = strtol(params[2].c_str(), NULL, 10);
|
||||
ci->AddAccess(nc, level, buf, last_seen);
|
||||
@@ -781,7 +790,9 @@ class DBPlain : public Module
|
||||
nc = findcore(params[2].c_str());
|
||||
if (!nc)
|
||||
{
|
||||
throw "akick for nonexistant core";
|
||||
std::stringstream reason;
|
||||
reason << "Akick for nonexistant core " << params[2] << " on " << ci->name;
|
||||
throw DatabaseException(reason.str());
|
||||
}
|
||||
}
|
||||
AutoKick *ak;
|
||||
|
||||
+8
-1
@@ -348,10 +348,17 @@ void User::AutoID(const char *account)
|
||||
|
||||
if ((tnc = findcore(account)))
|
||||
{
|
||||
this->nc = tnc;
|
||||
if ((na = findnick(this->nick)) && na->nc == tnc)
|
||||
{
|
||||
if (na->last_realname)
|
||||
delete [] na->last_realname;
|
||||
na->last_realname = sstrdup(this->realname);
|
||||
na->last_seen = time(NULL);
|
||||
this->Login(na->nc);
|
||||
this->UpdateHost();
|
||||
check_memos(this);
|
||||
|
||||
FOREACH_MOD(I_OnNickIdentify, OnNickIdentify(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user