| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include "systemctl.h" |
| 5 |
|
| 6 |
/* The init script exit codes for the LSB 'status' verb. (This is different from the 'start' verb, whose exit |
| 7 |
codes are defined in exit-status.h.) |
| 8 |
|
| 9 |
0 program is running or service is OK |
| 10 |
1 program is dead and /var/run pid file exists |
| 11 |
2 program is dead and /var/lock lock file exists |
| 12 |
3 program is not running |
| 13 |
4 program or service status is unknown |
| 14 |
5-99 reserved for future LSB use |
| 15 |
100-149 reserved for distribution use |
| 16 |
150-199 reserved for application use |
| 17 |
200-254 reserved |
| 18 |
|
| 19 |
https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html |
| 20 |
*/ |
| 21 |
enum { |
| 22 |
EXIT_PROGRAM_RUNNING_OR_SERVICE_OK = 0, |
| 23 |
EXIT_PROGRAM_DEAD_AND_PID_EXISTS = 1, |
| 24 |
EXIT_PROGRAM_DEAD_AND_LOCK_FILE_EXISTS = 2, |
| 25 |
EXIT_PROGRAM_NOT_RUNNING = 3, |
| 26 |
EXIT_PROGRAM_OR_SERVICES_STATUS_UNKNOWN = 4, |
| 27 |
}; |
| 28 |
|
| 29 |
typedef enum BusFocus { |
| 30 |
BUS_FULL, /* The full bus indicated via --system or --user */ |
| 31 |
BUS_MANAGER, /* The manager itself, possibly directly, possibly via the bus */ |
| 32 |
_BUS_FOCUS_MAX |
| 33 |
} BusFocus; |
| 34 |
|
| 35 |
int acquire_bus_full(BusFocus focus, bool graceful, sd_bus **ret); |
| 36 |
static inline int acquire_bus(BusFocus focus, sd_bus **ret) { |
| 37 |
return acquire_bus_full(focus, false, ret); |
| 38 |
} |
| 39 |
void release_busses(void); |
| 40 |
|
| 41 |
void ask_password_agent_open_maybe(void); |
| 42 |
void polkit_agent_open_maybe(void); |
| 43 |
|
| 44 |
int translate_bus_error_to_exit_status(int r, const sd_bus_error *error); |
| 45 |
|
| 46 |
int get_state_one_unit(sd_bus *bus, const char *unit, UnitActiveState *ret_active_state); |
| 47 |
int get_sub_state_one_unit(sd_bus *bus, const char *unit, char **ret_sub_state); |
| 48 |
int get_unit_list(sd_bus *bus, const char *machine, char **patterns, UnitInfo **unit_infos, int c, sd_bus_message **ret_reply); |
| 49 |
int expand_unit_names(sd_bus *bus, char * const *names, const char* suffix, char ***ret, bool *ret_expanded); |
| 50 |
|
| 51 |
int get_active_triggering_units(sd_bus *bus, const char *unit, bool ignore_masked, char ***ret); |
| 52 |
void warn_triggering_units(sd_bus *bus, const char *unit, const char *operation, bool ignore_masked); |
| 53 |
|
| 54 |
int need_daemon_reload(sd_bus *bus, const char *unit); |
| 55 |
|
| 56 |
void warn_unit_file_changed(const char *unit); |
| 57 |
|
| 58 |
int append_unit_dependencies(sd_bus *bus, char **names, char ***ret); |
| 59 |
int maybe_extend_with_unit_dependencies(sd_bus *bus, char ***list); |
| 60 |
|
| 61 |
int unit_file_find_path(LookupPaths *lp, const char *unit_name, char **ret_unit_path); |
| 62 |
int unit_find_paths(sd_bus *bus, const char *unit_name, LookupPaths *lp, bool force_client_side, Hashmap **cached_id_map, Hashmap **cached_name_map, char **ret_fragment_path, char ***ret_dropin_paths); |
| 63 |
|
| 64 |
int unit_is_masked(sd_bus *bus, const char *unit); |
| 65 |
int unit_exists(LookupPaths *lp, const char *unit); |
| 66 |
|
| 67 |
int unit_get_dependencies(sd_bus *bus, const char *name, char ***ret); |
| 68 |
|
| 69 |
const char* unit_type_suffix(const char *unit); |
| 70 |
bool output_show_unit(const UnitInfo *u, char **patterns); |
| 71 |
|
| 72 |
typedef enum InstallClientSide { |
| 73 |
INSTALL_CLIENT_SIDE_NO = 0, |
| 74 |
INSTALL_CLIENT_SIDE_OVERRIDE, |
| 75 |
INSTALL_CLIENT_SIDE_ARG_ROOT, |
| 76 |
INSTALL_CLIENT_SIDE_OFFLINE, |
| 77 |
INSTALL_CLIENT_SIDE_NOT_BOOTED, |
| 78 |
INSTALL_CLIENT_SIDE_GLOBAL_SCOPE, |
| 79 |
} InstallClientSide; |
| 80 |
|
| 81 |
InstallClientSide install_client_side(void); |
| 82 |
|
| 83 |
int output_table(Table *table); |
| 84 |
|
| 85 |
bool show_preset_for_state(UnitFileState state); |
| 86 |
|
| 87 |
int mangle_names(const char *operation, char * const *original_names, char ***ret); |
| 88 |
|
| 89 |
UnitFileFlags unit_file_flags_from_args(void); |
| 90 |
|
| 91 |
int halt_now(enum action a); |
| 92 |
|
| 93 |
int get_unit_by_pid(sd_bus *bus, pid_t pid, char **ret_unit, char **ret_path); |
| 94 |
int lookup_unit_by_pidref(sd_bus *bus, pid_t pid, char **ret_unit, char **ret_path); |