diff options
author | Kay Sievers <kay@vrfy.org> | 2012-04-17 16:05:03 +0200 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2012-04-17 16:05:28 +0200 |
commit | e9a5ef7cddcfcdb29b5aef3896931132b6fd5165 (patch) | |
tree | ed40d27a53fcbee52aedad4531860aec6edb5c55 /src/udev | |
parent | 75e37ac5b125713c5ab6e1c4a9d62cfb62948c27 (diff) |
selinux: unify systemd and udev code
Diffstat (limited to 'src/udev')
-rw-r--r-- | src/udev/udev-node.c | 13 | ||||
-rw-r--r-- | src/udev/udev.h | 1 | ||||
-rw-r--r-- | src/udev/udevadm.c | 4 | ||||
-rw-r--r-- | src/udev/udevd.c | 12 |
4 files changed, 15 insertions, 15 deletions
diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c index 20aa7c865d..3c9846f158 100644 --- a/src/udev/udev-node.c +++ b/src/udev/udev-node.c @@ -91,7 +91,7 @@ static int node_symlink(struct udev *udev, const char *node, const char *slink) buf[len] = '\0'; if (strcmp(target, buf) == 0) { log_debug("preserve already existing symlink '%s' to '%s'\n", slink, target); - udev_selinux_lsetfilecon(udev, slink, S_IFLNK); + label_fix(slink, true); utimensat(AT_FDCWD, slink, NULL, AT_SYMLINK_NOFOLLOW); goto exit; } @@ -103,11 +103,11 @@ static int node_symlink(struct udev *udev, const char *node, const char *slink) err = mkdir_parents(slink, 0755); if (err != 0 && err != -ENOENT) break; - udev_selinux_setfscreatecon(udev, slink, S_IFLNK); + label_context_set(slink, S_IFLNK); err = symlink(target, slink); if (err != 0) err = -errno; - udev_selinux_resetfscreatecon(udev); + label_context_clear(); } while (err == -ENOENT); if (err == 0) goto exit; @@ -120,11 +120,11 @@ static int node_symlink(struct udev *udev, const char *node, const char *slink) err = mkdir_parents(slink_tmp, 0755); if (err != 0 && err != -ENOENT) break; - udev_selinux_setfscreatecon(udev, slink_tmp, S_IFLNK); + label_context_set(slink_tmp, S_IFLNK); err = symlink(target, slink_tmp); if (err != 0) err = -errno; - udev_selinux_resetfscreatecon(udev); + label_context_clear(); } while (err == -ENOENT); if (err != 0) { log_error("symlink '%s' '%s' failed: %m\n", target, slink_tmp); @@ -269,7 +269,6 @@ void udev_node_update_old_links(struct udev_device *dev, struct udev_device *dev static int node_fixup(struct udev_device *dev, mode_t mode, uid_t uid, gid_t gid) { - struct udev *udev = udev_device_get_udev(dev); const char *devnode = udev_device_get_devnode(dev); dev_t devnum = udev_device_get_devnum(dev); struct stat stats; @@ -308,7 +307,7 @@ static int node_fixup(struct udev_device *dev, mode_t mode, uid_t uid, gid_t gid * something else has set a custom context in the meantime. */ if (strcmp(udev_device_get_action(dev), "add") == 0) - udev_selinux_lsetfilecon(udev, devnode, mode); + label_fix(devnode, true); /* always update timestamp when we re-use the node, like on media change events */ utimensat(AT_FDCWD, devnode, NULL, 0); diff --git a/src/udev/udev.h b/src/udev/udev.h index e229faaa4a..aaaf632209 100644 --- a/src/udev/udev.h +++ b/src/udev/udev.h @@ -26,6 +26,7 @@ #include "libudev.h" #include "libudev-private.h" #include "util.h" +#include "label.h" struct udev_event { struct udev *udev; diff --git a/src/udev/udevadm.c b/src/udev/udevadm.c index 2b4a845d77..5217d7f9dd 100644 --- a/src/udev/udevadm.c +++ b/src/udev/udevadm.c @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) log_open(); log_parse_environment(); udev_set_log_fn(udev, udev_main_log); - udev_selinux_init(udev); + label_init("/dev"); for (;;) { int option; @@ -143,7 +143,7 @@ int main(int argc, char *argv[]) adm_help(udev, argc, argv); rc = 2; out: - udev_selinux_exit(udev); + label_finish(); udev_unref(udev); log_close(); return rc; diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 20de5cfc28..16751144bf 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -858,11 +858,11 @@ static void static_dev_create_from_modules(struct udev *udev) util_strscpyl(filename, sizeof(filename), "/dev/", devname, NULL); mkdir_parents(filename, 0755); - udev_selinux_setfscreatecon(udev, filename, mode); + label_context_set(filename, mode); log_debug("mknod '%s' %c%u:%u\n", filename, type, maj, min); if (mknod(filename, mode, makedev(maj, min)) < 0 && errno == EEXIST) utimensat(AT_FDCWD, filename, NULL, 0); - udev_selinux_resetfscreatecon(udev); + label_context_clear(); } fclose(f); @@ -888,10 +888,10 @@ static void static_dev_create_links(struct udev *udev) struct stat sb; if (stat(stdlinks[i].target, &sb) == 0) { - udev_selinux_setfscreatecon(udev, stdlinks[i].link, S_IFLNK); + label_context_set(stdlinks[i].link, S_IFLNK); if (symlink(stdlinks[i].target, stdlinks[i].link) < 0 && errno == EEXIST) utimensat(AT_FDCWD, stdlinks[i].link, NULL, AT_SYMLINK_NOFOLLOW); - udev_selinux_resetfscreatecon(udev); + label_context_clear(); } } } @@ -1077,7 +1077,7 @@ int main(int argc, char *argv[]) log_parse_environment(); udev_set_log_fn(udev, udev_main_log); log_debug("version %s\n", VERSION); - udev_selinux_init(udev); + label_init("/dev"); for (;;) { int option; @@ -1607,7 +1607,7 @@ exit_daemonize: udev_queue_export_unref(udev_queue_export); udev_ctrl_connection_unref(ctrl_conn); udev_ctrl_unref(udev_ctrl); - udev_selinux_exit(udev); + label_finish(); udev_unref(udev); log_close(); return rc; |