CVSROOT    : /cvsroot/undernet-ircu
Module     : ircu2.10
Branch tags: u2_10_11_03
Commit time: 2002-11-23 19:46:01 UTC

Modified files:
  Tag: u2_10_11_03
     ChangeLog include/client.h include/whocmds.h ircd/client.c
     ircd/s_bsd.c

Log message:

Author: Kev <[EMAIL PROTECTED]>
Log message:

Fix a bug with Entrope's patch--a SetFlag() in deliver_it() than should
have been a ClrFlag().  Bug resulted in crashes on /restart and probably
other nastiness.

Fixed a long-standing bug in SEE_LUSER()--PRIV_SHOW_INVIS and
PRIV_SHOW_ALL_INVIS were or'd together in the argument to a HasPriv()
macro, which made those privileges of little use.

Use an enum for Privileges, like Entrope's enum Flag.

---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.290.2.125.2.17 ircu2.10/ChangeLog:1.290.2.125.2.18
--- ircu2.10/ChangeLog:1.290.2.125.2.17 Sat Nov 23 11:05:07 2002
+++ ircu2.10/ChangeLog  Sat Nov 23 11:45:49 2002
@@ -1,5 +1,20 @@
 2002-11-23  Kevin L Mitchell  <[EMAIL PROTECTED]>
 
+       * ircd/s_bsd.c (deliver_it): this should have been a ClrFlag(),
+       not a SetFlag()--caused crashes on /restart and probably other
+       nastiness
+
+       * ircd/client.c (client_set_privs): must count up through
+       PRIV_LAST_PRIV rather than 0, since we *start* at zero
+
+       * include/client.h: I was so inspired by the use of enum Flag by
+       Entrope that I decided to use an enum for privileges as well
+
+       * include/whocmds.h (SEE_LUSER): correct a bug in SEE_LUSER with
+       regard to the PRIV_SHOW_INVIS / PRIV_SHOW_ALL_INVIS privileges
+
+       * ircd/client.c: use enum Priv for privilage table
+
        * include/client.h: remove a comma from the end of the enumerator
        list--resulted in a gcc warning.
 
Index: ircu2.10/include/client.h
diff -u ircu2.10/include/client.h:1.23.2.4.8.1 ircu2.10/include/client.h:1.23.2.4.8.2
--- ircu2.10/include/client.h:1.23.2.4.8.1      Sat Nov 23 11:05:07 2002
+++ ircu2.10/include/client.h   Sat Nov 23 11:45:50 2002
@@ -18,7 +18,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  *
- * $Id: client.h,v 1.23.2.4.8.1 2002/11/23 19:05:07 klmitch Exp $
+ * $Id: client.h,v 1.23.2.4.8.2 2002/11/23 19:45:50 klmitch Exp $
  */
 #ifndef INCLUDED_client_h
 #define INCLUDED_client_h
@@ -66,41 +66,43 @@
  * source file, or in the source file itself (when only used in that file).
  */
 
-#define PRIV_CHAN_LIMIT                 1 /* no channel limit on oper */
-#define PRIV_MODE_LCHAN                 2 /* oper can mode local chans */
-#define PRIV_WALK_LCHAN                 3 /* oper can walk thru local modes */
-#define PRIV_DEOP_LCHAN                 4 /* no deop oper on local chans */
-#define PRIV_SHOW_INVIS                 5 /* show local invisible users */
-#define PRIV_SHOW_ALL_INVIS     6 /* show all invisible users */
-#define PRIV_UNLIMIT_QUERY      7 /* unlimit who queries */
-
-#define PRIV_KILL               8 /* oper can KILL */
-#define PRIV_LOCAL_KILL                 9 /* oper can local KILL */
-#define PRIV_REHASH            10 /* oper can REHASH */
-#define PRIV_RESTART           11 /* oper can RESTART */
-#define PRIV_DIE               12 /* oper can DIE */
-#define PRIV_GLINE             13 /* oper can GLINE */
-#define PRIV_LOCAL_GLINE       14 /* oper can local GLINE */
-#define PRIV_JUPE              15 /* oper can JUPE */
-#define PRIV_LOCAL_JUPE                16 /* oper can local JUPE */
-#define PRIV_OPMODE            17 /* oper can OP/CLEARMODE */
-#define PRIV_LOCAL_OPMODE      18 /* oper can local OP/CLEARMODE */
-#define PRIV_SET               19 /* oper can SET */
-#define PRIV_WHOX              20 /* oper can use /who x */
-#define PRIV_BADCHAN           21 /* oper can BADCHAN */
-#define PRIV_LOCAL_BADCHAN     22 /* oper can local BADCHAN */
-#define PRIV_SEE_CHAN          23 /* oper can see in secret chans */
-
-#define PRIV_PROPAGATE         24 /* propagate oper status */
-#define PRIV_DISPLAY           25 /* "Is an oper" displayed */
-#define PRIV_SEE_OPERS         26 /* display hidden opers */
+enum Priv {
+  PRIV_CHAN_LIMIT,     /* no channel limit on oper */
+  PRIV_MODE_LCHAN,     /* oper can mode local chans */
+  PRIV_WALK_LCHAN,     /* oper can walk thru local modes */
+  PRIV_DEOP_LCHAN,     /* no deop oper on local chans */
+  PRIV_SHOW_INVIS,     /* show local invisible users */
+  PRIV_SHOW_ALL_INVIS, /* show all invisible users */
+  PRIV_UNLIMIT_QUERY,  /* unlimit who queries */
+
+  PRIV_KILL,           /* oper can KILL */
+  PRIV_LOCAL_KILL,     /* oper can local KILL */
+  PRIV_REHASH,         /* oper can REHASH */
+  PRIV_RESTART,                /* oper can RESTART */
+  PRIV_DIE,            /* oper can DIE */
+  PRIV_GLINE,          /* oper can GLINE */
+  PRIV_LOCAL_GLINE,    /* oper can local GLINE */
+  PRIV_JUPE,           /* oper can JUPE */
+  PRIV_LOCAL_JUPE,     /* oper can local JUPE */
+  PRIV_OPMODE,         /* oper can OP/CLEARMODE */
+  PRIV_LOCAL_OPMODE,   /* oper can local OP/CLEARMODE */
+  PRIV_SET,            /* oper can SET */
+  PRIV_WHOX,           /* oper can use /who x */
+  PRIV_BADCHAN,                /* oper can BADCHAN */
+  PRIV_LOCAL_BADCHAN,  /* oper can local BADCHAN */
+  PRIV_SEE_CHAN,       /* oper can see in secret chans */
+
+  PRIV_PROPAGATE,      /* propagate oper status */
+  PRIV_DISPLAY,                /* "Is an oper" displayed */
+  PRIV_SEE_OPERS,      /* display hidden opers */
 
-#define PRIV_WIDE_GLINE                27 /* oper can set wider G-lines */
+  PRIV_WIDE_GLINE,     /* oper can set wider G-lines */
 
-#define PRIV_FORCE_OPMODE      28 /* oper can override a Q-line */
-#define PRIV_FORCE_LOCAL_OPMODE        29 /* oper can override a local channel Q-line 
*/
+  PRIV_FORCE_OPMODE,   /* oper can override a Q-line */
+  PRIV_FORCE_LOCAL_OPMODE,/* oper can override a local channel Q-line */
 
-#define PRIV_LAST_PRIV         29 /* must be the same as the last priv */
+  PRIV_LAST_PRIV       /* must be the same as the last priv */
+};
 
 #define _PRIV_NBITS            (8 * sizeof(unsigned long))
 
@@ -108,7 +110,7 @@
 #define _PRIV_BIT(priv)                (1 << ((priv) % _PRIV_NBITS))
 
 struct Privs {
-  unsigned long priv_mask[(PRIV_LAST_PRIV / _PRIV_NBITS) + 1];
+  unsigned long priv_mask[(PRIV_LAST_PRIV + _PRIV_NBITS - 1) / _PRIV_NBITS];
 };
 
 enum Flag {
Index: ircu2.10/include/whocmds.h
diff -u ircu2.10/include/whocmds.h:1.6.2.1 ircu2.10/include/whocmds.h:1.6.2.1.4.1
--- ircu2.10/include/whocmds.h:1.6.2.1  Sat Sep 14 13:44:32 2002
+++ ircu2.10/include/whocmds.h  Sat Nov 23 11:45:50 2002
@@ -1,7 +1,7 @@
 /*
  * whocmds.h
  *
- * $Id: whocmds.h,v 1.6.2.1 2002/09/14 20:44:32 kev Exp $
+ * $Id: whocmds.h,v 1.6.2.1.4.1 2002/11/23 19:45:50 klmitch Exp $
  */
 #ifndef INCLUDED_whocmds_h
 #define INCLUDED_whocmds_h
@@ -42,7 +42,7 @@
 
 #define IS_VISIBLE_USER(s,ac) ((s==ac) || (!IsInvisible(ac)))
 
-#define SEE_LUSER(s, ac, b) (IS_VISIBLE_USER(s, ac) || ((b & WHOSELECT_EXTRA) && 
MyConnect(ac) && HasPriv((s), PRIV_SHOW_INVIS | PRIV_SHOW_ALL_INVIS)))
+#define SEE_LUSER(s, ac, b) (IS_VISIBLE_USER(s, ac) || ((b & WHOSELECT_EXTRA) && 
+MyConnect(ac) && (HasPriv((s), PRIV_SHOW_INVIS) || HasPriv((s), 
+PRIV_SHOW_ALL_INVIS))))
 
 #define SEE_USER(s, ac, b) (SEE_LUSER(s, ac, b) || ((b & WHOSELECT_EXTRA) && 
HasPriv((s), PRIV_SHOW_ALL_INVIS)))
 
Index: ircu2.10/ircd/client.c
diff -u ircu2.10/ircd/client.c:1.15.2.3.8.1 ircu2.10/ircd/client.c:1.15.2.3.8.2
--- ircu2.10/ircd/client.c:1.15.2.3.8.1 Sat Nov 23 11:05:08 2002
+++ ircu2.10/ircd/client.c      Sat Nov 23 11:45:50 2002
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: client.c,v 1.15.2.3.8.1 2002/11/23 19:05:08 klmitch Exp $
+ * $Id: client.c,v 1.15.2.3.8.2 2002/11/23 19:45:50 klmitch Exp $
  */
 #include "config.h"
 
@@ -102,7 +102,7 @@
 }
 
 static struct {
-  unsigned int priv;
+  enum Priv priv;
   enum Feature feat;
   enum {
     FEATFLAG_DISABLES_PRIV,
@@ -163,7 +163,7 @@
   { PRIV_SEE_CHAN, FEAT_LOCOP_SEE_IN_SECRET_CHANNELS, FEATFLAG_LOCAL_OPERS },
   { PRIV_WIDE_GLINE, FEAT_LOCOP_WIDE_GLINE, FEATFLAG_LOCAL_OPERS },
 
-  { 0, FEAT_LAST_F, 0 }
+  { PRIV_LAST_PRIV, FEAT_LAST_F, 0 }
 };
 
 /* client_set_privs(struct Client* client)
@@ -191,7 +191,7 @@
 
   /* This sequence is temporary until the .conf is carefully rewritten */
 
-  for (i = 0; feattab[i].priv; i++) {
+  for (i = 0; feattab[i].priv != PRIV_LAST_PRIV; i++) {
     if (feattab[i].flag == FEATFLAG_ENABLES_PRIV) {
       if (!feature_bool(feattab[i].feat))
        PrivSet(&antiprivs, feattab[i].priv);
Index: ircu2.10/ircd/s_bsd.c
diff -u ircu2.10/ircd/s_bsd.c:1.45.2.11.8.1 ircu2.10/ircd/s_bsd.c:1.45.2.11.8.2
--- ircu2.10/ircd/s_bsd.c:1.45.2.11.8.1 Sat Nov 23 11:05:09 2002
+++ ircu2.10/ircd/s_bsd.c       Sat Nov 23 11:45:50 2002
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: s_bsd.c,v 1.45.2.11.8.1 2002/11/23 19:05:09 klmitch Exp $
+ * $Id: s_bsd.c,v 1.45.2.11.8.2 2002/11/23 19:45:50 klmitch Exp $
  */
 #include "config.h"
 
@@ -356,7 +356,7 @@
 
   switch (os_sendv_nonb(cli_fd(cptr), buf, &bytes_count, &bytes_written)) {
   case IO_SUCCESS:
-    SetFlag(cptr, FLAG_BLOCKED);
+    ClrFlag(cptr, FLAG_BLOCKED);
 
     cli_sendB(cptr) += bytes_written;
     cli_sendB(&me)  += bytes_written;
----------------------- End of diff -----------------------

Reply via email to