richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
594167
From 144887f20bb2dc9f46060091db03d4f517f1d518 Mon Sep 17 00:00:00 2001
594167
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
594167
Date: Wed, 2 Mar 2022 16:53:54 +0100
594167
Subject: [PATCH] shared/install: when we fail to chase a symlink, show some
594167
 logs
594167
594167
When chase_symlinks() fails, we'd get the generic error:
594167
594167
  Failed to disable: Permission denied.
594167
594167
Let's at least add the failure to changes list, so the user gets
594167
a slightly better message. Ideally, we'd say where exactly the permission
594167
failure occured, but chase_symlinks() is a library level function and I don't
594167
think we should add logging there. The output looks like this now:
594167
594167
  Failed to resolve symlink "/tmp/systemctl-test.1r7Roj/etc/systemd/system/link5alias2.service": Permission denied
594167
  Failed to resolve symlink "/tmp/systemctl-test.1r7Roj/etc/systemd/system/link5alias.service": Permission denied
594167
  Failed to disable unit, file /tmp/systemctl-test.1r7Roj/etc/systemd/system/link5alias2.service: Permission denied.
594167
  Failed to disable unit, file /tmp/systemctl-test.1r7Roj/etc/systemd/system/link5alias.service: Permission denied.
594167
594167
(cherry picked from commit 212a24f0bbe4c54183d3b0ad9579a995007e29a8)
594167
594167
Related: #2082131
594167
---
594167
 src/shared/install.c | 3 +++
594167
 1 file changed, 3 insertions(+)
594167
594167
diff --git a/src/shared/install.c b/src/shared/install.c
594167
index bf11e5bdce..ce045d02be 100644
594167
--- a/src/shared/install.c
594167
+++ b/src/shared/install.c
594167
@@ -616,6 +616,9 @@ static int remove_marked_symlinks_fd(
594167
                         if (q == -ENOENT)
594167
                                 continue;
594167
                         if (q < 0) {
594167
+                                log_debug_errno(q, "Failed to resolve symlink \"%s\": %m", p);
594167
+                                unit_file_changes_add(changes, n_changes, q, p, NULL);
594167
+
594167
                                 if (r == 0)
594167
                                         r = q;
594167
                                 continue;