diff options
author | greg@kroah.com <greg@kroah.com> | 2004-02-28 00:52:20 -0800 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 21:32:31 -0700 |
commit | 8481f8ce2bd2b19ebcf3cb96ac6825093f626b0f (patch) | |
tree | 9311b5e7fe1b85b1d5645d1b3dd4a4cfc0ab7737 /udev_selinux.c | |
parent | 89067448b935d580496555f257dd5512c4c39098 (diff) |
[PATCH] Add initial SELinux support for udev
Based on a patch from Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'udev_selinux.c')
-rw-r--r-- | udev_selinux.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/udev_selinux.c b/udev_selinux.c new file mode 100644 index 0000000000..3728fd0b50 --- /dev/null +++ b/udev_selinux.c @@ -0,0 +1,34 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <fcntl.h> +#include <unistd.h> +#include <errno.h> +#include <ctype.h> +#include <selinux/selinux.h> + +#include "udev.h" +#include "udev_version.h" +#include "udev_selinux.h" +#include "logging.h" + + +void selinux_add_node(char *filename) +{ + int retval; + + if (is_selinux_enabled() > 0) { + security_context_t scontext; + retval = matchpathcon(filename, 0, &scontext); + if (retval < 0) { + dbg("matchpathcon(%s) failed\n", filename); + } else { + retval=setfilecon(filename,scontext); + if (retval < 0) + dbg("setfiles %s failed with error '%s'", + filename, strerror(errno)); + free(scontext); + } + } +} + |