Index: src/s_serv.c
===================================================================
--- src/s_serv.c	(revision 37)
+++ src/s_serv.c	(working copy)
@@ -772,14 +772,20 @@
 	fclose(tunefile);
 }
 
-/** Rehash motd and rule files (MPATH/RPATH and all tld entries). */
-void rehash_motdrules()
+/* Merged into one function, as there really wasn't point having two with one doing TLDs and the other not..
+ * It's confusing, and really unnecessary IMO. (besides, how many people really have TLD blocks, and then how
+ * often do they rehash? Keeping them seperate adds nothing but complexity.)
+ */
+void reread_motdsandrules()
 {
-ConfigItem_tld *tlds;
+	ConfigItem_tld *tlds;
 
 	motd = (aMotd *) read_file_ex(MPATH, &motd, &motd_tm);
 	rules = (aMotd *) read_file(RPATH, &rules);
 	smotd = (aMotd *) read_file_ex(SMPATH, &smotd, &smotd_tm);
+	botmotd = (aMotd *) read_file(BPATH, &botmotd);
+	opermotd = (aMotd *) read_file(OPATH, &opermotd);
+
 	for (tlds = conf_tld; tlds; tlds = (ConfigItem_tld *) tlds->next)
 	{
 		tlds->motd = read_file_ex(tlds->motd_file, &tlds->motd, &tlds->motd_tm);
@@ -793,15 +799,6 @@
 	}
 }
 
-void reread_motdsandrules()
-{
-	motd = (aMotd *) read_file_ex(MPATH, &motd, &motd_tm);
-	rules = (aMotd *) read_file(RPATH, &rules);
-	smotd = (aMotd *) read_file_ex(SMPATH, &smotd, &smotd_tm);
-	botmotd = (aMotd *) read_file(BPATH, &botmotd);
-	opermotd = (aMotd *) read_file(OPATH, &opermotd);
-}
-
 /*
 ** m_rehash
 ** remote rehash by binary
@@ -811,24 +808,41 @@
 ** fixed remote rehashing, but it's getting a bit weird code again -- Syzop
 ** removed '-all' code, this is now considered as '/rehash', this is ok
 ** since we rehash everything with simple '/rehash' now. Syzop/20040205
+** Revisited 2005/09/29, trying to clean things up again a little.. Fixed remote
+** ulines not being able to rehash, fixed all but servadmin/coadmin not being able
+** to rehash -aflag, simplified/remove duplicate logic a little
+** perhaps easier to understand now? :) --w00t
 */
 CMD_FUNC(m_rehash)
 {
-	int  x;
+	int x = 0;
 
 	if (MyClient(sptr) && !OPCanRehash(sptr))
 	{
 		sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
 		return 0;
 	}
-	if (!MyClient(sptr) && !IsNetAdmin(sptr)
-	    && !IsULine(sptr))
+	else
 	{
-		sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
+		/* remote rehash request */
+		if (!IsNetAdmin(sptr) && !IsULine(sptr))
+		{
+			sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
+			return 0;
+		}
+	}
+
+	/* moved to avoid duplicating stuff. Side effect, sends even if remote rehash is off.. */
+	if (loop.ircd_rehashing)
+	{
+		sendto_one(sptr, ":%s NOTICE %s :A rehash is already in progress",
+			me.name, sptr->name);
 		return 0;
 	}
-	x = 0;
 
+	/* this looks whacked.. but unless we remove -flags totally
+	 * (was my original intent), it's got to stay. --w00t
+	 */
 	if (BadPtr(parv[2])) {
 		/* If the argument starts with a '-' (like -motd, -opermotd, etc) then it's
 		 * assumed not to be a server. -- Syzop
@@ -851,34 +865,25 @@
 #endif
 		if (parv[2] == NULL)
 		{
-			if (loop.ircd_rehashing)
-			{
-				sendto_one(sptr, ":%s NOTICE %s :A rehash is already in progress",
-					me.name, sptr->name);
-				return 0;
-			}
 			sendto_serv_butone(&me,
 			    ":%s GLOBOPS :%s is remotely rehashing server config file",
 			    me.name, sptr->name);
 			sendto_ops
 			    ("%s is remotely rehashing server config file",
 			    parv[0]);
-			reread_motdsandrules();
-			return rehash(cptr, sptr,
-			    (parc > 1) ? ((*parv[1] == 'q') ? 2 : 0) : 0);
+			/* fallthrough and rehash below, don't duplicate stuff. */
 		}
-		parv[1] = parv[2];
+		else
+		{
+			parv[1] = parv[2];
+		}
 	}
 
 	if (!BadPtr(parv[1]) && strcmp(parv[1], "-all"))
 	{
-
-		if (!IsAdmin(sptr) && !IsCoAdmin(sptr))
-		{
-			sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
-			return 0;
-		}
-
+		/* why doublecheck perms again? if they can rehash, they can rehash ffs.. broken anyhow
+		 * as we didn't check for NA, etc.
+		 */
 		if (*parv[1] == '-')
 		{
 			if (!strnicmp("-gar", parv[1], 4))
@@ -920,7 +925,7 @@
 				    sptr->name);
 				if (cptr != sptr)
 					sendto_serv_butone(&me, ":%s GLOBOPS :%s is remotely rehashing all MOTDs and RULES", me.name, sptr->name);
-				rehash_motdrules();
+				reread_motdsandrules();
 				RunHook3(HOOKTYPE_REHASHFLAG, cptr, sptr, parv[1]);
 				return 0;
 			}
@@ -930,12 +935,6 @@
 	}
 	else
 	{
-		if (loop.ircd_rehashing)
-		{
-			sendto_one(sptr, ":%s NOTICE %s :A rehash is already in progress",
-				me.name, sptr->name);
-			return 0;
-		}
 		sendto_ops("%s is rehashing server config file", parv[0]);
 	}
 
