debug: Replace "@<id>" with "#<id>" in logs

Wayland debug logs resemble email addresses. This is a problem when
anonymizing logs from users. For example:

[2512874.343] xdg_surface@700.configure(333)

In the above log line, the substring "surface@700.config" can be
mistaken for an email address and redacted during anonymization.

Signed-off-by: Alex Yang <aycyang@google.com>
This commit is contained in:
Alex Yang 2023-05-24 11:24:23 -07:00
parent 4ec379ebcc
commit 6d33346571
4 changed files with 12 additions and 12 deletions

View File

@ -1283,7 +1283,7 @@ wl_closure_print(struct wl_closure *closure, struct wl_object *target,
clock_gettime(CLOCK_REALTIME, &tp);
time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000);
fprintf(f, "[%7u.%03u] %s%s%s@%u.%s(",
fprintf(f, "[%7u.%03u] %s%s%s#%u.%s(",
time / 1000, time % 1000,
discarded ? "discarded " : "",
send ? " -> " : "",
@ -1323,7 +1323,7 @@ wl_closure_print(struct wl_closure *closure, struct wl_object *target,
break;
case 'o':
if (closure->args[i].o)
fprintf(f, "%s@%u",
fprintf(f, "%s#%u",
closure->args[i].o->interface->name,
closure->args[i].o->id);
else
@ -1335,7 +1335,7 @@ wl_closure_print(struct wl_closure *closure, struct wl_object *target,
else
nval = closure->args[i].n;
fprintf(f, "new id %s@",
fprintf(f, "new id %s#",
(closure->message->types[i]) ?
closure->message->types[i]->name :
"[unknown]");

View File

@ -312,7 +312,7 @@ wl_event_queue_release(struct wl_event_queue *queue)
wl_list_for_each_safe(proxy, tmp, &queue->proxy_list,
queue_link) {
if (queue != &queue->display->default_queue) {
wl_log(" %s@%u still attached\n",
wl_log(" %s#%u still attached\n",
proxy->object.interface->name,
proxy->object.id);
}
@ -1045,7 +1045,7 @@ display_handle_error(void *data,
const struct wl_interface *interface;
if (proxy) {
wl_log("%s@%u: error %d: %s\n",
wl_log("%s#%u: error %d: %s\n",
proxy->object.interface->name,
proxy->object.id,
code, message);
@ -1526,7 +1526,7 @@ queue_event(struct wl_display *display, int len)
clock_gettime(CLOCK_REALTIME, &tp);
time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000);
fprintf(stderr, "[%7u.%03u] discarded [%s]@%d.[event %d]"
fprintf(stderr, "[%7u.%03u] discarded [%s]#%d.[event %d]"
"(%d fd, %d byte)\n",
time / 1000, time % 1000,
zombie ? "zombie" : "unknown",

View File

@ -391,7 +391,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
if (opcode >= object->interface->method_count) {
wl_resource_post_error(client->display_resource,
WL_DISPLAY_ERROR_INVALID_METHOD,
"invalid method %d, object %s@%u",
"invalid method %d, object %s#%u",
opcode,
object->interface->name,
object->id);
@ -405,7 +405,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
wl_resource_post_error(client->display_resource,
WL_DISPLAY_ERROR_INVALID_METHOD,
"invalid method %d (since %d < %d)"
", object %s@%u",
", object %s#%u",
opcode, resource->version, since,
object->interface->name,
object->id);
@ -423,7 +423,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
wl_closure_lookup_objects(closure, &client->objects) < 0) {
wl_resource_post_error(client->display_resource,
WL_DISPLAY_ERROR_INVALID_METHOD,
"invalid arguments for %s@%u.%s",
"invalid arguments for %s#%u.%s",
object->interface->name,
object->id,
message->name);
@ -1343,7 +1343,7 @@ wl_global_remove(struct wl_global *global)
if (global->removed)
wl_abort("wl_global_remove: called twice on the same "
"global '%s@%"PRIu32"'", global->interface->name,
"global '%s#%"PRIu32"'", global->interface->name,
global->name);
wl_list_for_each(resource, &display->registry_resource_list, link)

View File

@ -383,7 +383,7 @@ client_test_queue_destroy_with_attached_proxies(void)
/* Check that the log contains some information about the attached
* wl_callback proxy. */
log = map_file(client_log_fd, &log_len);
ret = snprintf(callback_name, sizeof(callback_name), "wl_callback@%u",
ret = snprintf(callback_name, sizeof(callback_name), "wl_callback#%u",
wl_proxy_get_id((struct wl_proxy *) callback));
assert(ret > 0 && ret < (int)sizeof(callback_name) &&
"callback name creation failed (possibly truncated)");
@ -456,7 +456,7 @@ client_test_queue_destroy_default_with_attached_proxies(void)
/* Check that the log does not contain any warning about the attached
* wl_callback proxy. */
log = maybe_map_file(client_log_fd, &log_len);
ret = snprintf(callback_name, sizeof(callback_name), "wl_callback@%u",
ret = snprintf(callback_name, sizeof(callback_name), "wl_callback#%u",
wl_proxy_get_id((struct wl_proxy *) callback));
assert(ret > 0 && ret < (int)sizeof(callback_name) &&
"callback name creation failed (possibly truncated)");