From c67911bfcc44b8fe010f3a35e966746c30656d55 Mon Sep 17 00:00:00 2001 From: Matt Schatz Date: Tue, 16 Feb 2021 20:12:16 -0700 Subject: bots: Fix dtor channel iterator being invalidated. The call to UnAssign() erases the channel from the set which invalidates the iterator in this loop. Handle this in the same manner as the NickCore dtor. --- src/bots.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/bots.cpp b/src/bots.cpp index 2f6c916a7..94b688f0d 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -62,9 +62,9 @@ BotInfo::~BotInfo() IRCD->SendSQLineDel(&x); } - for (std::set::iterator it = this->channels->begin(), it_end = this->channels->end(); it != it_end; ++it) + for (std::set::iterator it = this->channels->begin(), it_end = this->channels->end(); it != it_end;) { - ChannelInfo *ci = *it; + ChannelInfo *ci = *it++; this->UnAssign(NULL, ci); } -- cgit From f83558f10b3ac6021b05fa187a9302310794f008 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 8 Apr 2021 13:25:05 +0100 Subject: Log when freopen and chown fail. --- src/init.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/init.cpp b/src/init.cpp index 602311a52..9c85196b9 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -106,9 +106,12 @@ void Anope::Fork() #ifndef _WIN32 kill(getppid(), SIGUSR2); - freopen("/dev/null", "r", stdin); - freopen("/dev/null", "w", stdout); - freopen("/dev/null", "w", stderr); + if (!freopen("/dev/null", "r", stdin)) + Log() << "Unable to redirect stdin to /dev/null: " << Anope::LastError(); + if (!freopen("/dev/null", "w", stdout)) + Log() << "Unable to redirect stdout to /dev/null: " << Anope::LastError(); + if (!freopen("/dev/null", "w", stderr)) + Log() << "Unable to redirect stderr to /dev/null: " << Anope::LastError(); setpgid(0, 0); @@ -263,7 +266,9 @@ static void setuidgid() { LogFile* lf = li.logfiles[j]; - chown(lf->filename.c_str(), uid, gid); + errno = 0; + if (chown(lf->filename.c_str(), uid, gid) != 0) + Log() << "Unable to change the ownership of " << lf->filename << " to " << uid << "/" << gid << ": " << Anope::LastError(); } } -- cgit From 683f42eeef9f82edcbf96349a21ed4153a80837c Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 8 Apr 2021 13:25:52 +0100 Subject: Use UTC in anopesmtp to fix a C++98 compat warning. --- src/tools/anopesmtp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tools/anopesmtp.cpp b/src/tools/anopesmtp.cpp index 396524049..d86f9c43f 100644 --- a/src/tools/anopesmtp.cpp +++ b/src/tools/anopesmtp.cpp @@ -112,9 +112,9 @@ static std::string GetTimeStamp() { char tbuf[256]; time_t t = time(NULL); - struct tm *tm = localtime(&t); + struct tm *tm = gmtime(&t); - strftime(tbuf, sizeof(tbuf) - 1, "%a, %d %b %Y %H:%M:%S %z", tm); + strftime(tbuf, sizeof(tbuf) - 1, "%a, %d %b %Y %H:%M:%S +0000", tm); return tbuf; } -- cgit From c00ecc5e024251213a71673a63efe24e10d0cdbe Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 16 Apr 2021 22:08:29 +0100 Subject: Process writes to the uplink socket before quitting in all cases. This allows any error that might have been sent to the IRCd to actually be sent. --- src/uplink.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/uplink.cpp b/src/uplink.cpp index 7e8a15860..785ef88cd 100644 --- a/src/uplink.cpp +++ b/src/uplink.cpp @@ -94,14 +94,13 @@ UplinkSocket::~UplinkSocket() } IRCD->SendSquit(Me, Anope::QuitReason); - - this->ProcessWrite(); // Write out the last bit } for (unsigned i = Me->GetLinks().size(); i > 0; --i) if (!Me->GetLinks()[i - 1]->IsJuped()) Me->GetLinks()[i - 1]->Delete(Me->GetName() + " " + Me->GetLinks()[i - 1]->GetName()); + this->ProcessWrite(); // Write out the last bit UplinkSock = NULL; Me->Unsync(); -- cgit