From 41813cc15a1392cdb71daee789a11e2025d4d817 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Fri, 21 Feb 2020 12:41:04 -0500 Subject: [PATCH 1/3] fix #791 --- irc/handlers.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/irc/handlers.go b/irc/handlers.go index 8f3827b9..814543ef 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -804,6 +804,25 @@ func debugHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res case "STOPCPUPROFILE": pprof.StopCPUProfile() rb.Notice(fmt.Sprintf("CPU profiling stopped")) + + case "CRASHSERVER": + if !client.HasRoleCapabs("oper:rehash") { + rb.Notice(client.t("You must have rehash permissions in order to execute DEBUG CRASHSERVER")) + return false + } + code := unregisterConfirmationCode(server.name, server.ctime) + if len(msg.Params) == 1 || msg.Params[1] != code { + rb.Notice(fmt.Sprintf(client.t("To crash the server, issue the following command: /DEBUG CRASHSERVER %s"), code)) + return false + } + go func() { + // intentional nil dereference on a new goroutine, bypassing recover-from-errors + var i, j *int + *i = *j + }() + + default: + rb.Notice(client.t("Unrecognized DEBUG subcommand")) } return false } From 490b3722bde65622f637e726aece9241cb7900bf Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Fri, 21 Feb 2020 13:07:22 -0500 Subject: [PATCH 2/3] add a logline and a help description for CRASHSERVER --- irc/handlers.go | 1 + irc/help.go | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/irc/handlers.go b/irc/handlers.go index 814543ef..a14cc7ed 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -815,6 +815,7 @@ func debugHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res rb.Notice(fmt.Sprintf(client.t("To crash the server, issue the following command: /DEBUG CRASHSERVER %s"), code)) return false } + server.logger.Error("server", fmt.Sprintf("DEBUG CRASHSERVER executed by operator %s", client.Oper().Name)) go func() { // intentional nil dereference on a new goroutine, bypassing recover-from-errors var i, j *int diff --git a/irc/help.go b/irc/help.go index 4f0a19da..58de3277 100644 --- a/irc/help.go +++ b/irc/help.go @@ -153,13 +153,14 @@ https://gist.github.com/DanielOaks/c104ad6e8759c01eb5c826d627caf80d`, oper: true, text: `DEBUG