Move some permission checks from set_user_mode() to its callers.
[ircu2.10.12-pk.git] / ircd / m_admin.c
index d7d3a8b596149afd7cf1010ae145e27c1a8ad2db..bfaa78c46e5b5c14bf172c50694d3aca2bd57509 100644 (file)
  *            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 "hash.h"
 #include "ircd.h"
+#include "ircd_features.h"
+#include "ircd_log.h"
 #include "ircd_reply.h"
 #include "msg.h"
 #include "numeric.h"
@@ -97,7 +93,7 @@
 #include "s_conf.h"
 #include "s_user.h"
 
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
 
 static int send_admin_info(struct Client* sptr)
 {
@@ -119,22 +115,32 @@ static int send_admin_info(struct Client* sptr)
  * parv[1] = servername
  */
 int m_admin(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
+{
+  struct Client *acptr;
+
+  assert(0 != cptr);
+  assert(cptr == sptr);
+
+  if (parc > 1  && (!(acptr = find_match_server(parv[1])) || !IsMe(acptr)))
+    return send_reply(sptr, ERR_NOPRIVILEGES);
+
+  return send_admin_info(sptr);
+}
+
+/*
+ * mo_admin - oper message handler
+ *
+ * parv[0] = sender prefix
+ * parv[1] = servername
+ */
+int mo_admin(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
   assert(0 != cptr);
   assert(cptr == sptr);
 
-  if (parc > 1) {
-    struct Client *acptr;
-    acptr = FindUser(parv[1]);
-    if (acptr)
-      parv[1] = cli_name(cli_user(acptr)->server);
-    else if (!(acptr = find_match_server(parv[1])))
-      return send_reply(sptr, ERR_NOSUCHSERVER, parv[1]);
-
-    parv[1] = cli_name(acptr);
-    if (hunt_server_cmd(sptr, CMD_ADMIN, cptr, 0, ":%C", 1, parc, parv) != HUNTED_ISME)
-      return 0;
-  }
+  if (hunt_server_cmd(sptr, CMD_ADMIN, cptr, feature_int(FEAT_HIS_REMOTE), 
+                      ":%C", 1, parc, parv) != HUNTED_ISME)
+    return 0;
   return send_admin_info(sptr);
 }