From 14c7994263150b01d7ffbf89969cf8e3df893dc8 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Mon, 25 Jun 2007 16:03:11 +0200 Subject: [PATCH] always unlink temporary file before creating new one --- udev_node.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/udev_node.c b/udev_node.c index 9e09e58b..fcd52d0e 100644 --- a/udev_node.c +++ b/udev_node.c @@ -63,6 +63,7 @@ int udev_node_mknod(struct udevice *udev, const char *file, dev_t devt, mode_t m info("atomically replace '%s'", file); strlcpy(file_tmp, file, sizeof(file_tmp)); strlcat(file_tmp, TMP_FILE_EXT, sizeof(file_tmp)); + unlink(file_tmp); selinux_setfscreatecon(file_tmp, udev->dev->kernel, mode); retval = mknod(file_tmp, mode, devt); selinux_resetfscreatecon(); @@ -162,6 +163,7 @@ static int node_symlink(const char *node, const char *slink) info("atomically replace '%s'", slink); strlcpy(slink_tmp, slink, sizeof(slink_tmp)); strlcat(slink_tmp, TMP_FILE_EXT, sizeof(slink_tmp)); + unlink(slink_tmp); selinux_setfscreatecon(slink_tmp, NULL, S_IFLNK); retval = symlink(target, slink_tmp); selinux_resetfscreatecon(); -- 2.39.5