[cvslog] [CVS] Module eggdrop1.6: Change committed

cvs at eggheads.org cvs at eggheads.org
Thu Nov 26 03:32:38 CST 2009


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.6
Commit time: 2009-11-26 09:32:38 UTC
Committer  : Rumen Stoyanov <pseudo at egg6.net>

Modified files:
     doc/Changes1.6 help/cmds1.help src/cmds.c src/modules.c
     src/patch.h src/proto.h src/tcluser.c src/userrec.c src/users.c
     src/mod/module.h src/mod/console.mod/console.c

Log message:

Moved console flags validation from cmd_console() to a separate function check_conflags().

Added calls to check_dcc_attrs() / check_dcc_chanattrs in tcl_chattr() to make the behaviour consistent between all chattr functions.

Added calls to check_conflags() in check_dcc_attrs/check_dcc_chanattrs() and chon_console() in order to ensure users will not retain privileged console flags if their access gets downgraded.
Fixes Bugzilla Bug # 133 ".chattr / .console bug"
Found by: DarkReap1 / Patch by: pseudo

---------------------- diff included ----------------------
Index: eggdrop1.6/doc/Changes1.6
diff -u eggdrop1.6/doc/Changes1.6:1.48 eggdrop1.6/doc/Changes1.6:1.49
--- eggdrop1.6/doc/Changes1.6:1.48	Mon Nov 23 03:42:01 2009
+++ eggdrop1.6/doc/Changes1.6	Thu Nov 26 03:32:27 2009
@@ -1,4 +1,4 @@
-$Id: Changes1.6,v 1.48 2009/11/23 09:42:01 pseudo Exp $
+$Id: Changes1.6,v 1.49 2009/11/26 09:32:27 pseudo Exp $
 
 Eggdrop Changes (since version 1.6.0)
 
@@ -6,6 +6,16 @@
 
 1.6.20 (CVS):
 
+  - Moved console flags validation from cmd_console() to a separate function
+    check_conflags().
+  - Added calls to check_dcc_attrs() / check_dcc_chanattrs in tcl_chattr()
+    to make the behaviour consistent between all chattr functions.
+  - Added calls to check_conflags() in check_dcc_attrs/check_dcc_chanattrs()
+    and chon_console() in order to ensure users will not retain privileged
+    console flags if their access gets downgraded.
+    Fixes Bugzilla Bug # 133 ".chattr / .console bug"
+    Found by: DarkReap1 / Patch by: pseudo
+
   - Introduced new config variable allow-ps to allow chanmode optionally
     enforce both +ps at the same time.
     Fixes Bugzilla Bug # 414  "channel modes +s and +p on ts5 network" 
Index: eggdrop1.6/help/cmds1.help
diff -u eggdrop1.6/help/cmds1.help:1.21 eggdrop1.6/help/cmds1.help:1.22
--- eggdrop1.6/help/cmds1.help:1.21	Sat Nov  1 14:41:10 2008
+++ eggdrop1.6/help/cmds1.help	Thu Nov 26 03:32:27 2009
@@ -244,6 +244,7 @@
      %bc%b  commands
      %bo%b  misc info, errors, etc (IMPORTANT STUFF)
      %bw%b  wallops (make sure the bot sets +w in init-server)
+     %bx%b  file transfers and file-area commands
 
 %{+n}
    Owners only (these have to be enabled in the config file via "set raw-log"):
Index: eggdrop1.6/src/cmds.c
diff -u eggdrop1.6/src/cmds.c:1.121 eggdrop1.6/src/cmds.c:1.122
--- eggdrop1.6/src/cmds.c:1.121	Sun Nov 15 07:10:34 2009
+++ eggdrop1.6/src/cmds.c	Thu Nov 26 03:32:27 2009
@@ -3,7 +3,7 @@
  *   commands from a user via dcc
  *   (split in 2, this portion contains no-irc commands)
  *
- * $Id: cmds.c,v 1.121 2009/11/15 13:10:34 pseudo Exp $
+ * $Id: cmds.c,v 1.122 2009/11/26 09:32:27 pseudo Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -646,7 +646,7 @@
 static void cmd_console(struct userrec *u, int idx, char *par)
 {
   char *nick, s[2], s1[512];
-  int dest = 0, i, ok = 0, pls, md;
+  int dest = 0, i, ok = 0, pls;
   struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
   module_entry *me;
 
@@ -694,9 +694,8 @@
     }
     strncpyz(dcc[dest].u.chat->con_chan, nick, 81);
     nick[0] = 0;
-    if ((dest == idx) && !glob_master(fr) && !chan_master(fr))
-      /* Consoling to another channel for self */
-      dcc[dest].u.chat->con_flags &= ~(LOG_MISC | LOG_CMDS | LOG_WALL);
+    if (dest != idx)
+      get_user_flagrec(dcc[dest].user, &fr, dcc[dest].u.chat->con_chan);
   }
   if (!nick[0])
     nick = newsplit(&par);
@@ -712,28 +711,15 @@
       else {
         s[0] = *nick;
         s[1] = 0;
-        md = logmodes(s);
-        if ((dest == idx) && !glob_master(fr) && pls) {
-          if (chan_master(fr))
-            md &= ~(LOG_FILES | LOG_LEV1 | LOG_LEV2 | LOG_LEV3 |
-                    LOG_LEV4 | LOG_LEV5 | LOG_LEV6 | LOG_LEV7 |
-                    LOG_LEV8 | LOG_DEBUG);
-          else
-            md &= ~(LOG_MISC | LOG_CMDS | LOG_FILES | LOG_LEV1 |
-                    LOG_LEV2 | LOG_LEV3 | LOG_LEV4 | LOG_LEV5 |
-                    LOG_LEV6 | LOG_LEV7 | LOG_LEV8 | LOG_WALL | LOG_DEBUG);
-        }
-        if (!glob_owner(fr) && pls)
-          md &= ~(LOG_RAW | LOG_SRVOUT | LOG_BOTNET | LOG_BOTSHARE);
-        if (!glob_botmast(fr) && pls)
-          md &= ~LOG_BOTS;
         if (pls)
-          dcc[dest].u.chat->con_flags |= md;
+          dcc[dest].u.chat->con_flags |= logmodes(s);
         else
-          dcc[dest].u.chat->con_flags &= ~md;
+          dcc[dest].u.chat->con_flags &= ~logmodes(s);
       }
     }
   }
+  dcc[dest].u.chat->con_flags = check_conflags(&fr,
+                                               dcc[dest].u.chat->con_flags);
   putlog(LOG_CMDS, "*", "#%s# console %s", dcc[idx].nick, s1);
   if (dest == idx) {
     dprintf(idx, "Set your console to %s: %s (%s).\n",
@@ -1269,6 +1255,7 @@
 int check_dcc_attrs(struct userrec *u, int oatr)
 {
   int i, stat;
+  struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
 
   if (!u)
     return 0;
@@ -1286,16 +1273,6 @@
         botnet_send_join_idx(i, -1);
       }
       if ((oatr & USER_MASTER) && !(u->flags & USER_MASTER)) {
-        struct flag_record fr = { FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0 };
-
-        dcc[i].u.chat->con_flags &= ~(LOG_MISC | LOG_CMDS | LOG_RAW |
-                                      LOG_FILES | LOG_LEV1 | LOG_LEV2 |
-                                      LOG_LEV3 | LOG_LEV4 | LOG_LEV5 |
-                                      LOG_LEV6 | LOG_LEV7 | LOG_LEV8 |
-                                      LOG_WALL | LOG_DEBUG);
-        get_user_flagrec(u, &fr, NULL);
-        if (!chan_master(fr))
-          dcc[i].u.chat->con_flags |= (LOG_MISC | LOG_CMDS);
         dprintf(i, "*** POOF! ***\n");
         dprintf(i, "You are no longer a master on this bot.\n");
       }
@@ -1320,6 +1297,9 @@
         dprintf(i, "@@@ POOF! @@@\n");
         dprintf(i, "You are no longer an owner of this bot.\n");
       }
+      get_user_flagrec(u, &fr, dcc[i].u.chat->con_chan);
+      dcc[i].u.chat->con_flags = check_conflags(&fr,
+                                                dcc[i].u.chat->con_flags);
       if ((stat & STAT_PARTY) && (u->flags & USER_OP))
         stat &= ~STAT_PARTY;
       if (!(stat & STAT_PARTY) && !(u->flags & USER_OP) &&
@@ -1379,7 +1359,8 @@
 int check_dcc_chanattrs(struct userrec *u, char *chname, int chflags,
                         int ochatr)
 {
-  int i, found = 0, atr = u ? u->flags : 0;
+  int i, found = 0;
+  struct flag_record fr = { FR_CHAN, 0, 0, 0, 0, 0 };
   struct chanset_t *chan;
 
   if (!u)
@@ -1392,19 +1373,11 @@
           (ochatr & (USER_OP | USER_MASTER | USER_OWNER))))
         botnet_send_join_idx(i, -1);
       if ((ochatr & USER_MASTER) && !(chflags & USER_MASTER)) {
-        if (!(atr & USER_MASTER))
-          dcc[i].u.chat->con_flags &= ~(LOG_MISC | LOG_CMDS);
         dprintf(i, "*** POOF! ***\n");
         dprintf(i, "You are no longer a master on %s.\n", chname);
       }
       if (!(ochatr & USER_MASTER) && (chflags & USER_MASTER)) {
         dcc[i].u.chat->con_flags |= conmask;
-        if (!(atr & USER_MASTER))
-          dcc[i].u.chat->con_flags &= ~(LOG_LEV1 | LOG_LEV2 | LOG_LEV3 |
-                                        LOG_LEV4 | LOG_LEV5 | LOG_LEV6 |
-                                        LOG_LEV7 | LOG_LEV8 | LOG_RAW |
-                                        LOG_DEBUG | LOG_WALL | LOG_FILES |
-                                        LOG_SRVOUT);
         dprintf(i, "*** POOF! ***\n");
         dprintf(i, "You are now a master on %s.\n", chname);
       }
@@ -1420,7 +1393,6 @@
           (!(chflags & (USER_OP | USER_MASTER | USER_OWNER)))) ||
           ((chflags & (USER_OP | USER_MASTER | USER_OWNER)) &&
           (!(ochatr & (USER_OP | USER_MASTER | USER_OWNER))))) {
-        struct flag_record fr = { FR_CHAN, 0, 0, 0, 0, 0 };
 
         for (chan = chanset; chan && !found; chan = chan->next) {
           get_user_flagrec(u, &fr, chan->dname);
@@ -1434,6 +1406,10 @@
         else
           strcpy(dcc[i].u.chat->con_chan, "*");
       }
+      fr.match = (FR_CHAN | FR_GLOBAL);
+      get_user_flagrec(u, &fr, dcc[i].u.chat->con_chan);
+      dcc[i].u.chat->con_flags = check_conflags(&fr,
+                                                dcc[i].u.chat->con_flags);
     }
   }
   return chflags;
@@ -1615,7 +1591,6 @@
   }
   if (chg && (me = module_find("irc", 0, 0))) {
     Function *func = me->funcs;
-
     (func[IRC_CHECK_THIS_USER]) (hand, 0, NULL);
   }
   if (tmpchg)
Index: eggdrop1.6/src/mod/console.mod/console.c
diff -u eggdrop1.6/src/mod/console.mod/console.c:1.35 eggdrop1.6/src/mod/console.mod/console.c:1.36
--- eggdrop1.6/src/mod/console.mod/console.c:1.35	Sat Feb 16 15:41:07 2008
+++ eggdrop1.6/src/mod/console.mod/console.c	Thu Nov 26 03:32:28 2009
@@ -3,7 +3,7 @@
  *   saved console settings based on console.tcl
  *   by cmwagner/billyjoe/D. Senso
  *
- * $Id: console.c,v 1.35 2008/02/16 21:41:07 guppy Exp $
+ * $Id: console.c,v 1.36 2009/11/26 09:32:28 pseudo Exp $
  */
 /*
  * Copyright (C) 1999 - 2008 Eggheads Development Team
@@ -244,13 +244,15 @@
 
 static int console_chon(char *handle, int idx)
 {
+  struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
   struct console_info *i = get_user(&USERENTRY_CONSOLE, dcc[idx].user);
 
   if (dcc[idx].type == &DCC_CHAT) {
     if (i) {
       if (i->channel && i->channel[0])
         strcpy(dcc[idx].u.chat->con_chan, i->channel);
-      dcc[idx].u.chat->con_flags = i->conflags;
+      get_user_flagrec(dcc[idx].user, &fr, i->channel);
+      dcc[idx].u.chat->con_flags = check_conflags(&fr, i->conflags);
       dcc[idx].u.chat->strip_flags = i->stripflags;
       if (i->echoflags)
         dcc[idx].status |= STAT_ECHO;
Index: eggdrop1.6/src/mod/module.h
diff -u eggdrop1.6/src/mod/module.h:1.88 eggdrop1.6/src/mod/module.h:1.89
--- eggdrop1.6/src/mod/module.h:1.88	Sat Oct 31 08:43:09 2009
+++ eggdrop1.6/src/mod/module.h	Thu Nov 26 03:32:28 2009
@@ -1,7 +1,7 @@
 /*
  * module.h
  *
- * $Id: module.h,v 1.88 2009/10/31 14:43:09 thommey Exp $
+ * $Id: module.h,v 1.89 2009/11/26 09:32:28 pseudo Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -478,7 +478,8 @@
 #define oatoi ((int (*) (const char *))global[291])
 /* 292 - 295 */
 #define str_isdigit ((int (*) (const char *))global[292])
-#define remove_crlf ((void (*)(char **))global[293])
+#define remove_crlf ((void (*) (char **))global[293])
+#define check_conflags ((int (*) (struct flag_record *, int))global[294])
 
 /* hostmasking */
 #define maskhost(a,b) maskaddr((a),(b),3)
Index: eggdrop1.6/src/modules.c
diff -u eggdrop1.6/src/modules.c:1.101 eggdrop1.6/src/modules.c:1.102
--- eggdrop1.6/src/modules.c:1.101	Sat Nov 21 17:12:30 2009
+++ eggdrop1.6/src/modules.c	Thu Nov 26 03:32:27 2009
@@ -4,7 +4,7 @@
  *
  * by Darrin Smith (beldin at light.iinet.net.au)
  *
- * $Id: modules.c,v 1.101 2009/11/21 23:12:30 pseudo Exp $
+ * $Id: modules.c,v 1.102 2009/11/26 09:32:27 pseudo Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -570,7 +570,8 @@
   (Function) oatoi,
   /* 292 - 295 */
   (Function) str_isdigit,
-  (Function) remove_crlf
+  (Function) remove_crlf,
+  (Function) check_conflags
 };
 
 void init_modules(void)
Index: eggdrop1.6/src/patch.h
diff -u eggdrop1.6/src/patch.h:1.1222 eggdrop1.6/src/patch.h:1.1223
--- eggdrop1.6/src/patch.h:1.1222	Mon Nov 23 03:42:01 2009
+++ eggdrop1.6/src/patch.h	Thu Nov 26 03:32:28 2009
@@ -10,7 +10,7 @@
  * statement, leave the rest of the file alone, this allows better
  * overlapping patches.
  *
- * $Id: patch.h,v 1.1222 2009/11/23 09:42:01 pseudo Exp $
+ * $Id: patch.h,v 1.1223 2009/11/26 09:32:28 pseudo Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -41,12 +41,12 @@
  *
  *
  */
-patch("1258969117");            /* current unixtime */
+patch("1259227739");            /* current unixtime */
 /*
  *
  *
  */
-patch("chanmode-ps");
+patch("checkconflags");
 /*
  *
  *
Index: eggdrop1.6/src/proto.h
diff -u eggdrop1.6/src/proto.h:1.76 eggdrop1.6/src/proto.h:1.77
--- eggdrop1.6/src/proto.h:1.76	Sat Oct 31 08:43:09 2009
+++ eggdrop1.6/src/proto.h	Thu Nov 26 03:32:28 2009
@@ -7,7 +7,7 @@
  * because they use structures in those
  * (saves including those .h files EVERY time) - Beldin
  *
- * $Id: proto.h,v 1.76 2009/10/31 14:43:09 thommey Exp $
+ * $Id: proto.h,v 1.77 2009/11/26 09:32:28 pseudo Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -302,6 +302,7 @@
 void touch_laston(struct userrec *, char *, time_t);
 void user_del_chan(char *);
 char *fixfrom(char *);
+int check_conflags(struct flag_record *fr, int md);
 
 /* users.c */
 void addignore(char *, char *, char *, time_t);
Index: eggdrop1.6/src/tcluser.c
diff -u eggdrop1.6/src/tcluser.c:1.46 eggdrop1.6/src/tcluser.c:1.47
--- eggdrop1.6/src/tcluser.c:1.46	Sun Nov 15 07:10:34 2009
+++ eggdrop1.6/src/tcluser.c	Thu Nov 26 03:32:28 2009
@@ -2,7 +2,7 @@
  * tcluser.c -- handles:
  *   Tcl stubs for the user-record-oriented commands
  *
- * $Id: tcluser.c,v 1.46 2009/11/15 13:10:34 pseudo Exp $
+ * $Id: tcluser.c,v 1.47 2009/11/26 09:32:28 pseudo Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -78,6 +78,7 @@
 
 static int tcl_chattr STDVAR
 {
+  int of, ocf = 0;
   char *chan, *chg, work[100];
   struct flag_record pls, mns, user;
   struct userrec *u;
@@ -125,6 +126,7 @@
   get_user_flagrec(u, &user, chan);
   /* Make changes */
   if (chg) {
+    of = user.global;
     pls.match = user.match;
     break_down_flags(chg, &pls, &mns);
     /* No-one can change these flags on-the-fly */
@@ -140,13 +142,18 @@
     user.udef_global = (user.udef_global | pls.udef_global)
                        & ~mns.udef_global;
     if (chan) {
+      ocf = user.chan;
       user.chan = chan_sanity_check((user.chan | pls.chan) & ~mns.chan,
                                     user.global);
       user.udef_chan = (user.udef_chan | pls.udef_chan) & ~mns.udef_chan;
+      
     }
     set_user_flagrec(u, &user, chan);
+    check_dcc_attrs(u, of);
+    if (chan)
+      check_dcc_chanattrs(u, chan, user.chan, ocf);
   }
-  user.chan &= ~BOT_SHARE; /* actually not an user flag, hide it */
+  user.chan &= ~BOT_SHARE; /* actually not a user flag, hide it */
   /* Build flag string */
   build_flags(work, &user, NULL);
   Tcl_AppendResult(irp, work, NULL);
Index: eggdrop1.6/src/userrec.c
diff -u eggdrop1.6/src/userrec.c:1.57 eggdrop1.6/src/userrec.c:1.58
--- eggdrop1.6/src/userrec.c:1.57	Sat Feb 16 15:41:05 2008
+++ eggdrop1.6/src/userrec.c	Thu Nov 26 03:32:28 2009
@@ -4,7 +4,7 @@
  *   a bunch of functions to find and change user records
  *   change and check user (and channel-specific) flags
  *
- * $Id: userrec.c,v 1.57 2008/02/16 21:41:05 guppy Exp $
+ * $Id: userrec.c,v 1.58 2009/11/26 09:32:28 pseudo Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -902,3 +902,24 @@
     }
   }
 }
+
+/* Check if the console flags specified in md are permissible according
+ * to the given flagrec. If the FR_CHAN flag is not set in fr->match,
+ * only global user flags will be considered.
+ * Returns: md with all unallowed flags masked out.
+ */
+int check_conflags(struct flag_record *fr, int md)
+{
+  if (!glob_owner(*fr))
+    md &= ~(LOG_RAW | LOG_SRVOUT | LOG_BOTNET | LOG_BOTSHARE); 
+  if (!glob_master(*fr)) {
+    md &= ~(LOG_FILES | LOG_LEV1 | LOG_LEV2 | LOG_LEV3 | LOG_LEV4 |
+            LOG_LEV5 | LOG_LEV6 | LOG_LEV7 | LOG_LEV8 | LOG_DEBUG |
+            LOG_WALL);
+    if ((fr->match & FR_CHAN) && !chan_master(*fr))
+      md &= ~(LOG_MISC | LOG_CMDS);
+  }
+  if (!glob_botmast(*fr))
+    md &= ~LOG_BOTS;
+  return md;
+}
Index: eggdrop1.6/src/users.c
diff -u eggdrop1.6/src/users.c:1.55 eggdrop1.6/src/users.c:1.56
--- eggdrop1.6/src/users.c:1.55	Mon Oct 12 08:10:32 2009
+++ eggdrop1.6/src/users.c	Thu Nov 26 03:32:28 2009
@@ -10,7 +10,7 @@
  *
  * dprintf'ized, 9nov1995
  *
- * $Id: users.c,v 1.55 2009/10/12 14:10:32 thommey Exp $
+ * $Id: users.c,v 1.56 2009/11/26 09:32:28 pseudo Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -969,7 +969,7 @@
     struct user_entry *e;
 
     if (!(u->flags & USER_BOT) && !egg_strcasecmp(u->handle, botnetnick)) {
-      putlog(LOG_MISC, "*", "(!) I have an user record, but without +b");
+      putlog(LOG_MISC, "*", "(!) I have a user record, but without +b");
       /* u->flags |= USER_BOT; */
     }
 
----------------------- End of diff -----------------------


More information about the Changes mailing list