about summary refs log tree commit diff homepage
path: root/test/Runtime/POSIX/SELinux/SELinux.c
blob: d3a73e724002f09cb973b0d2d052bfc0590be93f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* Very basic test, as right now SELinux support is extremely basic */
// RUN: %llvmgcc %s -emit-llvm %O0opt -c -o %t1.bc
// RUN: rm -rf %t.klee-out
// RUN: %klee --output-dir=%t.klee-out --posix-runtime --exit-on-error %t1.bc --sym-arg 2 > %t.log
// XFAIL: no-selinux

#include <selinux/selinux.h>
#include <stdio.h>
#include <assert.h>

int main(int argc, char** argv) {

  security_context_t con;

  assert(argc == 2);

  int selinux = is_selinux_enabled();
  printf("selinux enabled = %d\n", selinux);
  
  if (setfscreatecon(argv[1]) < 0)
    printf("Error: set\n");
  else printf("Success: set\n");
  
  if (getfscreatecon(&con) < 0)
    printf("Error: get\n");
  else printf("Success: get\n");

  printf("create_con = %s\n", con);

  return 0;
}