diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-10-20 17:57:03 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-10-20 18:06:28 +0200 |
commit | aecdef08be06d0881e0bc996361a46fe34dc9a4b (patch) | |
tree | 0b547e057a5e4a5e04065a55dc8f1bc3a41edd26 | |
parent | bootctl: add @current/@oneshot/@default targets to set-default/set-oneshot (diff) | |
download | systemd-aecdef08be06d0881e0bc996361a46fe34dc9a4b.tar.xz systemd-aecdef08be06d0881e0bc996361a46fe34dc9a4b.zip |
shared/clean-ipc: improve error message a bit
Failed to enter shared memory directory multipath: Permission denied
→
Failed to enter shared memory directory /dev/shm/multipath: Permission denied
When looking at nested directories, we will print only the final two elements
of the path. That is still more useful than just the last component of the
path. To print the full path, we'd have to allocate the string, and since the
error occurs so very rarely, I think the current best-effort approach is
enough.
-rw-r--r-- | src/shared/clean-ipc.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/shared/clean-ipc.c b/src/shared/clean-ipc.c index e4cd2d30d0..5d8f66c602 100644 --- a/src/shared/clean-ipc.c +++ b/src/shared/clean-ipc.c @@ -218,7 +218,7 @@ static int clean_sysvipc_msg(uid_t delete_uid, gid_t delete_gid, bool rm) { return ret; } -static int clean_posix_shm_internal(DIR *dir, uid_t uid, gid_t gid, bool rm) { +static int clean_posix_shm_internal(const char *dirname, DIR *dir, uid_t uid, gid_t gid, bool rm) { struct dirent *de; int ret = 0, r; @@ -234,7 +234,8 @@ static int clean_posix_shm_internal(DIR *dir, uid_t uid, gid_t gid, bool rm) { if (errno == ENOENT) continue; - ret = log_warning_errno(errno, "Failed to stat() POSIX shared memory segment %s: %m", de->d_name); + ret = log_warning_errno(errno, "Failed to stat() POSIX shared memory segment %s/%s: %m", + dirname, de->d_name); continue; } @@ -244,9 +245,10 @@ static int clean_posix_shm_internal(DIR *dir, uid_t uid, gid_t gid, bool rm) { kid = xopendirat(dirfd(dir), de->d_name, O_NOFOLLOW|O_NOATIME); if (!kid) { if (errno != ENOENT) - ret = log_warning_errno(errno, "Failed to enter shared memory directory %s: %m", de->d_name); + ret = log_warning_errno(errno, "Failed to enter shared memory directory %s/%s: %m", + dirname, de->d_name); } else { - r = clean_posix_shm_internal(kid, uid, gid, rm); + r = clean_posix_shm_internal(de->d_name, kid, uid, gid, rm); if (r < 0) ret = r; } @@ -262,7 +264,8 @@ static int clean_posix_shm_internal(DIR *dir, uid_t uid, gid_t gid, bool rm) { if (errno == ENOENT) continue; - ret = log_warning_errno(errno, "Failed to remove POSIX shared memory directory %s: %m", de->d_name); + ret = log_warning_errno(errno, "Failed to remove POSIX shared memory directory %s/%s: %m", + dirname, de->d_name); } else { log_debug("Removed POSIX shared memory directory %s", de->d_name); if (ret == 0) @@ -307,7 +310,7 @@ static int clean_posix_shm(uid_t uid, gid_t gid, bool rm) { return log_warning_errno(errno, "Failed to open /dev/shm: %m"); } - return clean_posix_shm_internal(dir, uid, gid, rm); + return clean_posix_shm_internal("/dev/shm", dir, uid, gid, rm); } static int clean_posix_mq(uid_t uid, gid_t gid, bool rm) { |