Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / s_user.c
index b4695ede58b6b27342d0fc91376884920196833d..0a71c4a742b1370d67fed4851949b6b008a0f3ea 100644 (file)
@@ -22,6 +22,8 @@
  *
  * $Id$
  */
+#include "config.h"
+
 #include "s_user.h"
 #include "IPcheck.h"
 #include "channel.h"
@@ -34,6 +36,7 @@
 #include "ircd_chattr.h"
 #include "ircd_features.h"
 #include "ircd_log.h"
+#include "ircd_policy.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "list.h"
@@ -130,50 +133,6 @@ void user_count_memory(size_t* count_out, size_t* bytes_out)
   *bytes_out = userCount * sizeof(struct User);
 }
 
-/*
- * user_set_away - set user away state
- * returns 1 if client is away or changed away message, 0 if 
- * client is removing away status.
- * NOTE: this function may modify user and message, so they
- * must be mutable.
- */
-int user_set_away(struct User* user, char* message)
-{
-  char* away;
-  assert(0 != user);
-
-  away = user->away;
-
-  if (EmptyString(message)) {
-    /*
-     * Marking as not away
-     */
-    if (away) {
-      MyFree(away);
-      user->away = 0;
-    }
-  }
-  else {
-    /*
-     * Marking as away
-     */
-    unsigned int len = strlen(message);
-
-    if (len > TOPICLEN) {
-      message[TOPICLEN] = '\0';
-      len = TOPICLEN;
-    }
-    if (away)
-      away = (char*) MyRealloc(away, len + 1);
-    else
-      away = (char*) MyMalloc(len + 1);
-    assert(0 != away);
-
-    user->away = away;
-    strcpy(away, message);
-  }
-  return (user->away != 0);
-}
 
 /*
  * next_client
@@ -406,8 +365,8 @@ int register_user(struct Client *cptr, struct Client *sptr,
         {
           last_too_many1 = CurrentTime;
           sendto_opmask_butone(0, SNO_TOOMANY, "Too many connections in "
-                               "class for %s.",
-                               get_client_name(sptr, HIDE_IP));
+                               "class %i for %s.", get_client_class(sptr),
+                               get_client_name(sptr, SHOW_IP));
         }
         ++ServerStats->is_ref;
         IPcheck_connect_fail(cli_ip(sptr));
@@ -420,7 +379,7 @@ int register_user(struct Client *cptr, struct Client *sptr,
           last_too_many2 = CurrentTime;
           sendto_opmask_butone(0, SNO_TOOMANY, "Too many connections from "
                                "same IP for %s.",
-                               get_client_name(sptr, HIDE_IP));
+                               get_client_name(sptr, SHOW_IP));
         }
         ++ServerStats->is_ref;
         return exit_client(cptr, sptr, &me,
@@ -1145,9 +1104,9 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv
           tmpmask = (what == MODE_ADD) ?
               (IsAnOper(sptr) ? SNO_OPERDEFAULT : SNO_DEFAULT) : 0;
         if (tmpmask)
-          cli_flags(sptr) |= FLAGS_SERVNOTICE;
+         SetServNotice(sptr);
         else
-          cli_flags(sptr) &= ~FLAGS_SERVNOTICE;
+         ClearServNotice(sptr);
         break;
       case 'w':
         if (what == MODE_ADD)
@@ -1227,15 +1186,27 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv
     if (feature_bool(FEAT_WALLOPS_OPER_ONLY) && !IsAnOper(sptr) &&
        !(setflags & FLAGS_WALLOP))
       ClearWallops(sptr);
+#ifdef SERVNOTICE_OPER_ONLY
+    if (MyConnect(sptr) && !IsAnOper(sptr) && !(setflags & FLAGS_SERVNOTICE)) {
+      ClearServNotice(sptr);
+      set_snomask(sptr, 0, SNO_SET);
+    }
+#endif
+#ifdef DEBUG_OPER_ONLY
+    if (!IsAnOper(sptr) && !(setflags & FLAGS_DEBUG))
+      ClearDebug(sptr);
+#endif
   }
   if (MyConnect(sptr)) {
     if ((setflags & (FLAGS_OPER | FLAGS_LOCOP)) && !IsAnOper(sptr))
       det_confs_butmask(sptr, CONF_CLIENT & ~CONF_OPS);
 
-    if (tmpmask != cli_snomask(sptr))
-      set_snomask(sptr, tmpmask, SNO_SET);
-    if (cli_snomask(sptr) && snomask_given)
-      send_reply(sptr, RPL_SNOMASK, cli_snomask(sptr), cli_snomask(sptr));
+    if (SendServNotice(sptr)) {
+      if (tmpmask != cli_snomask(sptr))
+       set_snomask(sptr, tmpmask, SNO_SET);
+      if (cli_snomask(sptr) && snomask_given)
+       send_reply(sptr, RPL_SNOMASK, cli_snomask(sptr), cli_snomask(sptr));
+    }
   }
   /*
    * Compare new flags with old flags and send string which