logind: add ListInhibitors Varlink method

The Varlink ListInhibitors method is the counterpart of D-Bus
ListInhibitors. Like its D-Bus counterpart it is zero-filter and streams
the full list of currently registered inhibitors using the
SD_VARLINK_METHOD_MORE pattern, returning InhibitorInfo objects with
Id, What, Who, Why, Mode, UID, PID, and Since fields.

There is no D-Bus GetInhibitor getter to fold in, so no unique-key
filter is introduced here.
This commit is contained in:
Yaping Li
2026-05-22 02:56:24 +00:00
parent b4de3e5759
commit d2bdaab55e
7 changed files with 204 additions and 4 deletions
+6
View File
@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "logind-inhibit.h"
#include "logind-session.h"
#include "tests.h"
#include "test-varlink-idl-util.h"
@@ -10,6 +11,11 @@ TEST(login_enums_idl) {
/* SessionClass has SESSION_NONE ("none") as an internal sentinel that is intentionally not exposed
* via Varlink. Only validate the IDL→C direction. */
TEST_IDL_ENUM_FROM_STRING(SessionClass, session_class, vl_type_SessionClass);
TEST_IDL_ENUM(InhibitMode, inhibit_mode, vl_type_InhibitMode);
/* InhibitWhat is a bit-flag enum: inhibit_what_to_string() accepts a bitmask and
* the index does not correspond to a sequential integer, so the TEST_IDL_ENUM
* round-trip macro doesn't apply. The flag→string mapping is exercised through
* ListInhibitors integration tests in TEST-35-LOGIN.sh. */
}
DEFINE_TEST_MAIN(LOG_DEBUG);