4 * Copyright (C) 2004 Daniel J Walsh <dwalsh@redhat.com>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation version 2 of the License.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include <selinux/selinux.h>
27 #include "../../udev_lib.h"
28 #include "../../logging.h"
31 unsigned char logname[LOGNAME_SIZE];
32 void log_message(int level, const char *format, ...)
36 va_start(args, format);
37 vsyslog(level, format, args);
42 static void selinux_add_node(char *filename)
46 if (is_selinux_enabled() > 0) {
47 security_context_t scontext;
48 retval = matchpathcon(filename, 0, &scontext);
50 dbg("matchpathcon(%s) failed\n", filename);
52 retval = setfilecon(filename,scontext);
54 dbg("setfiles %s failed with error '%s'",
55 filename, strerror(errno));
61 int main(int argc, char *argv[], char *envp[])
67 init_logging("udev_selinux");
69 action = get_action();
74 devname = get_devname();
80 if (strcmp(action, "add") == 0)
81 selinux_add_node(devname);