#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"
/*
* 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);
- return 0;
+ int flag = 0;
+
+# if !defined(OPER_REHASH) || !defined(LOCOP_REHASH)
+ if (
+# ifdef OPER_REHASH
+ !IsOper(sptr)
+# else
+ !IsLocOp(sptr)
+# endif
+ )
+ return send_reply(sptr, ERR_NOPRIVILEGES);
+# endif
+
+ 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);
+
+ return rehash(cptr, flag);
#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);
-}
-#endif
-#endif /* 0 */
-