static void assert_prerequisites() { int aslr_val = read_int_file("/proc/sys/kernel/randomize_va_space"); int ptrace_scope_val = read_int_file("/proc/sys/kernel/yama/ptrace_scope"); if (aslr_val != 0) { fatal("ASLR not disabled; randomize is %d", aslr_val); } if (ptrace_scope_val > 0) { fatal("Can't write to process memory; ptrace_scope is %d", ptrace_scope_val); } }
static int read_int_gpio_file(uint8_t gpio_pin, const char *file_name, uint8_t *value) { char path[MAX_STR_LENGTH]; uint32_t tmp; if (!create_gpio_path(path, gpio_pin, file_name)) return -1; if (read_int_file(path, &tmp) < 0) return -1; *value = tmp; return 0; }