Bryan Drewery 22 лет назад
Родитель
Сommit
97dd285dff
4 измененных файлов с 13 добавлено и 69 удалено
  1. 1 1
      src/dcc.c
  2. 7 55
      src/debug.c
  3. 1 2
      src/main.c
  4. 4 11
      src/shell.c

+ 1 - 1
src/dcc.c

@@ -240,7 +240,7 @@ static void greet_new_bot(int idx)
   else
     sysname = un.sysname;
 
-  dprintf(idx, "v 1001500 %d %s <%s> %d %li %s\n", HANDLEN, ver, "-", localhub, buildts, egg_version);
+  dprintf(idx, "v 1001500 %d Wraith %s <%s> %d %li %s\n", HANDLEN, egg_version, "-", localhub, buildts, egg_version);
 /* FIXME: remove after 1.1.8 */
   dprintf(idx, "vs %s\n", sysname);
   dprintf(idx, "bts %lu\n", buildts);

+ 7 - 55
src/debug.c

@@ -103,58 +103,16 @@ void sdprintf (char *format, ...)
 
 #ifdef DEBUG_CONTEXT
 
-static int      nested_debug = 0;
+#define CX(ptr) cx_file[ptr] && cx_file[ptr][0] ? cx_file[ptr] : "", cx_line[ptr], cx_note[ptr] && cx_note[ptr][0] ? cx_note[ptr] : ""
 
-void write_debug()
+static void write_debug()
 {
   int x;
   char s[25] = "", tmpout[150] = "", buf[DIRMAX] = "";
   int y;
 
-  if (nested_debug) {
-    /* Yoicks, if we have this there's serious trouble!
-     * All of these are pretty reliable, so we'll try these.
-     *
-     * NOTE: dont try and display context-notes in here, it's
-     *       _not_ safe <cybah>
-     */
-    sprintf(buf, "%sDEBUG.DEBUG", tempdir);
-    x = creat(buf, 0600);
-    setsock(x, SOCK_NONSOCK);
-    if (x >= 0) {
-      strncpyz(s, ctime(&now), sizeof s);
-      dprintf(-x, "Debug (%s) written %s\n", ver, s);
-      dprintf(-x, "Context: ");
-      cx_ptr = cx_ptr & 15;
-      for (y = ((cx_ptr + 1) & 15); y != cx_ptr; y = ((y + 1) & 15))
-        dprintf(-x, "%s/%d,\n         ", cx_file[y], cx_line[y]);
-      dprintf(-x, "%s/%d\n\n", cx_file[y], cx_line[y]);
-      killsock(x);
-      close(x);
-    }
-#ifndef CYGWIN_HACKS
-    {
-      /* Use this lame method because shell_exec() or mail() may have caused another segfault :o */
-      char buff[255] = "";
-
-      egg_snprintf(buff, sizeof(buff), "cat << EOFF >> %sbleh\nNDEBUG from: %s\n`date`\n`w`\n---\n`who`\n---\n`ls -al`\n---\n`ps ux`\n---\n`uname -a`\n---\n`id`\n---\n`cat %s`\nEOFF", tempdir, origbotname, buf);
-      system(buff);
-      egg_snprintf(buff, sizeof(buff), "cat %sbleh |mail wraith@shatow.net", tempdir);
-      system(buff);
-      unlink("bleh");
-    }
-#endif /* !CYGWIN_HACKS */
-    unlink(buf);
-    exit(1);                    /* Dont even try & tell people about, that may
-                                   have caused the fault last time. */
-  } else {
-    nested_debug = 1;
-  }
-
   egg_snprintf(tmpout, sizeof tmpout, "* Last 3 contexts: %s/%d [%s], %s/%d [%s], %s/%d [%s]",
-                                  cx_file[cx_ptr-2], cx_line[cx_ptr-2], cx_note[cx_ptr-2][0] ? cx_note[cx_ptr-2] : "",
-                                  cx_file[cx_ptr-1], cx_line[cx_ptr-1], cx_note[cx_ptr-1][0] ? cx_note[cx_ptr-1] : "",
-                                  cx_file[cx_ptr], cx_line[cx_ptr], cx_note[cx_ptr][0] ? cx_note[cx_ptr] : "");
+                                  CX(cx_ptr - 2), CX(cx_ptr - 1), CX(cx_ptr));
   putlog(LOG_MISC, "*", "%s", tmpout);
   printf("%s\n", tmpout);
   sprintf(buf, "%sDEBUG", tempdir);
@@ -174,10 +132,8 @@ void write_debug()
     dprintf(-x, "Context: ");
     cx_ptr = cx_ptr & 15;
     for (y = ((cx_ptr + 1) & 15); y != cx_ptr; y = ((y + 1) & 15))
-      dprintf(-x, "%s/%d, [%s]\n         ", cx_file[y], cx_line[y],
-              (cx_note[y][0]) ? cx_note[y] : "");
-    dprintf(-x, "%s/%d [%s]\n\n", cx_file[cx_ptr], cx_line[cx_ptr],
-            (cx_note[cx_ptr][0]) ? cx_note[cx_ptr] : "");
+      dprintf(-x, "%s/%d, [%s]\n         ", CX(y));
+    dprintf(-x, "%s/%d [%s]\n\n", CX(cx_ptr));
     tell_dcc(-x);
     dprintf(-x, "\n");
     tell_netdebug(-x);
@@ -277,14 +233,10 @@ stackdump(int idx)
   sleep(1);
 };
 
-static int nested_segv = 0;
 static void got_segv(int z)
 {
-  if (nested_segv)
-    signal(SIGSEGV, SIG_DFL);
-  else
-    nested_segv++;
-  stackdump(0);
+  signal(SIGSEGV, SIG_DFL);
+  /* stackdump(0); */
 #ifdef DEBUG_CONTEXT
   write_debug();
 #endif

+ 1 - 2
src/main.c

@@ -831,8 +831,6 @@ int main(int argc, char **argv)
     pid_t pid = 0;
   
     pid = do_fork();
-
-    writepid(conf.bot->pid_file, pid);
 /*
     printf("  |- %-10s (%d)\n", conf.bot->nick, pid);
     if (localhub) {
@@ -858,6 +856,7 @@ int main(int argc, char **argv)
     FreeConsole();
 #endif /* CYGWIN_HACKS */
     printf("%s[%s%s%s]%s -%s- initiated\n", BOLD(-1), BOLD_END(-1), packname, BOLD(-1), BOLD_END(-1), conf.bot->nick);
+    writepid(conf.bot->pid_file, getpid());
   }
 
   /* Terminal emulating dcc chat */

+ 4 - 11
src/shell.c

@@ -11,6 +11,7 @@
 
 #include "common.h"
 #include "shell.h"
+#include "chanprog.h"
 #include "cfg.h"
 #include "settings.h"
 #include "userrec.h"
@@ -77,12 +78,8 @@ int clear_tmp()
 #ifdef LEAF
 void check_mypid()
 { 
-  if (can_stat(conf.bot->pid_file) && (getpid() != checkpid(conf.bot->nick, NULL))) {
-    fatal(STR("getpid() does not match pid in file. Possible cloned process, exiting.."), 1);
-    nuke_server("Cloned Process...");
-    botnet_send_bye();
-    exit(1);
-  }
+  if (can_stat(conf.bot->pid_file) && (getpid() != checkpid(conf.bot->nick, NULL)))
+    fatal(STR("getpid() does not match pid in file. Possible cloned process, exiting.."), 0);
 }
 #endif /* LEAF */
 
@@ -718,11 +715,7 @@ int email(char *subject, char *msg, int who)
   if ((f = popen(run, "w"))) {
     if (sendmail) {
       fprintf(f, "To: %s\n", addrs);
-      fprintf(f, "From: %s@%s\n", 
-                                  conffile.bots ? 
-                                  (conffile.bots->nick ? conffile.bots->nick : 
-                                  (conffile.username ? conffile.username : "WRAITH")) 
-                                  : "WRAITH", un.nodename);
+      fprintf(f, "From: %s@%s\n", origbotname[0] ? origbotname : (conf.username ? conf.username : "WRAITH"), un.nodename);
       fprintf(f, "Subject: %s\n", subject);
       fprintf(f, "Content-Type: text/plain\n");
     }