Home | History | Annotate | Download | only in src
      1 #include <unistd.h>
      2 #include <sys/types.h>
      3 #include <fcntl.h>
      4 #include <stdlib.h>
      5 #include <errno.h>
      6 #include <string.h>
      7 #include "selinux_internal.h"
      8 #include "policy.h"
      9 #include <stdio.h>
     10 #include <limits.h>
     11 
     12 int security_disable(void)
     13 {
     14 	int fd, ret;
     15 	char path[PATH_MAX];
     16 	char buf[20];
     17 
     18 	if (!selinux_mnt) {
     19 		errno = ENOENT;
     20 		return -1;
     21 	}
     22 
     23 	snprintf(path, sizeof path, "%s/disable", selinux_mnt);
     24 	fd = open(path, O_WRONLY | O_CLOEXEC);
     25 	if (fd < 0)
     26 		return -1;
     27 
     28 	buf[0] = '1';
     29 	buf[1] = '\0';
     30 	ret = write(fd, buf, strlen(buf));
     31 	close(fd);
     32 	if (ret < 0)
     33 		return -1;
     34 
     35 	return 0;
     36 }
     37 
     38 hidden_def(security_disable)
     39