summaryrefslogtreecommitdiff
path: root/src/udev/smack-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/udev/smack-util.c')
-rw-r--r--src/udev/smack-util.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/udev/smack-util.c b/src/udev/smack-util.c
index 93c0d4a347..2711041c7e 100644
--- a/src/udev/smack-util.c
+++ b/src/udev/smack-util.c
@@ -40,3 +40,50 @@ bool use_smack(void) {
#endif
}
+
+int smack_label_path(const char *path, const char *label) {
+#ifdef HAVE_SMACK
+ if (!use_smack())
+ return 0;
+
+ if (label)
+ return setxattr(path, "security.SMACK64", label, strlen(label), 0);
+ else
+ return lremovexattr(path, "security.SMACK64");
+#else
+ return 0;
+#endif
+}
+
+int smack_label_fd(int fd, const char *label) {
+#ifdef HAVE_SMACK
+ if (!use_smack())
+ return 0;
+
+ return fsetxattr(fd, "security.SMACK64", label, strlen(label), 0);
+#else
+ return 0;
+#endif
+}
+
+int smack_label_ip_out_fd(int fd, const char *label) {
+#ifdef HAVE_SMACK
+ if (!use_smack())
+ return 0;
+
+ return fsetxattr(fd, "security.SMACK64IPOUT", label, strlen(label), 0);
+#else
+ return 0;
+#endif
+}
+
+int smack_label_ip_in_fd(int fd, const char *label) {
+#ifdef HAVE_SMACK
+ if (!use_smack())
+ return 0;
+
+ return fsetxattr(fd, "security.SMACK64IPIN", label, strlen(label), 0);
+#else
+ return 0;
+#endif
+}