systemd/0161-shared-install-add-a-bit-more-quoting.patch
Jan Macku 0daf48d9aa systemd-250-8
Resolves: #2047682,#2068043,#2068131,#2073003,#2073994,#2082131,#2083493,#2087652,#2100340
2022-07-20 08:37:23 +02:00

119 lines
6.4 KiB
Diff

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