/* $Id: mac.c,v 2.4 2012/08/30 16:05:46 ksb Exp $ * Test program to see if the local library supports Mandatory Access Control * calls. This doesn't mean that the kernel supports them at run-time. * You may have to compile a new kernel to actually use them. If you * run the program it fails if the present kernel doesn't include the MAC * option. --ksb * $Compile: ${cc:-gcc} -Wall -g %f -o %F * $Compile(USE_GET_PROC): ${cc:-gcc} -D%s -Wall -g %f -o %F * $Check: %b -mCompile %f && ./%F >/dev/null * $Fail: ${false:-false} */ #include #include #include #include #include #include #include int main(int argc, char **argv) { #if USE_GET_PROC auto mac_t macMe; auto char *pcOut; if (0 != mac_prepare_process_label(& macMe)) { fprintf(stderr, "mac prep proc label: %s\n", strerror(errno)); exit(EX_OSERR); } if (-1 == mac_get_proc(macMe)) { fprintf(stderr, "mac get proc: %s\n", strerror(errno)); exit(EX_UNAVAILABLE); } if (-1 == mac_to_text(macMe, &pcOut)) { fprintf(stderr, "mac to text: %s\n", strerror(errno)); exit(EX_SOFTWARE); } printf("my mac_proc = \"%s\"\n", pcOut); #else if (1 != mac_is_present((const char *)0)) { exit(EX_UNAVAILABLE); } #endif exit(EX_OK); }