else
mode |= S_IFCHR;
- /* preserve node with already correct numbers, to prevent changing the inode number */
if (lstat(file, &stats) == 0) {
if ((stats.st_mode & S_IFMT) == (mode & S_IFMT) && (stats.st_rdev == devt)) {
info("preserve file '%s', because it has correct dev_t", file);
selinux_setfilecon(file, udev->dev->kernel, stats.st_mode);
goto perms;
}
+ } else {
+ selinux_setfscreatecon(file, udev->dev->kernel, mode);
+ retval = mknod(file, mode, devt);
+ selinux_resetfscreatecon();
+ if (retval == 0)
+ goto perms;
}
- selinux_setfscreatecon(file, udev->dev->kernel, mode);
- retval = mknod(file, mode, devt);
- selinux_resetfscreatecon();
- if (retval == 0)
- goto perms;
-
info("atomically replace '%s'", file);
strlcpy(file_tmp, file, sizeof(file_tmp));
strlcat(file_tmp, TMP_FILE_EXT, sizeof(file_tmp));
}
}
}
+ } else {
+ info("creating symlink '%s' to '%s'", slink, target);
+ selinux_setfscreatecon(slink, NULL, S_IFLNK);
+ retval = symlink(target, slink);
+ selinux_resetfscreatecon();
+ if (retval == 0)
+ goto exit;
}
- info("creating symlink '%s' to '%s'", slink, target);
- selinux_setfscreatecon(slink, NULL, S_IFLNK);
- retval = symlink(target, slink);
- selinux_resetfscreatecon();
- if (retval == 0)
- goto exit;
-
info("atomically replace '%s'", slink);
strlcpy(slink_tmp, slink, sizeof(slink_tmp));
strlcat(slink_tmp, TMP_FILE_EXT, sizeof(slink_tmp));