chiark / gitweb /
[PATCH] udev* segfaults with new klibc
[elogind.git] / udev_selinux.c
1 #include <stdlib.h>
2 #include <string.h>
3 #include <stdio.h>
4 #include <fcntl.h>
5 #include <unistd.h>
6 #include <errno.h>
7 #include <ctype.h>
8 #include <selinux/selinux.h>
9
10 #include "udev.h"
11 #include "udev_version.h"
12 #include "udev_selinux.h"
13 #include "logging.h"
14
15
16 void selinux_add_node(char *filename)
17 {
18         int retval;
19
20         if (is_selinux_enabled() > 0) {
21                 security_context_t scontext;
22                 retval = matchpathcon(filename, 0, &scontext);
23                 if (retval < 0) {
24                         dbg("matchpathcon(%s) failed\n", filename);
25                 } else {
26                         retval=setfilecon(filename,scontext);
27                         if (retval < 0)
28                                 dbg("setfiles %s failed with error '%s'",
29                                     filename, strerror(errno));
30                         free(scontext);
31                 }
32         }
33 }
34