From: Kay Sievers Date: Mon, 25 Jun 2007 14:03:11 +0000 (+0200) Subject: always unlink temporary file before creating new one X-Git-Tag: 174~1895 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14c7994263150b01d7ffbf89969cf8e3df893dc8;p=systemd always unlink temporary file before creating new one --- 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();