Skip to content

Commit

Permalink
Only use prctl if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
ssm committed Oct 15, 2012
1 parent 8fed994 commit c58b300
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions security.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
*/
#include <sys/utsname.h>
#include "cpm.h"
#if defined(HAVE_SYS_PRCTL_H)
#include <sys/ptrace.h>
#include <sys/prctl.h>
#endif
#include <sys/types.h>
#include <sys/wait.h>
#include <regex.h>
Expand Down Expand Up @@ -510,11 +512,13 @@ int initSecurity(int* max_mem_lock, int* memory_safe, int* ptrace_safe,
}

if (p == 0) {
#if defined(HAVE_SYS_PRCTL_H)
// makes the child unattachable
if (prctl(PR_SET_DUMPABLE, 0, 0, 0, 0) != 0) {
fprintf(stderr, "Can not set child non dumpable\n");
_exit(1);
}
#endif

if (ptrace(PT_ATTACH, p0, 0, 0) != 0) {
// someone is already attached to us; shoot the parent in the head
Expand Down

0 comments on commit c58b300

Please sign in to comment.