bus/containers: Indicate in loginfo whether connection is contained

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101354
This commit is contained in:
Simon McVittie 2017-07-21 20:51:53 +01:00
parent 1de35ba8ee
commit 7743c98b4b
3 changed files with 59 additions and 0 deletions

View file

@ -588,6 +588,9 @@ cache_peer_loginfo_string (BusConnectionData *d,
unsigned long pid;
char *windows_sid = NULL, *security_label = NULL;
dbus_bool_t prev_added;
const char *container = NULL;
const char *container_type = NULL;
const char *container_name = NULL;
if (!_dbus_string_init (&loginfo_buf))
return FALSE;
@ -659,6 +662,29 @@ cache_peer_loginfo_string (BusConnectionData *d,
prev_added = TRUE;
}
if (bus_containers_connection_is_contained (connection, &container,
&container_type,
&container_name))
{
dbus_bool_t did_append;
if (prev_added)
{
if (!_dbus_string_append_byte (&loginfo_buf, ' '))
goto oom;
}
did_append = _dbus_string_append_printf (&loginfo_buf,
"container=%s %s=\"%s\")",
container,
container_type,
container_name);
if (!did_append)
goto oom;
else
prev_added = TRUE;
}
if (!_dbus_string_steal_data (&loginfo_buf, &(d->cached_loginfo_string)))
goto oom;

View file

@ -1091,3 +1091,32 @@ bus_containers_remove_connection (BusContainers *self,
dbus_connection_unref (connection);
#endif /* DBUS_ENABLE_CONTAINERS */
}
dbus_bool_t
bus_containers_connection_is_contained (DBusConnection *connection,
const char **path,
const char **type,
const char **name)
{
#ifdef DBUS_ENABLE_CONTAINERS
BusContainerInstance *instance;
instance = dbus_connection_get_data (connection, contained_data_slot);
if (instance != NULL)
{
if (path != NULL)
*path = instance->path;
if (type != NULL)
*type = instance->type;
if (name != NULL)
*name = instance->name;
return TRUE;
}
#endif /* DBUS_ENABLE_CONTAINERS */
return FALSE;
}

View file

@ -49,6 +49,10 @@ dbus_bool_t bus_containers_supported_arguments_getter (BusContext *context,
void bus_containers_remove_connection (BusContainers *self,
DBusConnection *connection);
dbus_bool_t bus_containers_connection_is_contained (DBusConnection *connection,
const char **path,
const char **type,
const char **name);
static inline void
bus_clear_containers (BusContainers **containers_p)