1 // SPDX-License-Identifier: GPL-2.0-only 2 3 #include <stdbool.h> 4 #include <stdlib.h> 5 #include <error.h> 6 #include <stdio.h> 7 8 #include "unpriv_helpers.h" 9 get_unpriv_disabled(void)10bool get_unpriv_disabled(void) 11 { 12 bool disabled; 13 char buf[2]; 14 FILE *fd; 15 16 fd = fopen("/proc/sys/" UNPRIV_SYSCTL, "r"); 17 if (fd) { 18 disabled = (fgets(buf, 2, fd) == buf && atoi(buf)); 19 fclose(fd); 20 } else { 21 perror("fopen /proc/sys/" UNPRIV_SYSCTL); 22 disabled = true; 23 } 24 25 return disabled; 26 } 27