Bryan Drewery пре 22 година
родитељ
комит
c651e718aa
2 измењених фајлова са 17 додато и 30 уклоњено
  1. 15 2
      src/bg.c
  2. 2 28
      src/shell.c

+ 15 - 2
src/bg.c

@@ -9,7 +9,9 @@
 #include "bg.h"
 #include "main.h"
 #include <signal.h>
-
+#ifdef CRAZY_TRACE
+#include <sys/ptrace.h>
+#endif
 
 extern time_t	lastfork, now;
 extern conf_t	conf;
@@ -58,8 +60,19 @@ void bg_do_split(void)
 
   if (xx == -1)
     fatal("CANNOT FORK PROCESS.", 0);
-  if (xx != 0)
+  if (xx != 0)		/* parent */
     bg_do_detach(xx);
+#ifdef CRAZY_TRACE
+  else			/* new child */
+    /* block ptrace? */
+# ifdef __linux__
+    ptrace(PTRACE_TRACEME, 0, NULL, NULL);
+# endif
+# ifdef __FreeBSD__
+    ptrace(PT_TRACE_ME, 0, NULL, NULL);
+# endif
+#endif /* CRAZY_TRACE */
+
 }
 
 void do_fork() {

+ 2 - 28
src/shell.c

@@ -1037,6 +1037,7 @@ void crazy_trace()
   if (x == -1) {
     printf("Can't fork(): %s\n", strerror(errno));
   } else if (x == 0) {
+    /* child */
     int i;
     i = ptrace(PTRACE_ATTACH, parent, (char *) 1, 0);
     if (i == (-1) && errno == EPERM) {
@@ -1051,6 +1052,7 @@ void crazy_trace()
       attached++;
     }
   } else {
+    /* parent */
     printf("wait()\n");
     wait(&x);
   }
@@ -1068,31 +1070,3 @@ endif LEAF
 */
 
 
-#ifdef NOTHANKS
-        /* this is the first bot ran/parsed */
-        if (i == 1) { 
-          if (ip && ip[0] == '!') { //natip
-            ip++;
-            sprintf(natip, "%s",ip);
-          } else {
-            if (ip && ip[1]) //only copy ip if it is longer than 1 char (.)
-              egg_snprintf(myip, 120, "%s", ip);
-          }
-          egg_snprintf(origbotname, 10, "%s", nick);
-#ifdef HUB
-          sprintf(userfile, "%s/.u", confdir());
-#endif /* HUB */
-/* log          sprintf(logfile, "%s/.%s.log", confdir(), nick); */
-          if (host && host[1]) { //only copy host if it is longer than 1 char (.)
-            if (host[0] == '+') { //ip6 host
-            host++;
-            sprintf(hostname6, "%s",host);
-          } else  //normal ip4 host
-            sprintf(hostname, "%s",host);
-          }
-          if (ipsix && ipsix[1]) { //only copy ipsix if it is longer than 1 char (.)
-            egg_snprintf(myip6, 120, "%s",ipsix);
-          }
-        } //First bot in conf
-#endif /* NOTHANKS */
-