teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

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

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