diff --git a/Changes b/Changes index 276e62167..296a0c057 100644 --- a/Changes +++ b/Changes @@ -2208,3 +2208,9 @@ - Little tweak to +Z: when the last insecure user parts and the channel is set +Z (secure), the parting user saw the MODE too, which was silly. Reported by Robby22 (#0003720). +- Added '/REHASH -global' command which will rehash all servers on the + network. You can also specify options like '/REHASH -global -motd' to + rehash only the MOTD/RULES/etc. Just like /REHASH this is a + NetAdmin-only command. This command is fully backwards compatible with + older UnrealIRCd version in the sense that it will also REHASH old + Unreal's. Suggested by 'P' in #0001522. diff --git a/doc/unreal32docs.html b/doc/unreal32docs.html index 344c3d652..a9fe6f6df 100644 --- a/doc/unreal32docs.html +++ b/doc/unreal32docs.html @@ -3335,9 +3335,10 @@ to get more information on a command.

IRCop - rehash <server> <flags> + rehash <server|-global> <flags> Rehashes the servers config file. Including a server name allows you to - rehash a remote servers config file. Several flags are also available. They + rehash a remote servers config file, and using -global will rehash all + servers on the network (both are NetAdmin-only). Several flags are also available. They Include
-dns - Reinitializes and reloads the resolver
-motd - Only re-read all MOTD, BOTMOTD, OPERMOTD and RULES files (including those in tld{} blocks)
diff --git a/help.conf b/help.conf index 61c82bb68..a1c6432c1 100644 --- a/help.conf +++ b/help.conf @@ -913,13 +913,15 @@ help Rehash { " Prompts the server to reread the configuration files."; " IRC Operator only command."; " -"; - " Syntax: REHASH "; - " REHASH "; + " Syntax: REHASH [flag]"; + " REHASH -global [flag]"; + " REHASH [flag]"; " -"; - " If servername and flags are not specified this rehashes the"; + " If servername and flag are not specified this rehashes the"; " unrealircd.conf, and re-reads all MOTD, BOTMOTD, OPERMOTD and RULES files."; " If servername is specified, this is used to rehash the remote server."; - " Only NetAdmins may specify a server name."; + " If -global is specified, then all servers on the network are rehashed."; + " Only NetAdmins may specify a server name and use -global."; " -"; " The flags are used to rehash other config files, valid flags are:"; " -dns - Reinitializes and reloads the resolver"; diff --git a/src/s_serv.c b/src/s_serv.c index c09011f1f..c44c65add 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -653,7 +653,10 @@ CMD_FUNC(m_rehash) else x = hunt_server_token(cptr, sptr, MSG_REHASH, TOK_REHASH, "%s", 1, parc, parv); } else { - x = hunt_server_token(cptr, sptr, MSG_REHASH, TOK_REHASH, "%s %s", 1, parc, parv); + if (!_match("-glob*", parv[1])) /* This is really ugly... hack to make /rehash -global -something work */ + x = HUNTED_ISME; + else + x = hunt_server_token(cptr, sptr, MSG_REHASH, TOK_REHASH, "%s %s", 1, parc, parv); } if (x != HUNTED_ISME) return 0; /* Now forwarded or server didnt exist */ @@ -683,6 +686,48 @@ CMD_FUNC(m_rehash) (parc > 1) ? ((*parv[1] == 'q') ? 2 : 0) : 0); } parv[1] = parv[2]; + } else { + /* Ok this is in an 'else' because it should be only executed for sptr == cptr, + * but it's totally unrelated to the above ;). + */ + if (parv[1] && !_match("-glob*", parv[1])) + { + /* /REHASH -global [options] */ + Link *lp; + aClient *acptr; + + /* Shift parv's to the left */ + parv[1] = parv[2]; + parv[2] = NULL; + parc--; + /* Only netadmins may use /REHASH -global, which is because: + * a) it makes sense + * b) remote servers don't support remote rehashes by non-netadmins + */ + if (!IsNetAdmin(sptr)) + { + sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); + sendnotice(sptr, "'/REHASH -global' requires you to be NetAdmin"); + return 0; + } + if (parv[1] && *parv[1] != '-') + { + sendnotice(sptr, "You cannot specify a server name after /REHASH -global, for obvious reasons"); + return 0; + } + /* Broadcast it in an inefficient, but backwards compatible way. */ + for (lp = Servers; lp; lp = lp->next) + { + acptr = lp->value.cptr; + if (acptr == &me) + continue; + sendto_one(acptr, ":%s %s %s", + sptr->name, + IsToken(acptr->from) ? TOK_REHASH : MSG_REHASH, + parv[1] ? parv[1] : "-all"); + } + /* Don't return, continue, because we need to REHASH ourselves as well. */ + } } if (!BadPtr(parv[1]) && stricmp(parv[1], "-all"))