mirror of
https://github.com/systemd/systemd.git
synced 2025-01-27 18:04:05 +03:00
udevd: create static device links only when the target exists
For example, not all systems have PROC_KCORE enabled. Avoid a broken symbolic link in those cases. Signed-off-by: Yin Kangkai <kangkai.yin@intel.com> Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
This commit is contained in:
parent
40929a0222
commit
08f11597f2
12
udev/udevd.c
12
udev/udevd.c
@ -900,10 +900,14 @@ static void static_dev_create_links(struct udev *udev, DIR *dir)
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(stdlinks); i++) {
|
||||
udev_selinux_setfscreateconat(udev, dirfd(dir), stdlinks[i].link, S_IFLNK);
|
||||
if (symlinkat(stdlinks[i].target, dirfd(dir), stdlinks[i].link) < 0 && errno == EEXIST)
|
||||
utimensat(dirfd(dir), stdlinks[i].link, NULL, AT_SYMLINK_NOFOLLOW);
|
||||
udev_selinux_resetfscreatecon(udev);
|
||||
struct stat sb;
|
||||
|
||||
if (stat(stdlinks[i].target, &sb) == 0) {
|
||||
udev_selinux_setfscreateconat(udev, dirfd(dir), stdlinks[i].link, S_IFLNK);
|
||||
if (symlinkat(stdlinks[i].target, dirfd(dir), stdlinks[i].link) < 0 && errno == EEXIST)
|
||||
utimensat(dirfd(dir), stdlinks[i].link, NULL, AT_SYMLINK_NOFOLLOW);
|
||||
udev_selinux_resetfscreatecon(udev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user