Merge branch 'insp3' into master.

This commit is contained in:
Sadie Powell 2021-08-01 19:42:57 +01:00
commit a730147586
6 changed files with 24 additions and 25 deletions

9
configure vendored
View File

@ -157,6 +157,15 @@ if ($interactive) {
}
}
unless (run_test $RealDir, -w $RealDir, 'writable') {
print_error <<"EOE";
the source directory is not writable. This most likely means that you
downloaded InspIRCd as root but tried to build as an unprivileged user. To
fix this issue redownload the source as the user you want to build as or fix
the permissions of <|GREEN $RealDir|>.
EOE
};
$config{CXX} = find_compiler($config{CXX} // $ENV{CXX});
unless ($config{CXX}) {
say 'A suitable C++ compiler could not be detected on your system!';

View File

@ -31,8 +31,10 @@ namespace IRCv3
class IRCv3::WriteNeighborsWithCap : public User::ForEachNeighborHandler
{
private:
const Cap::Capability& cap;
ClientProtocol::Event& protoev;
uint64_t sentid;
void Execute(LocalUser* user) override
{
@ -45,8 +47,10 @@ class IRCv3::WriteNeighborsWithCap : public User::ForEachNeighborHandler
: cap(capability)
, protoev(ev)
{
user->ForEachNeighbor(*this, include_self);
sentid = user->ForEachNeighbor(*this, include_self);
}
uint64_t GetAlreadySentId() const { return sentid; }
};
/** Base class for simple message tags.

View File

@ -573,7 +573,7 @@ class CoreExport User : public Extensible
* @param include_self True to include this user in the set of neighbors, false otherwise.
* Modules may override this. Has no effect if this user is not local.
*/
void ForEachNeighbor(ForEachNeighborHandler& handler, bool include_self = true);
uint64_t ForEachNeighbor(ForEachNeighborHandler& handler, bool include_self = true);
/** Return true if the user shares at least one channel with another user
* @param other The other user to compare the channel list against

View File

@ -67,7 +67,6 @@ my $runtimedir = "@RUNTIME_DIR@";
my $valgrindlogpath = "@LOG_DIR@/valgrind";
my $executable = "inspircd";
my $version = "@VERSION_FULL@";
my $uid = "@UID@";
my @gdbargs = (
'--eval-command', 'handle SIGPIPE pass nostop noprint',
@ -85,22 +84,6 @@ sub expand_fragment($$) {
}
}
if (!(grep { $_ eq '--runasroot' } @ARGV) && ($< == 0 || $> == 0)) {
if ($uid !~ /^\d+$/) {
# Named UID, look it up
$uid = getpwnam $uid;
}
if (!$uid) {
die "Cannot find a valid UID to change to";
}
# drop root if we were configured with an ircd UID
$< = $uid;
$> = $uid;
if ($< == 0 || $> == 0) {
die "Could not drop root: $!";
}
}
our($pid,$pidfile);
# Lets see what they want to do.. Set the variable (Cause i'm a lazy coder)
my $arg = shift(@ARGV);

View File

@ -33,6 +33,9 @@ namespace
class UserResolver : public DNS::Request
{
private:
/** The socket address that the user we are looking up is connected from. */
const irc::sockets::sockaddrs sa;
/** UUID we are looking up */
const std::string uuid;
@ -57,6 +60,7 @@ class UserResolver : public DNS::Request
*/
UserResolver(DNS::Manager* mgr, Module* me, LocalUser* user, const std::string& to_resolve, DNS::QueryType qt)
: DNS::Request(mgr, me, to_resolve, qt)
, sa(user->client_sa)
, uuid(user->uuid)
{
}
@ -68,11 +72,8 @@ class UserResolver : public DNS::Request
void OnLookupComplete(const DNS::Query* r) override
{
LocalUser* bound_user = IS_LOCAL(ServerInstance->Users.FindUUID(uuid));
if (!bound_user)
{
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Resolution finished for user '%s' who is gone", uuid.c_str());
if (!bound_user || bound_user->client_sa != sa)
return;
}
const DNS::ResourceRecord* ans_record = r->FindAnswerOfType(this->question.type);
if (ans_record == NULL)
@ -145,7 +146,7 @@ class UserResolver : public DNS::Request
void OnError(const DNS::Query* query) override
{
LocalUser* bound_user = IS_LOCAL(ServerInstance->Users.FindUUID(uuid));
if (bound_user)
if (bound_user && bound_user->client_sa == sa)
HandleError(bound_user, "Could not resolve your hostname: " + this->manager->GetErrorStr(query->error));
}
};

View File

@ -887,7 +887,7 @@ void User::WriteCommonRaw(ClientProtocol::Event& protoev, bool include_self)
ForEachNeighbor(handler, include_self);
}
void User::ForEachNeighbor(ForEachNeighborHandler& handler, bool include_self)
uint64_t User::ForEachNeighbor(ForEachNeighborHandler& handler, bool include_self)
{
// The basic logic for visiting the neighbors of a user is to iterate the channel list of the user
// and visit all users on those channels. Because two users may share more than one common channel,
@ -936,6 +936,8 @@ void User::ForEachNeighbor(ForEachNeighborHandler& handler, bool include_self)
}
}
}
return newid;
}
void User::WriteRemoteNumeric(const Numeric::Numeric& numeric)