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

* Port [3704] to 1.2.15
* Fix the bot not starting up when it is not allowed to run ptrace() (FreeBSD: security.bsd.unprivileged_proc_debug=0)



svn: 3705

Bryan Drewery 18 лет назад
Родитель
Сommit
d233a32cbf
2 измененных файлов с 4 добавлено и 2 удалено
  1. 1 0
      doc/UPDATES
  2. 3 2
      src/shell.c

+ 1 - 0
doc/UPDATES

@@ -20,6 +20,7 @@
 * Fix segfault in cmd_mmode (fixes #399)
 * Fix segfault in cmd_mmode (fixes #399)
 * Fix segfault from receiving from non-recursive dns servers. (fixes #401)
 * Fix segfault from receiving from non-recursive dns servers. (fixes #401)
 * Fix some cases where the bot would pointlessly do WHO on users instead of on the channel to resolve a desync.
 * Fix some cases where the bot would pointlessly do WHO on users instead of on the channel to resolve a desync.
+* Fix the bot not starting up when it is not allowed to run ptrace() (FreeBSD: security.bsd.unprivileged_proc_debug=0)
 
 
 1.2.14 - http://wraith.botpack.net/milestone/1.2.14
 1.2.14 - http://wraith.botpack.net/milestone/1.2.14
 * Fix another bug in shell functions. (fixes #321)
 * Fix another bug in shell functions. (fixes #321)

+ 3 - 2
src/shell.c

@@ -416,7 +416,8 @@ void check_trace(int start)
         return;
         return;
       case 0:		//child
       case 0:		//child
         i = ptrace(PT_ATTACH, parent, 0, 0);
         i = ptrace(PT_ATTACH, parent, 0, 0);
-        if (i == -1) {
+        /* EPERM is given on fbsd when security.bsd.unprivileged_proc_debug=0 */
+        if (i == -1 && errno != EPERM) {
           if (start) {
           if (start) {
             kill(parent, SIGKILL);
             kill(parent, SIGKILL);
             exit(1);
             exit(1);
@@ -1114,7 +1115,7 @@ void crazy_trace()
     /* child */
     /* child */
     int i;
     int i;
     i = ptrace(PTRACE_ATTACH, parent, (char *) 1, 0);
     i = ptrace(PTRACE_ATTACH, parent, (char *) 1, 0);
-    if (i == (-1) && errno == EPERM) {
+    if (i == -1) {
       printf("CANT PTRACE PARENT: errno: %d %s, i: %d\n", errno, strerror(errno), i);
       printf("CANT PTRACE PARENT: errno: %d %s, i: %d\n", errno, strerror(errno), i);
       waitpid(parent, &i, 0);
       waitpid(parent, &i, 0);
       kill(parent, SIGCHLD);
       kill(parent, SIGCHLD);