chiark / gitweb /
Bring bootchart code in line with CODING_STYLE
[elogind.git] / src / udev / udev-node.c
index 187e24e5b6f988ab66aa6258a4c9d73559367c72..0429c35ff7fc1a2b1a0a9e7f8d053e5356995d90 100644 (file)
 #include <sys/time.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#ifdef HAVE_XATTR
-#include <attr/xattr.h>
-#endif
 
 #include "udev.h"
+#include "smack-util.h"
 
 static int node_symlink(struct udev_device *dev, const char *node, const char *slink)
 {
@@ -284,9 +282,7 @@ static int node_permissions_apply(struct udev_device *dev, bool apply,
 
         if (apply) {
                 bool selinux = false;
-#ifdef HAVE_SMACK
                 bool smack = false;
-#endif
 
                 if ((stats.st_mode & 0777) != (mode & 0777) || stats.st_uid != uid || stats.st_gid != gid) {
                         log_debug("set permissions %s, %#o, uid=%u, gid=%u\n", devnode, mode, uid, gid);
@@ -310,14 +306,12 @@ static int node_permissions_apply(struct udev_device *dev, bool apply,
                                 else
                                         log_debug("SECLABEL: set SELinux label '%s'", label);
 
-#ifdef HAVE_SMACK
                         } else if (streq(name, "smack")) {
                                 smack = true;
-                                if (lsetxattr(devnode, "security.SMACK64", label, strlen(label), 0) < 0)
+                                if (smack_label_path(devnode, label) < 0)
                                         log_error("SECLABEL: failed to set SMACK label '%s'", label);
                                 else
                                         log_debug("SECLABEL: set SMACK label '%s'", label);
-#endif
 
                         } else
                                 log_error("SECLABEL: unknown subsystem, ignoring '%s'='%s'", name, label);
@@ -326,10 +320,8 @@ static int node_permissions_apply(struct udev_device *dev, bool apply,
                 /* set the defaults */
                 if (!selinux)
                         label_fix(devnode, true, false);
-#ifdef HAVE_SMACK
                 if (!smack)
-                        lremovexattr(devnode, "security.SMACK64");
-#endif
+                        smack_label_path(devnode, NULL);
         }
 
         /* always update timestamp when we re-use the node, like on media change events */