From: Zbigniew Jędrzejewski-Szmek Date: Mon, 24 Jan 2022 09:53:00 +0000 (+0100) Subject: user-runtime-dir: error out immediately if mkdir fails X-Git-Tag: v251-rc1~464 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4a00b45fa669faafc1ac1ec531cc106f2374e52d;p=thirdparty%2Fsystemd.git user-runtime-dir: error out immediately if mkdir fails We try to create two directories: /run/user and /run/user/. For the first we check the return value and error out if creation fails. But for the second one we continued based on the assumption that the subsequent mount will immediately fail anyway. But this has the disadvantage that we get a somewhat confusing error message: janv. 23 22:04:31 nsfw systemd-user-runtime-dir[1660]: Failed to mount per-user tmpfs directory /run/user/1000: No such file or directory Let's instead fail immediately with a precise error message. For https://bugzilla.redhat.com/show_bug.cgi?id=2044100. --- diff --git a/src/login/user-runtime-dir.c b/src/login/user-runtime-dir.c index 5ce5b35e178..f96a2d86623 100644 --- a/src/login/user-runtime-dir.c +++ b/src/login/user-runtime-dir.c @@ -80,7 +80,9 @@ static int user_mkdir_runtime_path( uid, gid, runtime_dir_size, runtime_dir_inodes, mac_smack_use() ? ",smackfsroot=*" : ""); - (void) mkdir_label(runtime_path, 0700); + r = mkdir_label(runtime_path, 0700); + if (r < 0 && r != -EEXIST) + return log_error_errno(r, "Failed to create %s: %m", runtime_path); r = mount_nofollow_verbose(LOG_DEBUG, "tmpfs", runtime_path, "tmpfs", MS_NODEV|MS_NOSUID, options); if (r < 0) {