Merge pull request #32072 from YHNdnzj/no-ellipsize

core/manager: use cellescape and don't be too aggressive
This commit is contained in:
Yu Watanabe
2024-04-04 02:44:59 +09:00
committed by GitHub
2 changed files with 8 additions and 11 deletions
+3 -1
View File
@@ -562,7 +562,9 @@ char *cellescape(char *buf, size_t len, const char *s) {
size_t i = 0, last_char_width[4] = {}, k = 0;
assert(buf);
assert(len > 0); /* at least a terminating NUL */
assert(s);
for (;;) {
char four[4];
@@ -612,7 +614,7 @@ char *cellescape(char *buf, size_t len, const char *s) {
else
assert(i + 1 <= len);
done:
done:
buf[i] = '\0';
return buf;
}
+5 -10
View File
@@ -2586,22 +2586,17 @@ static void manager_invoke_notify_message(
UNIT_VTABLE(u)->notify_message(u, ucred, tags, fds);
else if (DEBUG_LOGGING) {
_cleanup_free_ char *buf = NULL, *x = NULL, *y = NULL;
_cleanup_free_ char *joined = strv_join(tags, ", ");
char buf[CELLESCAPE_DEFAULT_LENGTH];
buf = strv_join(tags, ", ");
if (buf)
x = ellipsize(buf, 20, 90);
if (x)
y = cescape(x);
log_unit_debug(u, "Got notification message \"%s\", ignoring.", strnull(y));
log_unit_debug(u, "Got notification message from unexpected unit type, ignoring: %s",
joined ? cellescape(buf, sizeof(buf), joined) : "(null)");
}
}
static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
_cleanup_fdset_free_ FDSet *fds = NULL;
Manager *m = ASSERT_PTR(userdata);
_cleanup_fdset_free_ FDSet *fds = NULL;
char buf[NOTIFY_BUFFER_MAX+1];
struct iovec iovec = {
.iov_base = buf,