From b4c7ae9c8cb445b21d7c064f321e92e81b7692ce Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Tue, 11 Jan 2022 17:20:22 +0100 Subject: [PATCH] plugins/bootmisc: check return value from symlink() log on error Signed-off-by: Joachim Wiberg --- plugins/bootmisc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/bootmisc.c b/plugins/bootmisc.c index 9aa25656..54616850 100644 --- a/plugins/bootmisc.c +++ b/plugins/bootmisc.c @@ -104,6 +104,12 @@ static void clean(void *arg) } } +static void ln(const char *target, const char *linkpath, int ignerr) +{ + if (symlink(target, linkpath) && !ignerr) + _pe("Failed creating %s -> %s symlink", target, linkpath); +} + /* * Setup standard FHS 2.3 structure in /var, and write runlevel to UTMP */ @@ -125,11 +131,11 @@ static void setup(void *arg) _d("System with new /run tmpfs ..."); if (!fisdir("/run/lock")) makedir("/run/lock", 1777); - symlink("/run/lock", "/var/lock"); - symlink("/dev/shm", "/run/shm"); + ln("/run/lock", "/var/lock", 0); + ln("/dev/shm", "/run/shm", 0); /* compat only, should really be set up by OS/dist */ - symlink("/run", "/var/run"); + ln("/run", "/var/run", 1); } else { makedir("/var/lock", 1777); makedir("/var/run", 0755); @@ -183,7 +189,7 @@ static void setup(void *arg) makedir("/var/run/sshd", 01755); /* OpenSSH */ if (!fexist("/etc/mtab")) - symlink("../proc/self/mounts", "/etc/mtab"); + ln("../proc/self/mounts", "/etc/mtab", 1); /* Void Linux has a uuidd that runs as uuid:uuid and needs /run/uuid */ mksubsys("/var/run/uuidd", 0755, "uuidd", "uuidd");