mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-09 03:48:02 +02:00
tests: Exercise NSS group lookup before running tests
Similar to #256, NSS plugins might open file descriptors the first time they look up a system group, and leave them open. To avoid detecting this as a leak, do one group lookup (which we expect to fail) before starting testing, so that the fd is already open the first time we call _dbus_check_fdleaks_enter(), and therefore is not considered to have been leaked in _dbus_check_fdleaks_leave(). Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/540 Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
e3c3cd6889
commit
7cbb7b75dd
1 changed files with 9 additions and 3 deletions
|
|
@ -788,14 +788,20 @@ _dbus_test_main (int argc,
|
||||||
* show up as having been "leaked" by the first module of code under
|
* show up as having been "leaked" by the first module of code under
|
||||||
* test that happens to do a NSS lookup. */
|
* test that happens to do a NSS lookup. */
|
||||||
{
|
{
|
||||||
DBusString username;
|
DBusString lookup;
|
||||||
dbus_uid_t ignored_uid = DBUS_UID_UNSET;
|
dbus_uid_t ignored_uid = DBUS_UID_UNSET;
|
||||||
|
dbus_gid_t ignored_gid = DBUS_GID_UNSET;
|
||||||
|
|
||||||
_dbus_string_init_const (&username, "dbus-no-user-with-this-name");
|
_dbus_string_init_const (&lookup, "dbus-no-user-with-this-name");
|
||||||
/* We use a username that almost certainly doesn't exist, because
|
/* We use a username that almost certainly doesn't exist, because
|
||||||
* if we used something like root it might get handled early in the
|
* if we used something like root it might get handled early in the
|
||||||
* NSS search order, before we get as far as asking sssd or LDAP. */
|
* NSS search order, before we get as far as asking sssd or LDAP. */
|
||||||
_dbus_parse_unix_user_from_config (&username, &ignored_uid);
|
_dbus_parse_unix_user_from_config (&lookup, &ignored_uid);
|
||||||
|
|
||||||
|
/* Same for groups */
|
||||||
|
_dbus_string_init_const (&lookup, "dbus-no-group-with-this-name");
|
||||||
|
_dbus_parse_unix_group_from_config (&lookup, &ignored_gid);
|
||||||
|
|
||||||
_dbus_test_check_memleaks ("initial nss query");
|
_dbus_test_check_memleaks ("initial nss query");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue