1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-06 08:26:52 +03:00
systemd/udev_selinux.c
greg@kroah.com 8481f8ce2b [PATCH] Add initial SELinux support for udev
Based on a patch from Daniel J Walsh <dwalsh@redhat.com>
2005-04-26 21:32:31 -07:00

35 lines
675 B
C

#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);
}
}
}