Skip to content

Commit 5a20a98

Browse files
committed
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.
1 parent 93b6d6a commit 5a20a98

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

src/shared/install.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ void unit_file_dump_changes(int r, const char *verb, const UnitFileChange *chang
338338
break;
339339
case UNIT_FILE_UNLINK:
340340
if (!quiet)
341-
log_info("Removed %s.", changes[i].path);
341+
log_info("Removed \"%s\".", changes[i].path);
342342
break;
343343
case UNIT_FILE_IS_MASKED:
344344
if (!quiet)
@@ -361,11 +361,11 @@ void unit_file_dump_changes(int r, const char *verb, const UnitFileChange *chang
361361
case -EEXIST:
362362
if (changes[i].source)
363363
log_error_errno(changes[i].type_or_errno,
364-
"Failed to %s unit, file %s already exists and is a symlink to %s.",
364+
"Failed to %s unit, file \"%s\" already exists and is a symlink to \"%s\".",
365365
verb, changes[i].path, changes[i].source);
366366
else
367367
log_error_errno(changes[i].type_or_errno,
368-
"Failed to %s unit, file %s already exists.",
368+
"Failed to %s unit, file \"%s\" already exists.",
369369
verb, changes[i].path);
370370
logged = true;
371371
break;
@@ -391,7 +391,7 @@ void unit_file_dump_changes(int r, const char *verb, const UnitFileChange *chang
391391
logged = true;
392392
break;
393393
case -ELOOP:
394-
log_error_errno(changes[i].type_or_errno, "Failed to %s unit, refusing to operate on linked unit file %s",
394+
log_error_errno(changes[i].type_or_errno, "Failed to %s unit, refusing to operate on linked unit file %s.",
395395
verb, changes[i].path);
396396
logged = true;
397397
break;
@@ -403,7 +403,7 @@ void unit_file_dump_changes(int r, const char *verb, const UnitFileChange *chang
403403

404404
default:
405405
assert(changes[i].type_or_errno < 0);
406-
log_error_errno(changes[i].type_or_errno, "Failed to %s unit, file %s: %m.",
406+
log_error_errno(changes[i].type_or_errno, "Failed to %s unit, file \"%s\": %m",
407407
verb, changes[i].path);
408408
logged = true;
409409
}
@@ -839,15 +839,15 @@ static int find_symlinks(
839839

840840
d = opendir(path);
841841
if (!d) {
842-
log_error_errno(errno, "Failed to open directory '%s' while scanning for symlinks, ignoring: %m", path);
842+
log_error_errno(errno, "Failed to open directory \"%s\" while scanning for symlinks, ignoring: %m", path);
843843
continue;
844844
}
845845

846846
r = find_symlinks_in_directory(d, path, root_dir, i, match_name, ignore_same_name, config_path, same_name_link);
847847
if (r > 0)
848848
return 1;
849849
else if (r < 0)
850-
log_debug_errno(r, "Failed to lookup for symlinks in '%s': %m", path);
850+
log_debug_errno(r, "Failed to look up symlinks in \"%s\": %m", path);
851851
}
852852

853853
/* We didn't find any suitable symlinks in .wants or .requires directories, let's look for linked unit files in this directory. */
@@ -1320,7 +1320,7 @@ static int unit_file_load(
13201320
0, info,
13211321
NULL);
13221322
if (r < 0)
1323-
return log_debug_errno(r, "Failed to parse %s: %m", info->name);
1323+
return log_debug_errno(r, "Failed to parse \"%s\": %m", info->name);
13241324

13251325
if ((flags & SEARCH_DROPIN) == 0)
13261326
info->type = UNIT_FILE_TYPE_REGULAR;
@@ -1483,7 +1483,7 @@ static int unit_file_search(
14831483
STRV_FOREACH(p, files) {
14841484
r = unit_file_load_or_readlink(c, info, *p, lp, flags | SEARCH_DROPIN);
14851485
if (r < 0)
1486-
return log_debug_errno(r, "Failed to load conf file %s: %m", *p);
1486+
return log_debug_errno(r, "Failed to load conf file \"%s\": %m", *p);
14871487
}
14881488

14891489
return result;
@@ -1728,7 +1728,7 @@ int unit_file_verify_alias(const UnitFileInstallInfo *i, const char *dst, char *
17281728
return log_error_errno(r, "Failed to verify alias validity: %m");
17291729
if (r == 0)
17301730
return log_warning_errno(SYNTHETIC_ERRNO(EXDEV),
1731-
"Invalid unit %s symlink %s.",
1731+
"Invalid unit \"%s\" symlink \"%s\".",
17321732
i->name, dst);
17331733

17341734
} else {
@@ -1739,7 +1739,7 @@ int unit_file_verify_alias(const UnitFileInstallInfo *i, const char *dst, char *
17391739

17401740
UnitNameFlags type = unit_name_to_instance(i->name, &inst);
17411741
if (type < 0)
1742-
return log_error_errno(type, "Failed to extract instance name from %s: %m", i->name);
1742+
return log_error_errno(type, "Failed to extract instance name from \"%s\": %m", i->name);
17431743

17441744
if (type == UNIT_NAME_INSTANCE) {
17451745
r = unit_name_replace_instance(dst, inst, &dst_updated);

0 commit comments

Comments
 (0)