| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
#include "sd-bus.h" |
| 4 |
|
| 5 |
#include "bus-error.h" |
| 6 |
#include "bus-locator.h" |
| 7 |
#include "log.h" |
| 8 |
#include "login-util.h" |
| 9 |
#include "sysupdate-util.h" |
| 10 |
|
| 11 |
int reboot_now(void) { |
| 12 |
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; |
| 13 |
_cleanup_(sd_bus_close_unrefp) sd_bus *bus = NULL; |
| 14 |
int r; |
| 15 |
|
| 16 |
r = sd_bus_open_system(&bus); |
| 17 |
if (r < 0) |
| 18 |
return log_error_errno(r, "Failed to open bus connection: %m"); |
| 19 |
|
| 20 |
r = bus_call_method(bus, bus_login_mgr, "RebootWithFlags", &error, NULL, "t", |
| 21 |
(uint64_t) SD_LOGIND_ROOT_CHECK_INHIBITORS); |
| 22 |
if (r < 0) |
| 23 |
return log_error_errno(r, "Failed to issue reboot request: %s", bus_error_message(&error, r)); |
| 24 |
|
| 25 |
return 0; |
| 26 |
} |