* note: it is guaranteed that parv[0]..parv[parc-1] are all
* non-NULL pointers.
*/
-#if 0
-/*
- * No need to include handlers.h here the signatures must match
- * and we don't need to force a rebuild of all the handlers everytime
- * we add a new one to the list. --Bleep
- */
-#include "handlers.h"
-#endif /* 0 */
+#include "config.h"
+
#include "client.h"
#include "ircd.h"
#include "ircd_log.h"
#include "ircd_reply.h"
#include "ircd_string.h"
+#include "motd.h"
#include "numeric.h"
#include "s_conf.h"
#include "send.h"
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
/*
* mo_rehash - oper message handler
+ *
+ * parv[1] = 'm' flushes the MOTD cache and returns
+ * parv[1] = 'l' reopens the log files and returns
+ * parv[1] = 'q' to not rehash the resolver (optional)
*/
int mo_rehash(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
{
-#if defined(OPER_REHASH) || defined(LOCOP_REHASH)
-#ifndef LOCOP_REHASH
- if (!MyUser(sptr) || !IsOper(sptr))
-#else
-#ifdef OPER_REHASH
- if (!MyUser(sptr) || !IsAnOper(sptr))
-#else
- if (!MyUser(sptr) || !IsLocOp(sptr))
-#endif
-#endif
- {
- send_reply(sptr, ERR_NOPRIVILEGES);
- sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
- return 0;
+ int flag = 0;
+
+ if (!HasPriv(sptr, PRIV_REHASH))
+ return send_reply(sptr, ERR_NOPRIVILEGES);
+
+ if (parc > 1) { /* special processing */
+ if (*parv[1] == 'm') {
+ send_reply(sptr, SND_EXPLICIT | RPL_REHASHING, ":Flushing MOTD cache");
+ motd_recache(); /* flush MOTD cache */
+ return 0;
+ } else if (*parv[1] == 'l') {
+ send_reply(sptr, SND_EXPLICIT | RPL_REHASHING, ":Reopening log files");
+ log_reopen(); /* reopen log files */
+ return 0;
+ } else if (*parv[1] == 'q')
+ flag = 2;
}
+
send_reply(sptr, RPL_REHASHING, configfile);
sendto_opmask_butone(0, SNO_OLDSNO, "%C is rehashing Server config file",
sptr);
- ircd_log(L_INFO, "REHASH From %s\n", get_client_name(sptr, HIDE_IP));
- return rehash(cptr, (parc > 1) ? ((*parv[1] == 'q') ? 2 : 0) : 0);
-#endif /* defined(OPER_REHASH) || defined(LOCOP_REHASH) */
- return 0;
-}
-#if 0
-#if defined(OPER_REHASH) || defined(LOCOP_REHASH)
-/*
- * m_rehash
- */
-int m_rehash(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
-{
-#ifndef LOCOP_REHASH
- if (!MyUser(sptr) || !IsOper(sptr))
-#else
-#ifdef OPER_REHASH
- if (!MyUser(sptr) || !IsAnOper(sptr))
-#else
- if (!MyUser(sptr) || !IsLocOp(sptr))
-#endif
-#endif
- {
- sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); /* XXX DEAD */
- return 0;
- }
- sendto_one(sptr, rpl_str(RPL_REHASHING), me.name, parv[0], configfile); /* XXX DEAD */
- sendto_ops("%s is rehashing Server config file", parv[0]); /* XXX DEAD */
- ircd_log(L_INFO, "REHASH From %s\n", get_client_name(sptr, HIDE_IP));
- return rehash(cptr, (parc > 1) ? ((*parv[1] == 'q') ? 2 : 0) : 0);
+ log_write(LS_SYSTEM, L_INFO, 0, "REHASH From %#C", sptr);
+
+ return rehash(cptr, flag);
}
-#endif
-#endif /* 0 */