summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@samsung.com>2013-12-19 17:05:40 +0900
committerCedric BAIL <cedric.bail@samsung.com>2013-12-19 17:11:13 +0900
commit56d9c12676a69ca600bfff52525aef55d0f39949 (patch)
tree77dbb7967b80eb7b2b2dacc002e7d25d25e7bae2 /src
parent147f088efae2885c52d6f4a71bdac9f9945f7138 (diff)
gdb: test for bad kernel behavior.
Diffstat (limited to 'src')
-rw-r--r--src/bin/e_start_main.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/bin/e_start_main.c b/src/bin/e_start_main.c
index fa28cc825..b29d35bd7 100644
--- a/src/bin/e_start_main.c
+++ b/src/bin/e_start_main.c
@@ -492,6 +492,7 @@ main(int argc, char **argv)
492 Eina_Bool done = EINA_FALSE; 492 Eina_Bool done = EINA_FALSE;
493 Eina_Bool remember_sigill = EINA_FALSE; 493 Eina_Bool remember_sigill = EINA_FALSE;
494 Eina_Bool remember_sigusr1 = EINA_FALSE; 494 Eina_Bool remember_sigusr1 = EINA_FALSE;
495 Eina_Bool bad_kernel = EINA_FALSE;
495 496
496#ifdef HAVE_SYS_PTRACE_H 497#ifdef HAVE_SYS_PTRACE_H
497 if (!really_know) 498 if (!really_know)
@@ -564,10 +565,22 @@ main(int argc, char **argv)
564 /* And call gdb if available */ 565 /* And call gdb if available */
565 r = 0; 566 r = 0;
566 567
567 if (home) 568 /* Check if patch to prevent ptrace to another process is present in the kernel. */
569 {
570 int fd;
571 char c;
572
573 fd = open("/proc/sys/kernel/yama/ptrace_scope", O_RDONLY);
574 if (fd != -1)
575 {
576 if (read(fd, &c, sizeof (c)) == sizeof (c) && c != '0')
577 bad_kernel = EINA_TRUE;
578 }
579 close(fd);
580 }
581
582 if (home && !bad_kernel)
568 { 583 {
569 struct stat st;
570
571 /* call e_sys gdb */ 584 /* call e_sys gdb */
572 snprintf(buffer, sizeof(buffer), 585 snprintf(buffer, sizeof(buffer),
573 "gdb " 586 "gdb "
@@ -588,11 +601,7 @@ main(int argc, char **argv)
588 "%s/.e-crashdump.txt", 601 "%s/.e-crashdump.txt",
589 home); 602 home);
590 603
591 /* Check the file was correctly generated (may fail on crappy kernel with ptrace 604 backtrace_str = strdup(buffer);
592 diable). In which case a manual : echo 0 > /proc/sys/kernel/yama/ptrace_scope
593 as root is necessary. */
594 if (!stat(buffer, &st))
595 backtrace_str = strdup(buffer);
596 r = WEXITSTATUS(r); 605 r = WEXITSTATUS(r);
597 } 606 }
598 607