blob: dac0f5bd0f880a912e03d442346a96e905c93fbe [file] [log] [blame]
Stephen Smalleyf0740362012-01-04 12:30:47 -05001#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
12int 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);
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
38hidden_def(security_disable)