]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
c2f1db8f | 2 | #pragma once |
60918275 LP |
3 | |
4 | #include <stdbool.h> | |
a66d02c3 | 5 | #include <stdio.h> |
ea430986 | 6 | |
718db961 | 7 | #include "sd-bus.h" |
d0955f00 | 8 | #include "sd-device.h" |
718db961 | 9 | #include "sd-event.h" |
71d35b6b | 10 | |
4ad49000 | 11 | #include "cgroup-util.h" |
400f1a33 | 12 | #include "fdset.h" |
2e5c94b9 | 13 | #include "hashmap.h" |
6a48d82f | 14 | #include "ip-address-access.h" |
2e5c94b9 | 15 | #include "list.h" |
da8e1782 | 16 | #include "prioq.h" |
2e5c94b9 | 17 | #include "ratelimit.h" |
a16e1123 | 18 | |
227b8a76 | 19 | struct libmnt_monitor; |
57b7a260 | 20 | typedef struct Unit Unit; |
227b8a76 | 21 | |
4f0f902f | 22 | /* Enforce upper limit how many names we allow */ |
59d1a833 | 23 | #define MANAGER_MAX_NAMES 131072 /* 128K */ |
4f0f902f | 24 | |
60918275 | 25 | typedef struct Manager Manager; |
acbb0225 | 26 | |
89998745 LP |
27 | /* An externally visible state. We don't actually maintain this as state variable, but derive it from various fields |
28 | * when requested */ | |
f755e3b7 | 29 | typedef enum ManagerState { |
d81afec1 | 30 | MANAGER_INITIALIZING, |
f755e3b7 | 31 | MANAGER_STARTING, |
a16e1123 | 32 | MANAGER_RUNNING, |
f755e3b7 LP |
33 | MANAGER_DEGRADED, |
34 | MANAGER_MAINTENANCE, | |
35 | MANAGER_STOPPING, | |
36 | _MANAGER_STATE_MAX, | |
37 | _MANAGER_STATE_INVALID = -1 | |
38 | } ManagerState; | |
39 | ||
af41e508 | 40 | typedef enum ManagerObjective { |
f755e3b7 | 41 | MANAGER_OK, |
a16e1123 LP |
42 | MANAGER_EXIT, |
43 | MANAGER_RELOAD, | |
44 | MANAGER_REEXECUTE, | |
b9080b03 FF |
45 | MANAGER_REBOOT, |
46 | MANAGER_POWEROFF, | |
47 | MANAGER_HALT, | |
48 | MANAGER_KEXEC, | |
664f88a7 | 49 | MANAGER_SWITCH_ROOT, |
af41e508 LP |
50 | _MANAGER_OBJECTIVE_MAX, |
51 | _MANAGER_OBJECTIVE_INVALID = -1 | |
52 | } ManagerObjective; | |
a16e1123 | 53 | |
127d5fd1 ZJS |
54 | typedef enum StatusType { |
55 | STATUS_TYPE_EPHEMERAL, | |
56 | STATUS_TYPE_NORMAL, | |
ebc5788e | 57 | STATUS_TYPE_EMERGENCY, |
127d5fd1 ZJS |
58 | } StatusType; |
59 | ||
afcfaa69 LP |
60 | typedef enum OOMPolicy { |
61 | OOM_CONTINUE, /* The kernel kills the process it wants to kill, and that's it */ | |
62 | OOM_STOP, /* The kernel kills the process it wants to kill, and we stop the unit */ | |
63 | OOM_KILL, /* The kernel kills the process it wants to kill, and all others in the unit, and we stop the unit */ | |
64 | _OOM_POLICY_MAX, | |
65 | _OOM_POLICY_INVALID = -1 | |
66 | } OOMPolicy; | |
67 | ||
7bc740f4 YW |
68 | /* Notes: |
69 | * 1. TIMESTAMP_FIRMWARE, TIMESTAMP_LOADER, TIMESTAMP_KERNEL, TIMESTAMP_INITRD, | |
70 | * TIMESTAMP_SECURITY_START, and TIMESTAMP_SECURITY_FINISH are set only when | |
71 | * the manager is system and not running under container environment. | |
72 | * | |
73 | * 2. The monotonic timestamp of TIMESTAMP_KERNEL is always zero. | |
74 | * | |
75 | * 3. The realtime timestamp of TIMESTAMP_KERNEL will be unset if the system does not | |
76 | * have RTC. | |
77 | * | |
78 | * 4. TIMESTAMP_FIRMWARE and TIMESTAMP_LOADER will be unset if the system does not | |
79 | * have RTC, or systemd is built without EFI support. | |
80 | * | |
81 | * 5. The monotonic timestamps of TIMESTAMP_FIRMWARE and TIMESTAMP_LOADER are stored as | |
82 | * negative of the actual value. | |
83 | * | |
84 | * 6. TIMESTAMP_USERSPACE is the timestamp of when the manager was started. | |
85 | * | |
86 | * 7. TIMESTAMP_INITRD_* are set only when the system is booted with an initrd. | |
87 | */ | |
88 | ||
9f9f0342 LP |
89 | typedef enum ManagerTimestamp { |
90 | MANAGER_TIMESTAMP_FIRMWARE, | |
91 | MANAGER_TIMESTAMP_LOADER, | |
92 | MANAGER_TIMESTAMP_KERNEL, | |
93 | MANAGER_TIMESTAMP_INITRD, | |
94 | MANAGER_TIMESTAMP_USERSPACE, | |
95 | MANAGER_TIMESTAMP_FINISH, | |
96 | ||
97 | MANAGER_TIMESTAMP_SECURITY_START, | |
98 | MANAGER_TIMESTAMP_SECURITY_FINISH, | |
99 | MANAGER_TIMESTAMP_GENERATORS_START, | |
100 | MANAGER_TIMESTAMP_GENERATORS_FINISH, | |
101 | MANAGER_TIMESTAMP_UNITS_LOAD_START, | |
102 | MANAGER_TIMESTAMP_UNITS_LOAD_FINISH, | |
d4ee7bd8 YW |
103 | |
104 | MANAGER_TIMESTAMP_INITRD_SECURITY_START, | |
105 | MANAGER_TIMESTAMP_INITRD_SECURITY_FINISH, | |
106 | MANAGER_TIMESTAMP_INITRD_GENERATORS_START, | |
107 | MANAGER_TIMESTAMP_INITRD_GENERATORS_FINISH, | |
108 | MANAGER_TIMESTAMP_INITRD_UNITS_LOAD_START, | |
109 | MANAGER_TIMESTAMP_INITRD_UNITS_LOAD_FINISH, | |
9f9f0342 LP |
110 | _MANAGER_TIMESTAMP_MAX, |
111 | _MANAGER_TIMESTAMP_INVALID = -1, | |
112 | } ManagerTimestamp; | |
113 | ||
400f1a33 | 114 | #include "execute.h" |
60918275 | 115 | #include "job.h" |
84e3543e | 116 | #include "path-lookup.h" |
4d7213b2 | 117 | #include "show-status.h" |
400f1a33 | 118 | #include "unit-name.h" |
60918275 | 119 | |
638cece4 LP |
120 | typedef enum ManagerTestRunFlags { |
121 | MANAGER_TEST_NORMAL = 0, /* run normally */ | |
ed4ac965 LP |
122 | MANAGER_TEST_RUN_MINIMAL = 1 << 0, /* create basic data structures */ |
123 | MANAGER_TEST_RUN_BASIC = 1 << 1, /* interact with the environment */ | |
124 | MANAGER_TEST_RUN_ENV_GENERATORS = 1 << 2, /* also run env generators */ | |
125 | MANAGER_TEST_RUN_GENERATORS = 1 << 3, /* also run unit generators */ | |
e8112e67 | 126 | MANAGER_TEST_FULL = MANAGER_TEST_RUN_BASIC | MANAGER_TEST_RUN_ENV_GENERATORS | MANAGER_TEST_RUN_GENERATORS, |
638cece4 LP |
127 | } ManagerTestRunFlags; |
128 | ||
e0a3da1f ZJS |
129 | assert_cc((MANAGER_TEST_FULL & UINT8_MAX) == MANAGER_TEST_FULL); |
130 | ||
60918275 | 131 | struct Manager { |
87f0e418 | 132 | /* Note that the set of units we know of is allowed to be |
35b8ca3a | 133 | * inconsistent. However the subset of it that is loaded may |
87d1515d LP |
134 | * not, and the list of jobs may neither. */ |
135 | ||
87f0e418 LP |
136 | /* Active jobs and units */ |
137 | Hashmap *units; /* name string => Unit object n:1 */ | |
4b58153d | 138 | Hashmap *units_by_invocation_id; |
60918275 LP |
139 | Hashmap *jobs; /* job id => Job object 1:1 */ |
140 | ||
ef734fd6 LP |
141 | /* To make it easy to iterate through the units of a specific |
142 | * type we maintain a per type linked list */ | |
ac155bb8 | 143 | LIST_HEAD(Unit, units_by_type[_UNIT_TYPE_MAX]); |
ef734fd6 | 144 | |
87f0e418 | 145 | /* Units that need to be loaded */ |
ac155bb8 | 146 | LIST_HEAD(Unit, load_queue); /* this is actually more a stack than a queue, but uh. */ |
60918275 | 147 | |
034c6ed7 | 148 | /* Jobs that need to be run */ |
da8e1782 | 149 | struct Prioq *run_queue; |
034c6ed7 | 150 | |
c1e1601e LP |
151 | /* Units and jobs that have not yet been announced via |
152 | * D-Bus. When something about a job changes it is added here | |
153 | * if it is not in there yet. This allows easy coalescing of | |
154 | * D-Bus change signals. */ | |
ac155bb8 | 155 | LIST_HEAD(Unit, dbus_unit_queue); |
c1e1601e LP |
156 | LIST_HEAD(Job, dbus_job_queue); |
157 | ||
701cc384 | 158 | /* Units to remove */ |
ac155bb8 | 159 | LIST_HEAD(Unit, cleanup_queue); |
23a177ef | 160 | |
c5a97ed1 LP |
161 | /* Units and jobs to check when doing GC */ |
162 | LIST_HEAD(Unit, gc_unit_queue); | |
163 | LIST_HEAD(Job, gc_job_queue); | |
701cc384 | 164 | |
4ad49000 | 165 | /* Units that should be realized */ |
91a6073e | 166 | LIST_HEAD(Unit, cgroup_realize_queue); |
4ad49000 | 167 | |
09e24654 LP |
168 | /* Units whose cgroup ran empty */ |
169 | LIST_HEAD(Unit, cgroup_empty_queue); | |
170 | ||
afcfaa69 LP |
171 | /* Units whose memory.event fired */ |
172 | LIST_HEAD(Unit, cgroup_oom_queue); | |
173 | ||
19496554 MS |
174 | /* Target units whose default target dependencies haven't been set yet */ |
175 | LIST_HEAD(Unit, target_deps_queue); | |
176 | ||
a3c1168a LP |
177 | /* Units that might be subject to StopWhenUnneeded= clean-up */ |
178 | LIST_HEAD(Unit, stop_when_unneeded_queue); | |
179 | ||
718db961 LP |
180 | sd_event *event; |
181 | ||
62a76913 LP |
182 | /* This maps PIDs we care about to units that are interested in. We allow multiple units to he interested in |
183 | * the same PID and multiple PIDs to be relevant to the same unit. Since in most cases only a single unit will | |
184 | * be interested in the same PID we use a somewhat special encoding here: the first unit interested in a PID is | |
185 | * stored directly in the hashmap, keyed by the PID unmodified. If there are other units interested too they'll | |
186 | * be stored in a NULL-terminated array, and keyed by the negative PID. This is safe as pid_t is signed and | |
187 | * negative PIDs are not used for regular processes but process groups, which we don't care about in this | |
188 | * context, but this allows us to use the negative range for our own purposes. */ | |
189 | Hashmap *watch_pids; /* pid => unit as well as -pid => array of units */ | |
9152c765 | 190 | |
95ae05c0 WC |
191 | /* A set contains all units which cgroup should be refreshed after startup */ |
192 | Set *startup_units; | |
193 | ||
f755e3b7 LP |
194 | /* A set which contains all currently failed units */ |
195 | Set *failed_units; | |
196 | ||
752b5905 LP |
197 | sd_event_source *run_queue_event_source; |
198 | ||
c952c6ec | 199 | char *notify_socket; |
718db961 LP |
200 | int notify_fd; |
201 | sd_event_source *notify_event_source; | |
202 | ||
d8fdc620 LP |
203 | int cgroups_agent_fd; |
204 | sd_event_source *cgroups_agent_event_source; | |
205 | ||
718db961 LP |
206 | int signal_fd; |
207 | sd_event_source *signal_event_source; | |
c952c6ec | 208 | |
575b300b LP |
209 | sd_event_source *sigchld_event_source; |
210 | ||
718db961 LP |
211 | int time_change_fd; |
212 | sd_event_source *time_change_event_source; | |
9d58f1db | 213 | |
bbf5fd8e LP |
214 | sd_event_source *timezone_change_event_source; |
215 | ||
718db961 | 216 | sd_event_source *jobs_in_progress_event_source; |
acbb0225 | 217 | |
00d9ef85 LP |
218 | int user_lookup_fds[2]; |
219 | sd_event_source *user_lookup_event_source; | |
220 | ||
5f109056 LP |
221 | sd_event_source *sync_bus_names_event_source; |
222 | ||
463d0d15 | 223 | UnitFileScope unit_file_scope; |
84e3543e | 224 | LookupPaths lookup_paths; |
e8630e69 ZJS |
225 | Hashmap *unit_id_map; |
226 | Hashmap *unit_name_map; | |
fe51822e | 227 | Set *unit_path_cache; |
91e0ee5f | 228 | usec_t unit_cache_mtime; |
036643a2 | 229 | |
1ad6e8b3 LP |
230 | char **transient_environment; /* The environment, as determined from config files, kernel cmdline and environment generators */ |
231 | char **client_environment; /* Environment variables created by clients through the bus API */ | |
1137a57c | 232 | |
e96d6be7 | 233 | usec_t runtime_watchdog; |
65224c1d | 234 | usec_t reboot_watchdog; |
acafd7d8 | 235 | usec_t kexec_watchdog; |
e96d6be7 | 236 | |
9f9f0342 | 237 | dual_timestamp timestamps[_MANAGER_TIMESTAMP_MAX]; |
8d567588 | 238 | |
9670d583 | 239 | /* Data specific to the device subsystem */ |
d0955f00 | 240 | sd_device_monitor *device_monitor; |
8fe914ec | 241 | Hashmap *devices_by_sysfs; |
ef734fd6 LP |
242 | |
243 | /* Data specific to the mount subsystem */ | |
d379d442 | 244 | struct libmnt_monitor *mount_monitor; |
718db961 | 245 | sd_event_source *mount_event_source; |
ea430986 | 246 | |
07b0b134 ML |
247 | /* Data specific to the swap filesystem */ |
248 | FILE *proc_swaps; | |
718db961 | 249 | sd_event_source *swap_event_source; |
9670d583 | 250 | Hashmap *swaps_by_devnode; |
07b0b134 | 251 | |
ea430986 | 252 | /* Data specific to the D-Bus subsystem */ |
718db961 LP |
253 | sd_bus *api_bus, *system_bus; |
254 | Set *private_buses; | |
255 | int private_listen_fd; | |
256 | sd_event_source *private_listen_event_source; | |
8f8f05a9 LP |
257 | |
258 | /* Contains all the clients that are subscribed to signals via | |
259 | the API bus. Note that private bus connections are always | |
260 | considered subscribes, since they last for very short only, | |
261 | and it is much simpler that way. */ | |
262 | sd_bus_track *subscribed; | |
263 | char **deserialized_subscribed; | |
5e8d1c9a | 264 | |
8f88ecf6 LP |
265 | /* This is used during reloading: before the reload we queue |
266 | * the reply message here, and afterwards we send it */ | |
209de525 | 267 | sd_bus_message *pending_reload_message; |
8e274523 | 268 | |
05e343b7 | 269 | Hashmap *watch_bus; /* D-Bus names => Unit object n:1 */ |
05e343b7 | 270 | |
71445ae7 LP |
271 | bool send_reloading_done; |
272 | ||
7fab9d01 | 273 | uint32_t current_job_id; |
bacbccb7 | 274 | uint32_t default_unit_job_id; |
7fab9d01 | 275 | |
9d58f1db LP |
276 | /* Data specific to the Automount subsystem */ |
277 | int dev_autofs_fd; | |
278 | ||
8e274523 | 279 | /* Data specific to the cgroup subsystem */ |
4ad49000 | 280 | Hashmap *cgroup_unit; |
efdb0237 | 281 | CGroupMask cgroup_supported; |
9444b1f2 | 282 | char *cgroup_root; |
e537352b | 283 | |
09e24654 | 284 | /* Notifications from cgroups, when the unified hierarchy is used is done via inotify. */ |
efdb0237 LP |
285 | int cgroup_inotify_fd; |
286 | sd_event_source *cgroup_inotify_event_source; | |
afcfaa69 LP |
287 | |
288 | /* Maps for finding the unit for each inotify watch descriptor for the cgroup.events and | |
289 | * memory.events cgroupv2 attributes. */ | |
0bb814c2 | 290 | Hashmap *cgroup_control_inotify_wd_unit; |
afcfaa69 | 291 | Hashmap *cgroup_memory_inotify_wd_unit; |
701cc384 | 292 | |
09e24654 LP |
293 | /* A defer event for handling cgroup empty events and processing them after SIGCHLD in all cases. */ |
294 | sd_event_source *cgroup_empty_event_source; | |
afcfaa69 | 295 | sd_event_source *cgroup_oom_event_source; |
09e24654 | 296 | |
35b8ca3a | 297 | /* Make sure the user cannot accidentally unmount our cgroup |
33be102a LP |
298 | * file system */ |
299 | int pin_cgroupfs_fd; | |
300 | ||
892a035c | 301 | unsigned gc_marker; |
efdb0237 | 302 | |
bbf5fd8e LP |
303 | /* The stat() data the last time we saw /etc/localtime */ |
304 | usec_t etc_localtime_mtime; | |
305 | bool etc_localtime_accessible:1; | |
306 | ||
af41e508 | 307 | ManagerObjective objective:5; |
41447faf | 308 | |
af41e508 | 309 | /* Flags */ |
9d58f1db | 310 | bool dispatching_load_queue:1; |
9d58f1db | 311 | |
72bc8d00 | 312 | bool taint_usr:1; |
e0a3da1f | 313 | |
d8eb10d6 | 314 | /* Have we already sent out the READY=1 notification? */ |
0c2826c6 ZJS |
315 | bool ready_sent:1; |
316 | ||
d8eb10d6 ZJS |
317 | /* Have we already printed the taint line if necessary? */ |
318 | bool taint_logged:1; | |
319 | ||
00b5974f LP |
320 | /* Have we ever changed the "kernel.pid_max" sysctl? */ |
321 | bool sysctl_pid_max_changed:1; | |
322 | ||
638cece4 | 323 | ManagerTestRunFlags test_run_flags:8; |
0d8c31ff | 324 | |
287419c1 AC |
325 | /* If non-zero, exit with the following value when the systemd |
326 | * process terminate. Useful for containers: systemd-nspawn could get | |
327 | * the return value. */ | |
328 | uint8_t return_value; | |
329 | ||
d450b6f2 | 330 | ShowStatus show_status; |
36cf4507 | 331 | StatusUnitFormat status_unit_format; |
7d5ceb64 | 332 | char *confirm_spawn; |
31a7eb86 | 333 | bool no_console_output; |
2a12e32e | 334 | bool service_watchdogs; |
d3689161 | 335 | |
0a494f1f LP |
336 | ExecOutput default_std_output, default_std_error; |
337 | ||
085afe36 | 338 | usec_t default_restart_usec, default_timeout_start_usec, default_timeout_stop_usec; |
dc653bf4 JK |
339 | usec_t default_timeout_abort_usec; |
340 | bool default_timeout_abort_set; | |
1f19a534 | 341 | |
3f41e1e5 LN |
342 | usec_t default_start_limit_interval; |
343 | unsigned default_start_limit_burst; | |
344 | ||
085afe36 LP |
345 | bool default_cpu_accounting; |
346 | bool default_memory_accounting; | |
13c31542 | 347 | bool default_io_accounting; |
085afe36 | 348 | bool default_blockio_accounting; |
03a7b521 | 349 | bool default_tasks_accounting; |
377bfd2d | 350 | bool default_ip_accounting; |
085afe36 | 351 | |
0af20ea2 | 352 | uint64_t default_tasks_max; |
bd8f585b LP |
353 | usec_t default_timer_accuracy_usec; |
354 | ||
afcfaa69 LP |
355 | OOMPolicy default_oom_policy; |
356 | ||
a6ecbf83 | 357 | int original_log_level; |
bda7d78b | 358 | LogTarget original_log_target; |
a6ecbf83 | 359 | bool log_level_overridden:1; |
bda7d78b | 360 | bool log_target_overridden:1; |
a6ecbf83 | 361 | |
517d56b1 | 362 | struct rlimit *rlimit[_RLIMIT_MAX]; |
c93ff2e9 | 363 | |
a7556052 LP |
364 | /* non-zero if we are reloading or reexecuting, */ |
365 | int n_reloading; | |
e409f875 LP |
366 | |
367 | unsigned n_installed_jobs; | |
76bf48b7 | 368 | unsigned n_failed_jobs; |
f2b68789 | 369 | |
03b717a3 | 370 | /* Jobs in progress watching */ |
637f8b8e | 371 | unsigned n_running_jobs; |
7ed9f6cd | 372 | unsigned n_on_console; |
03b717a3 | 373 | unsigned jobs_in_progress_iteration; |
637f8b8e | 374 | |
e46b13c8 ZJS |
375 | /* Do we have any outstanding password prompts? */ |
376 | int have_ask_password; | |
377 | int ask_password_inotify_fd; | |
378 | sd_event_source *ask_password_event_source; | |
379 | ||
f2b68789 | 380 | /* Type=idle pipes */ |
31a7eb86 | 381 | int idle_pipe[4]; |
718db961 | 382 | sd_event_source *idle_pipe_event_source; |
664f88a7 LP |
383 | |
384 | char *switch_root; | |
385 | char *switch_root_init; | |
a57f7e2c LP |
386 | |
387 | /* This maps all possible path prefixes to the units needing | |
388 | * them. It's a hashmap with a path string as key and a Set as | |
389 | * value where Unit objects are contained. */ | |
390 | Hashmap *units_requiring_mounts_for; | |
e3dd987c | 391 | |
283868e1 SW |
392 | /* Used for processing polkit authorization responses */ |
393 | Hashmap *polkit_registry; | |
2e5c94b9 | 394 | |
29206d46 LP |
395 | /* Dynamic users/groups, indexed by their name */ |
396 | Hashmap *dynamic_users; | |
397 | ||
00d9ef85 LP |
398 | /* Keep track of all UIDs and GIDs any of our services currently use. This is useful for the RemoveIPC= logic. */ |
399 | Hashmap *uid_refs; | |
400 | Hashmap *gid_refs; | |
401 | ||
e8a565cb YW |
402 | /* ExecRuntime, indexed by their owner unit id */ |
403 | Hashmap *exec_runtime_by_id; | |
404 | ||
24dd31c1 | 405 | /* When the user hits C-A-D more than 7 times per 2s, do something immediately... */ |
2e5c94b9 | 406 | RateLimit ctrl_alt_del_ratelimit; |
ae8c7939 | 407 | EmergencyAction cad_burst_action; |
f2341e0a LP |
408 | |
409 | const char *unit_log_field; | |
410 | const char *unit_log_format_string; | |
ae2a2c53 | 411 | |
4b58153d LP |
412 | const char *invocation_log_field; |
413 | const char *invocation_log_format_string; | |
414 | ||
463d0d15 | 415 | int first_boot; /* tri-state */ |
3536f49e | 416 | |
62a76913 | 417 | /* Prefixes of e.g. RuntimeDirectory= */ |
72fd1768 | 418 | char *prefix[_EXEC_DIRECTORY_TYPE_MAX]; |
62a76913 LP |
419 | |
420 | /* Used in the SIGCHLD and sd_notify() message invocation logic to avoid that we dispatch the same event | |
421 | * multiple times on the same unit. */ | |
422 | unsigned sigchldgen; | |
423 | unsigned notifygen; | |
c6e892bc YW |
424 | |
425 | bool honor_device_enumeration; | |
60918275 LP |
426 | }; |
427 | ||
dc653bf4 | 428 | static inline usec_t manager_default_timeout_abort_usec(Manager *m) { |
9c79f0e0 | 429 | assert(m); |
dc653bf4 JK |
430 | return m->default_timeout_abort_set ? m->default_timeout_abort_usec : m->default_timeout_stop_usec; |
431 | } | |
432 | ||
463d0d15 LP |
433 | #define MANAGER_IS_SYSTEM(m) ((m)->unit_file_scope == UNIT_FILE_SYSTEM) |
434 | #define MANAGER_IS_USER(m) ((m)->unit_file_scope != UNIT_FILE_SYSTEM) | |
435 | ||
2c289ea8 LP |
436 | #define MANAGER_IS_RELOADING(m) ((m)->n_reloading > 0) |
437 | ||
49d5666c LP |
438 | #define MANAGER_IS_FINISHED(m) (dual_timestamp_is_set((m)->timestamps + MANAGER_TIMESTAMP_FINISH)) |
439 | ||
af41e508 LP |
440 | /* The objective is set to OK as soon as we enter the main loop, and set otherwise as soon as we are done with it */ |
441 | #define MANAGER_IS_RUNNING(m) ((m)->objective == MANAGER_OK) | |
4259d202 | 442 | |
638cece4 LP |
443 | #define MANAGER_IS_TEST_RUN(m) ((m)->test_run_flags != 0) |
444 | ||
445 | int manager_new(UnitFileScope scope, ManagerTestRunFlags test_run_flags, Manager **m); | |
06d8d842 | 446 | Manager* manager_free(Manager *m); |
c70cac54 | 447 | DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free); |
60918275 | 448 | |
a16e1123 | 449 | int manager_startup(Manager *m, FILE *serialization, FDSet *fds); |
f50e0a01 | 450 | |
60918275 | 451 | Job *manager_get_job(Manager *m, uint32_t id); |
87f0e418 | 452 | Unit *manager_get_unit(Manager *m, const char *name); |
60918275 | 453 | |
86fbf370 | 454 | int manager_get_job_from_dbus_path(Manager *m, const char *s, Job **_j); |
ea430986 | 455 | |
718db961 LP |
456 | int manager_load_unit_prepare(Manager *m, const char *name, const char *path, sd_bus_error *e, Unit **_ret); |
457 | int manager_load_unit(Manager *m, const char *name, const char *path, sd_bus_error *e, Unit **_ret); | |
4109ede7 | 458 | int manager_load_startable_unit_or_warn(Manager *m, const char *name, const char *path, Unit **ret); |
718db961 | 459 | int manager_load_unit_from_dbus_path(Manager *m, const char *s, sd_bus_error *e, Unit **_u); |
28247076 | 460 | |
50cbaba4 LP |
461 | int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, Set *affected_jobs, sd_bus_error *e, Job **_ret); |
462 | int manager_add_job_by_name(Manager *m, JobType type, const char *name, JobMode mode, Set *affected_jobs, sd_bus_error *e, Job **_ret); | |
463 | int manager_add_job_by_name_and_warn(Manager *m, JobType type, const char *name, JobMode mode, Set *affected_jobs, Job **ret); | |
15d167f8 | 464 | int manager_propagate_reload(Manager *m, Unit *unit, JobMode mode, sd_bus_error *e); |
60918275 | 465 | |
87f0e418 | 466 | void manager_dump_units(Manager *s, FILE *f, const char *prefix); |
cea8e32e | 467 | void manager_dump_jobs(Manager *s, FILE *f, const char *prefix); |
ad75b9e7 | 468 | void manager_dump(Manager *s, FILE *f, const char *prefix); |
713f6f90 | 469 | int manager_get_dump_string(Manager *m, char **ret); |
a66d02c3 | 470 | |
7fad411c LP |
471 | void manager_clear_jobs(Manager *m); |
472 | ||
f75f613d FB |
473 | void manager_unwatch_pid(Manager *m, pid_t pid); |
474 | ||
c1e1601e | 475 | unsigned manager_dispatch_load_queue(Manager *m); |
f50e0a01 | 476 | |
79a224c4 | 477 | int manager_default_environment(Manager *m); |
1ad6e8b3 LP |
478 | int manager_transient_environment_add(Manager *m, char **plus); |
479 | int manager_client_environment_modify(Manager *m, char **minus, char **plus); | |
480 | int manager_get_effective_environment(Manager *m, char ***ret); | |
481 | ||
c93ff2e9 | 482 | int manager_set_default_rlimits(Manager *m, struct rlimit **default_rlimit); |
b2bb3dbe | 483 | |
9152c765 | 484 | int manager_loop(Manager *m); |
83c60c9f | 485 | |
d8d5ab98 | 486 | int manager_open_serialization(Manager *m, FILE **_f); |
a16e1123 | 487 | |
b3680f49 | 488 | int manager_serialize(Manager *m, FILE *f, FDSet *fds, bool switching_root); |
a16e1123 LP |
489 | int manager_deserialize(Manager *m, FILE *f, FDSet *fds); |
490 | ||
491 | int manager_reload(Manager *m); | |
492 | ||
fdf20a31 | 493 | void manager_reset_failed(Manager *m); |
5632e374 | 494 | |
4927fcae | 495 | void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success); |
e983b760 | 496 | void manager_send_unit_plymouth(Manager *m, Unit *u); |
4927fcae | 497 | |
31afa0a4 | 498 | bool manager_unit_inactive_or_pending(Manager *m, const char *name); |
8f6df3fa | 499 | |
b0c918b9 LP |
500 | void manager_check_finished(Manager *m); |
501 | ||
8559b3b7 | 502 | void manager_recheck_dbus(Manager *m); |
4cfa2c99 | 503 | void manager_recheck_journal(Manager *m); |
f1dd0c3f | 504 | |
d450b6f2 | 505 | void manager_set_show_status(Manager *m, ShowStatus mode); |
e2680723 LP |
506 | void manager_set_first_boot(Manager *m, bool b); |
507 | ||
127d5fd1 | 508 | void manager_status_printf(Manager *m, StatusType type, const char *status, const char *format, ...) _printf_(4,5); |
cb8ccb22 | 509 | void manager_flip_auto_status(Manager *m, bool enable); |
68b29a9f | 510 | |
a57f7e2c | 511 | Set *manager_get_units_requiring_mounts_for(Manager *m, const char *path); |
e66cf1a3 | 512 | |
f755e3b7 LP |
513 | ManagerState manager_state(Manager *m); |
514 | ||
5269eb6b | 515 | int manager_update_failed_units(Manager *m, Unit *u, bool failed); |
03455c28 | 516 | |
00d9ef85 LP |
517 | void manager_unref_uid(Manager *m, uid_t uid, bool destroy_now); |
518 | int manager_ref_uid(Manager *m, uid_t uid, bool clean_ipc); | |
519 | ||
520 | void manager_unref_gid(Manager *m, gid_t gid, bool destroy_now); | |
521 | int manager_ref_gid(Manager *m, gid_t gid, bool destroy_now); | |
522 | ||
523 | void manager_vacuum_uid_refs(Manager *m); | |
524 | void manager_vacuum_gid_refs(Manager *m); | |
525 | ||
526 | void manager_serialize_uid_refs(Manager *m, FILE *f); | |
527 | void manager_deserialize_uid_refs_one(Manager *m, const char *value); | |
528 | ||
529 | void manager_serialize_gid_refs(Manager *m, FILE *f); | |
530 | void manager_deserialize_gid_refs_one(Manager *m, const char *value); | |
531 | ||
af6b0ecc LP |
532 | char *manager_taint_string(Manager *m); |
533 | ||
adefcf28 LP |
534 | void manager_ref_console(Manager *m); |
535 | void manager_unref_console(Manager *m); | |
536 | ||
a6ecbf83 FB |
537 | void manager_override_log_level(Manager *m, int level); |
538 | void manager_restore_original_log_level(Manager *m); | |
539 | ||
bda7d78b FB |
540 | void manager_override_log_target(Manager *m, LogTarget target); |
541 | void manager_restore_original_log_target(Manager *m); | |
542 | ||
f755e3b7 LP |
543 | const char *manager_state_to_string(ManagerState m) _const_; |
544 | ManagerState manager_state_from_string(const char *s) _pure_; | |
7d5ceb64 FB |
545 | |
546 | const char *manager_get_confirm_spawn(Manager *m); | |
b0eb2944 FB |
547 | bool manager_is_confirm_spawn_disabled(Manager *m); |
548 | void manager_disable_confirm_spawn(void); | |
9f9f0342 LP |
549 | |
550 | const char *manager_timestamp_to_string(ManagerTimestamp m) _const_; | |
551 | ManagerTimestamp manager_timestamp_from_string(const char *s) _pure_; | |
d4ee7bd8 | 552 | ManagerTimestamp manager_timestamp_initrd_mangle(ManagerTimestamp s); |
afcfaa69 LP |
553 | |
554 | const char* oom_policy_to_string(OOMPolicy i) _const_; | |
555 | OOMPolicy oom_policy_from_string(const char *s) _pure_; |