[systemd-commits] src/shared src/udev
Kay Sievers
kay at kemper.freedesktop.org
Wed Oct 9 08:37:22 PDT 2013
src/shared/label.c | 12 ++++++++++++
src/shared/label.h | 2 ++
src/udev/udev-node.c | 6 ++++--
3 files changed, 18 insertions(+), 2 deletions(-)
New commits:
commit 463b5dbb0d10227230468ee3adc3b50fce7d0707
Author: Kay Sievers <kay at vrfy.org>
Date: Wed Oct 9 17:31:00 2013 +0200
udev: add SECLABEL{selinux}= support
diff --git a/src/shared/label.c b/src/shared/label.c
index fde39f2..5c7cc1c 100644
--- a/src/shared/label.c
+++ b/src/shared/label.c
@@ -384,3 +384,15 @@ skipped:
#endif
return bind(fd, addr, addrlen) < 0 ? -errno : 0;
}
+
+int label_apply(const char *path, const char *label) {
+ int r = 0;
+
+#ifdef HAVE_SELINUX
+ if (!use_selinux())
+ return 0;
+
+ r = setfilecon(path, (char *)label);
+#endif
+ return r;
+}
diff --git a/src/shared/label.h b/src/shared/label.h
index 09e15e3..b190e69 100644
--- a/src/shared/label.h
+++ b/src/shared/label.h
@@ -46,6 +46,8 @@ void label_retest_selinux(void);
int label_bind(int fd, const struct sockaddr *addr, socklen_t addrlen);
+int label_apply(const char *path, const char *label);
+
int label_write_one_line_file_atomic(const char *fn, const char *line);
int label_write_env_file(const char *fname, char **l);
int label_fopen_temporary(const char *path, FILE **_f, char **_temp_path);
diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
index 74c1953..187e24e 100644
--- a/src/udev/udev-node.c
+++ b/src/udev/udev-node.c
@@ -305,8 +305,10 @@ static int node_permissions_apply(struct udev_device *dev, bool apply,
if (streq(name, "selinux")) {
selinux = true;
- /* FIXME: hook up libselinux */
- log_error("SECLABEL: failed to set selinux label '%s'", label);
+ if (label_apply(devnode, label) < 0)
+ log_error("SECLABEL: failed to set SELinux label '%s'", label);
+ else
+ log_debug("SECLABEL: set SELinux label '%s'", label);
#ifdef HAVE_SMACK
} else if (streq(name, "smack")) {
More information about the systemd-commits
mailing list