ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
2aacef
From e44e907f58d3c89e0de01e8ff4e25079f1ca505e Mon Sep 17 00:00:00 2001
2aacef
From: Luca Boccassi <bluca@debian.org>
2aacef
Date: Wed, 23 Nov 2022 16:06:48 +0000
2aacef
Subject: [PATCH] portable: add a few more useful debug log messages
2aacef
2aacef
When attaching and /etc/systemd/system.attached can't be created or used
2aacef
(eg: dead symlink) the logs are pretty much useless as even at debug
2aacef
level there's no indication of what is going wrong.
2aacef
Add some debug logs, and return a more specific error string over D-Bus.
2aacef
2aacef
(cherry picked from commit 80d95fcd6e1947a7887b96b22a32dbca115baac9)
2aacef
2aacef
Related: #2138081
2aacef
---
2aacef
 src/portable/portable.c | 6 +++---
2aacef
 1 file changed, 3 insertions(+), 3 deletions(-)
2aacef
2aacef
diff --git a/src/portable/portable.c b/src/portable/portable.c
2aacef
index be906f786c..fbc4497014 100644
2aacef
--- a/src/portable/portable.c
2aacef
+++ b/src/portable/portable.c
2aacef
@@ -1131,7 +1131,7 @@ static int attach_unit_file(
2aacef
         (void) mkdir_parents(where, 0755);
2aacef
         if (mkdir(where, 0755) < 0) {
2aacef
                 if (errno != EEXIST)
2aacef
-                        return -errno;
2aacef
+                        return log_debug_errno(errno, "Failed to create attach directory %s: %m", where);
2aacef
         } else
2aacef
                 (void) portable_changes_add(changes, n_changes, PORTABLE_MKDIR, where, NULL);
2aacef
 
2aacef
@@ -1145,7 +1145,7 @@ static int attach_unit_file(
2aacef
 
2aacef
         if (mkdir(dropin_dir, 0755) < 0) {
2aacef
                 if (errno != EEXIST)
2aacef
-                        return -errno;
2aacef
+                        return log_debug_errno(errno, "Failed to create drop-in directory %s: %m", dropin_dir);
2aacef
         } else
2aacef
                 (void) portable_changes_add(changes, n_changes, PORTABLE_MKDIR, dropin_dir, NULL);
2aacef
 
2aacef
@@ -1392,7 +1392,7 @@ int portable_attach(
2aacef
                 r = attach_unit_file(&paths, image->path, image->type, extension_images,
2aacef
                                      item, profile, flags, changes, n_changes);
2aacef
                 if (r < 0)
2aacef
-                        return r;
2aacef
+                        return sd_bus_error_set_errnof(error, r, "Failed to attach unit '%s': %m", item->name);
2aacef
         }
2aacef
 
2aacef
         /* We don't care too much for the image symlink, it's just a convenience thing, it's not necessary for proper