teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0161-shared-install-add-a-bit-more-quoting.patch

8d419f
From 348699605248eb30743c0aac4f2ecbff5dd986ad Mon Sep 17 00:00:00 2001
8d419f
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
8d419f
Date: Thu, 3 Mar 2022 11:09:25 +0100
8d419f
Subject: [PATCH] shared/install: add a bit more quoting
8d419f
8d419f
When we are printing a valid unit name, quoting isn't necessary, because
8d419f
unit names cannot contain whitespace or other confusing characters. In particular
8d419f
if the unit name is prefixed by " unit " or something else that clearly
8d419f
identifies the string as a unit name, quoting would just add unnecessary
8d419f
noise. But when we're printing paths or invalid names, it's better to add
8d419f
quotes for clarity.
8d419f
8d419f
(cherry picked from commit e75a26d0457d67a3146ff2d90af07db22213da3c)
8d419f
8d419f
Related: #2082131
8d419f
---
8d419f
 src/shared/install.c | 22 +++++++++++-----------
8d419f
 1 file changed, 11 insertions(+), 11 deletions(-)
8d419f
8d419f
diff --git a/src/shared/install.c b/src/shared/install.c
8d419f
index e07ca31797..cbfe96b1e8 100644
8d419f
--- a/src/shared/install.c
8d419f
+++ b/src/shared/install.c
8d419f
@@ -338,7 +338,7 @@ void unit_file_dump_changes(int r, const char *verb, const UnitFileChange *chang
8d419f
                         break;
8d419f
                 case UNIT_FILE_UNLINK:
8d419f
                         if (!quiet)
8d419f
-                                log_info("Removed %s.", changes[i].path);
8d419f
+                                log_info("Removed \"%s\".", changes[i].path);
8d419f
                         break;
8d419f
                 case UNIT_FILE_IS_MASKED:
8d419f
                         if (!quiet)
8d419f
@@ -361,11 +361,11 @@ void unit_file_dump_changes(int r, const char *verb, const UnitFileChange *chang
8d419f
                 case -EEXIST:
8d419f
                         if (changes[i].source)
8d419f
                                 log_error_errno(changes[i].type_or_errno,
8d419f
-                                                "Failed to %s unit, file %s already exists and is a symlink to %s.",
8d419f
+                                                "Failed to %s unit, file \"%s\" already exists and is a symlink to \"%s\".",
8d419f
                                                 verb, changes[i].path, changes[i].source);
8d419f
                         else
8d419f
                                 log_error_errno(changes[i].type_or_errno,
8d419f
-                                                "Failed to %s unit, file %s already exists.",
8d419f
+                                                "Failed to %s unit, file \"%s\" already exists.",
8d419f
                                                 verb, changes[i].path);
8d419f
                         logged = true;
8d419f
                         break;
8d419f
@@ -391,7 +391,7 @@ void unit_file_dump_changes(int r, const char *verb, const UnitFileChange *chang
8d419f
                         logged = true;
8d419f
                         break;
8d419f
                 case -ELOOP:
8d419f
-                        log_error_errno(changes[i].type_or_errno, "Failed to %s unit, refusing to operate on linked unit file %s",
8d419f
+                        log_error_errno(changes[i].type_or_errno, "Failed to %s unit, refusing to operate on linked unit file %s.",
8d419f
                                         verb, changes[i].path);
8d419f
                         logged = true;
8d419f
                         break;
8d419f
@@ -403,7 +403,7 @@ void unit_file_dump_changes(int r, const char *verb, const UnitFileChange *chang
8d419f
 
8d419f
                 default:
8d419f
                         assert(changes[i].type_or_errno < 0);
8d419f
-                        log_error_errno(changes[i].type_or_errno, "Failed to %s unit, file %s: %m.",
8d419f
+                        log_error_errno(changes[i].type_or_errno, "Failed to %s unit, file \"%s\": %m",
8d419f
                                         verb, changes[i].path);
8d419f
                         logged = true;
8d419f
                 }
8d419f
@@ -840,7 +840,7 @@ static int find_symlinks(
8d419f
 
8d419f
                 d = opendir(path);
8d419f
                 if (!d) {
8d419f
-                        log_error_errno(errno, "Failed to open directory '%s' while scanning for symlinks, ignoring: %m", path);
8d419f
+                        log_error_errno(errno, "Failed to open directory \"%s\" while scanning for symlinks, ignoring: %m", path);
8d419f
                         continue;
8d419f
                 }
8d419f
 
8d419f
@@ -848,7 +848,7 @@ static int find_symlinks(
8d419f
                 if (r > 0)
8d419f
                         return 1;
8d419f
                 else if (r < 0)
8d419f
-                        log_debug_errno(r, "Failed to lookup for symlinks in '%s': %m", path);
8d419f
+                        log_debug_errno(r, "Failed to look up symlinks in \"%s\": %m", path);
8d419f
         }
8d419f
 
8d419f
         /* We didn't find any suitable symlinks in .wants or .requires directories, let's look for linked unit files in this directory. */
8d419f
@@ -1321,7 +1321,7 @@ static int unit_file_load(
8d419f
                          0, info,
8d419f
                          NULL);
8d419f
         if (r < 0)
8d419f
-                return log_debug_errno(r, "Failed to parse %s: %m", info->name);
8d419f
+                return log_debug_errno(r, "Failed to parse \"%s\": %m", info->name);
8d419f
 
8d419f
         if ((flags & SEARCH_DROPIN) == 0)
8d419f
                 info->type = UNIT_FILE_TYPE_REGULAR;
8d419f
@@ -1481,7 +1481,7 @@ static int unit_file_search(
8d419f
         STRV_FOREACH(p, files) {
8d419f
                 r = unit_file_load_or_readlink(c, info, *p, lp, flags | SEARCH_DROPIN);
8d419f
                 if (r < 0)
8d419f
-                        return log_debug_errno(r, "Failed to load conf file %s: %m", *p);
8d419f
+                        return log_debug_errno(r, "Failed to load conf file \"%s\": %m", *p);
8d419f
         }
8d419f
 
8d419f
         return result;
8d419f
@@ -1726,7 +1726,7 @@ int unit_file_verify_alias(const UnitFileInstallInfo *i, const char *dst, char *
8d419f
                         return log_error_errno(r, "Failed to verify alias validity: %m");
8d419f
                 if (r == 0)
8d419f
                         return log_warning_errno(SYNTHETIC_ERRNO(EXDEV),
8d419f
-                                                 "Invalid unit %s symlink %s.",
8d419f
+                                                 "Invalid unit \"%s\" symlink \"%s\".",
8d419f
                                                  i->name, dst);
8d419f
 
8d419f
         } else {
8d419f
@@ -1737,7 +1737,7 @@ int unit_file_verify_alias(const UnitFileInstallInfo *i, const char *dst, char *
8d419f
 
8d419f
                         UnitNameFlags type = unit_name_to_instance(i->name, &inst);
8d419f
                         if (type < 0)
8d419f
-                                return log_error_errno(type, "Failed to extract instance name from %s: %m", i->name);
8d419f
+                                return log_error_errno(type, "Failed to extract instance name from \"%s\": %m", i->name);
8d419f
 
8d419f
                         if (type == UNIT_NAME_INSTANCE) {
8d419f
                                 r = unit_name_replace_instance(dst, inst, &dst_updated);