summaryrefslogtreecommitdiff
path: root/udev_add.c
diff options
context:
space:
mode:
Diffstat (limited to 'udev_add.c')
-rw-r--r--udev_add.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/udev_add.c b/udev_add.c
index eeab1ca174..e5bd042a5c 100644
--- a/udev_add.c
+++ b/udev_add.c
@@ -83,6 +83,7 @@ create:
selinux_setfscreatecon(file, udev->kernel_name, mode);
retval = mknod(file, mode, devt);
+ selinux_resetfscreatecon();
if (retval != 0) {
dbg("mknod(%s, %#o, %u, %u) failed with error '%s'",
file, mode, major(devt), minor(devt), strerror(errno));
@@ -196,6 +197,7 @@ static int create_node(struct udevice *udev, struct sysfs_class_device *class_de
/* create symlink(s) if requested */
foreach_strpart(udev->symlink, " ", pos, len) {
+ int retval;
char linkname[NAME_SIZE];
char linktarget[NAME_SIZE];
@@ -227,9 +229,11 @@ static int create_node(struct udevice *udev, struct sysfs_class_device *class_de
dbg("symlink(%s, %s)", linktarget, filename);
if (!udev->test_run) {
- selinux_setfscreatecon(filename, udev->kernel_name, S_IFLNK);
unlink(filename);
- if (symlink(linktarget, filename) != 0)
+ selinux_setfscreatecon(filename, udev->kernel_name, S_IFLNK);
+ retval = symlink(linktarget, filename);
+ selinux_resetfscreatecon();
+ if (retval != 0)
dbg("symlink(%s, %s) failed with error '%s'",
linktarget, filename, strerror(errno));
}
@@ -326,7 +330,7 @@ int udev_add_device(struct udevice *udev, struct sysfs_class_device *class_dev)
}
exit:
- selinux_restore();
+ selinux_exit();
return retval;
}