1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include "bus-polkit.h"
4 #include "logind-polkit.h"
5 #include "missing_capability.h"
6 #include "user-util.h"
7
check_polkit_chvt(sd_bus_message * message,Manager * manager,sd_bus_error * error)8 int check_polkit_chvt(sd_bus_message *message, Manager *manager, sd_bus_error *error) {
9 #if ENABLE_POLKIT
10 return bus_verify_polkit_async(
11 message,
12 CAP_SYS_ADMIN,
13 "org.freedesktop.login1.chvt",
14 NULL,
15 false,
16 UID_INVALID,
17 &manager->polkit_registry,
18 error);
19 #else
20 /* Allow chvt when polkit is not present. This allows a service to start a graphical session as a
21 * non-root user when polkit is not compiled in, more closely matching the default polkit policy */
22 return 1;
23 #endif
24 }
25