fixed propagation of user mode changes (user should ALWAYS be notified) KeepConn
authorpk910 <philipp@zoelle1.de>
Wed, 26 Dec 2012 07:54:17 +0000 (08:54 +0100)
committerpk910 <philipp@zoelle1.de>
Wed, 26 Dec 2012 08:07:11 +0000 (09:07 +0100)
ircd/s_user.c

index 60144878d25c049b891de1092960fc78262bca20..e5d17b975d1d594ae7a0a066a319702bb7c0aaf8 100644 (file)
@@ -948,6 +948,8 @@ void send_umode_out(struct Client *cptr, struct Client *sptr,
   }
   if (cptr && MyUser(cptr))
     send_umode(cptr, sptr, old, ALL_UMODES, 0);
+  if (sptr && sptr != cptr && MyUser(sptr))
+    send_umode(sptr, sptr, old, ALL_UMODES, 0);
 }
 
 
@@ -1396,6 +1398,8 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc,
       ClearOverrideCC(sptr);
     if (!FlagHas(&setflags, FLAG_KEEPCONN_ENABLED) && IsKeepConnEnabled(sptr) && !HasPriv(sptr, PRIV_SET_KEEPCONN))
       ClearKeepConnEnabled(sptr);
+    if(keepconn && !HasPriv(sptr, PRIV_SET_KEEPCONN))
+      keepconn = NULL;
     /* Opers are able to fake the webirc usermode only if FEAT_FAKE_WEBIRC is true. */
     if (!FlagHas(&setflags, FLAG_WEBIRC) && IsWebIRC(sptr) && !(feature_bool(FEAT_FAKE_WEBIRC) && IsOper(sptr)))
       ClearWebIRC(sptr);
@@ -1458,6 +1462,9 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc,
   }
   if (!FlagHas(&setflags, FLAG_KEEPCONN_ENABLED) && IsKeepConnEnabled(sptr)) {
     sptr->keepconn = atoi(keepconn);
+  } else if(keepconn && sptr->keepconn != atoi(keepconn)) {
+    FlagClr(&setflags, FLAG_KEEPCONN_ENABLED);
+    sptr->keepconn = atoi(keepconn);
   }
 
   if (IsRegistered(sptr)) {
@@ -1586,7 +1593,7 @@ int send_umode(struct Client *cptr, struct Client *sptr, struct Flags *old,
   int flag;
   char *m;
   int what = MODE_NULL;
-  int add_fakehost = 0, add_account = 0;
+  int add_fakehost = 0, add_account = 0, add_keepconn = 0;
 
   /*
    * Build a string in umodeBuf to represent the change in the user's
@@ -1613,6 +1620,10 @@ int send_umode(struct Client *cptr, struct Client *sptr, struct Flags *old,
       if(!serv_modes || FlagHas(old, flag)) continue;
       add_fakehost = 1;
     }
+    
+    if(flag == FLAG_KEEPCONN_ENABLED) {
+      add_keepconn = 1;
+    }
 
     switch (sendset)
     {
@@ -1678,6 +1689,11 @@ int send_umode(struct Client *cptr, struct Client *sptr, struct Flags *old,
     while((*m++ = *t++)) ; /* Empty loop */
     --m; /* back up over previous nul-termination */
   }
+  
+  if(add_keepconn) {
+    *m++ = ' ';
+    m += sprintf(m, "%u", sptr->keepconn);
+  }
 
   *m = '\0';
   if (*umodeBuf && cptr)