]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/login/logind-core.c
Merge pull request #18685 from poettering/network-type-tweaks
[thirdparty/systemd.git] / src / login / logind-core.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include <fcntl.h>
4 #include <sys/ioctl.h>
5 #include <sys/types.h>
6 #include <linux/vt.h>
7
8 #include "sd-device.h"
9
10 #include "alloc-util.h"
11 #include "bus-error.h"
12 #include "bus-util.h"
13 #include "cgroup-util.h"
14 #include "conf-parser.h"
15 #include "device-util.h"
16 #include "efi-loader.h"
17 #include "errno-util.h"
18 #include "fd-util.h"
19 #include "limits-util.h"
20 #include "logind.h"
21 #include "parse-util.h"
22 #include "path-util.h"
23 #include "process-util.h"
24 #include "stdio-util.h"
25 #include "strv.h"
26 #include "terminal-util.h"
27 #include "udev-util.h"
28 #include "user-util.h"
29 #include "userdb.h"
30 #include "utmp-wtmp.h"
31
32 void manager_reset_config(Manager *m) {
33 assert(m);
34
35 m->n_autovts = 6;
36 m->reserve_vt = 6;
37 m->remove_ipc = true;
38 m->inhibit_delay_max = 5 * USEC_PER_SEC;
39 m->user_stop_delay = 10 * USEC_PER_SEC;
40
41 m->handle_power_key = HANDLE_POWEROFF;
42 m->handle_suspend_key = HANDLE_SUSPEND;
43 m->handle_hibernate_key = HANDLE_HIBERNATE;
44 m->handle_lid_switch = HANDLE_SUSPEND;
45 m->handle_lid_switch_ep = _HANDLE_ACTION_INVALID;
46 m->handle_lid_switch_docked = HANDLE_IGNORE;
47 m->handle_reboot_key = HANDLE_REBOOT;
48 m->power_key_ignore_inhibited = false;
49 m->suspend_key_ignore_inhibited = false;
50 m->hibernate_key_ignore_inhibited = false;
51 m->lid_switch_ignore_inhibited = true;
52 m->reboot_key_ignore_inhibited = false;
53
54 m->holdoff_timeout_usec = 30 * USEC_PER_SEC;
55
56 m->idle_action_usec = 30 * USEC_PER_MINUTE;
57 m->idle_action = HANDLE_IGNORE;
58
59 m->runtime_dir_size = physical_memory_scale(10U, 100U); /* 10% */
60 m->runtime_dir_inodes = DIV_ROUND_UP(m->runtime_dir_size, 4096); /* 4k per inode */
61 m->sessions_max = 8192;
62 m->inhibitors_max = 8192;
63
64 m->kill_user_processes = KILL_USER_PROCESSES;
65
66 m->kill_only_users = strv_free(m->kill_only_users);
67 m->kill_exclude_users = strv_free(m->kill_exclude_users);
68 }
69
70 int manager_parse_config_file(Manager *m) {
71 assert(m);
72
73 return config_parse_many_nulstr(
74 PKGSYSCONFDIR "/logind.conf",
75 CONF_PATHS_NULSTR("systemd/logind.conf.d"),
76 "Login\0",
77 config_item_perf_lookup, logind_gperf_lookup,
78 CONFIG_PARSE_WARN, m,
79 NULL);
80 }
81
82 int manager_add_device(Manager *m, const char *sysfs, bool master, Device **ret_device) {
83 Device *d;
84
85 assert(m);
86 assert(sysfs);
87
88 d = hashmap_get(m->devices, sysfs);
89 if (d)
90 /* we support adding master-flags, but not removing them */
91 d->master = d->master || master;
92 else {
93 d = device_new(m, sysfs, master);
94 if (!d)
95 return -ENOMEM;
96 }
97
98 if (ret_device)
99 *ret_device = d;
100
101 return 0;
102 }
103
104 int manager_add_seat(Manager *m, const char *id, Seat **ret_seat) {
105 Seat *s;
106 int r;
107
108 assert(m);
109 assert(id);
110
111 s = hashmap_get(m->seats, id);
112 if (!s) {
113 r = seat_new(&s, m, id);
114 if (r < 0)
115 return r;
116 }
117
118 if (ret_seat)
119 *ret_seat = s;
120
121 return 0;
122 }
123
124 int manager_add_session(Manager *m, const char *id, Session **ret_session) {
125 Session *s;
126 int r;
127
128 assert(m);
129 assert(id);
130
131 s = hashmap_get(m->sessions, id);
132 if (!s) {
133 r = session_new(&s, m, id);
134 if (r < 0)
135 return r;
136 }
137
138 if (ret_session)
139 *ret_session = s;
140
141 return 0;
142 }
143
144 int manager_add_user(
145 Manager *m,
146 UserRecord *ur,
147 User **ret_user) {
148
149 User *u;
150 int r;
151
152 assert(m);
153 assert(ur);
154
155 u = hashmap_get(m->users, UID_TO_PTR(ur->uid));
156 if (!u) {
157 r = user_new(&u, m, ur);
158 if (r < 0)
159 return r;
160 }
161
162 if (ret_user)
163 *ret_user = u;
164
165 return 0;
166 }
167
168 int manager_add_user_by_name(
169 Manager *m,
170 const char *name,
171 User **ret_user) {
172
173 _cleanup_(user_record_unrefp) UserRecord *ur = NULL;
174 int r;
175
176 assert(m);
177 assert(name);
178
179 r = userdb_by_name(name, USERDB_AVOID_SHADOW, &ur);
180 if (r < 0)
181 return r;
182
183 return manager_add_user(m, ur, ret_user);
184 }
185
186 int manager_add_user_by_uid(
187 Manager *m,
188 uid_t uid,
189 User **ret_user) {
190
191 _cleanup_(user_record_unrefp) UserRecord *ur = NULL;
192 int r;
193
194 assert(m);
195 assert(uid_is_valid(uid));
196
197 r = userdb_by_uid(uid, USERDB_AVOID_SHADOW, &ur);
198 if (r < 0)
199 return r;
200
201 return manager_add_user(m, ur, ret_user);
202 }
203
204 int manager_add_inhibitor(Manager *m, const char* id, Inhibitor **ret) {
205 Inhibitor *i;
206 int r;
207
208 assert(m);
209 assert(id);
210
211 i = hashmap_get(m->inhibitors, id);
212 if (!i) {
213 r = inhibitor_new(&i, m, id);
214 if (r < 0)
215 return r;
216 }
217
218 if (ret)
219 *ret = i;
220
221 return 0;
222 }
223
224 int manager_add_button(Manager *m, const char *name, Button **ret_button) {
225 Button *b;
226
227 assert(m);
228 assert(name);
229
230 b = hashmap_get(m->buttons, name);
231 if (!b) {
232 b = button_new(m, name);
233 if (!b)
234 return -ENOMEM;
235 }
236
237 if (ret_button)
238 *ret_button = b;
239
240 return 0;
241 }
242
243 int manager_process_seat_device(Manager *m, sd_device *d) {
244 Device *device;
245 int r;
246
247 assert(m);
248
249 if (device_for_action(d, SD_DEVICE_REMOVE) ||
250 sd_device_has_current_tag(d, "seat") <= 0) {
251 const char *syspath;
252
253 r = sd_device_get_syspath(d, &syspath);
254 if (r < 0)
255 return 0;
256
257 device = hashmap_get(m->devices, syspath);
258 if (!device)
259 return 0;
260
261 seat_add_to_gc_queue(device->seat);
262 device_free(device);
263
264 } else {
265 const char *sn, *syspath;
266 bool master;
267 Seat *seat;
268
269 if (sd_device_get_property_value(d, "ID_SEAT", &sn) < 0 || isempty(sn))
270 sn = "seat0";
271
272 if (!seat_name_is_valid(sn)) {
273 log_device_warning(d, "Device with invalid seat name %s found, ignoring.", sn);
274 return 0;
275 }
276
277 seat = hashmap_get(m->seats, sn);
278 master = sd_device_has_current_tag(d, "master-of-seat") > 0;
279
280 /* Ignore non-master devices for unknown seats */
281 if (!master && !seat)
282 return 0;
283
284 r = sd_device_get_syspath(d, &syspath);
285 if (r < 0)
286 return r;
287
288 r = manager_add_device(m, syspath, master, &device);
289 if (r < 0)
290 return r;
291
292 if (!seat) {
293 r = manager_add_seat(m, sn, &seat);
294 if (r < 0) {
295 if (!device->seat)
296 device_free(device);
297
298 return r;
299 }
300 }
301
302 device_attach(device, seat);
303 seat_start(seat);
304 }
305
306 return 0;
307 }
308
309 int manager_process_button_device(Manager *m, sd_device *d) {
310 const char *sysname;
311 Button *b;
312 int r;
313
314 assert(m);
315
316 r = sd_device_get_sysname(d, &sysname);
317 if (r < 0)
318 return r;
319
320 if (device_for_action(d, SD_DEVICE_REMOVE) ||
321 sd_device_has_current_tag(d, "power-switch") <= 0) {
322
323 b = hashmap_get(m->buttons, sysname);
324 if (!b)
325 return 0;
326
327 button_free(b);
328
329 } else {
330 const char *sn;
331
332 r = manager_add_button(m, sysname, &b);
333 if (r < 0)
334 return r;
335
336 if (sd_device_get_property_value(d, "ID_SEAT", &sn) < 0 || isempty(sn))
337 sn = "seat0";
338
339 button_set_seat(b, sn);
340
341 r = button_open(b);
342 if (r < 0) /* event device doesn't have any keys or switches relevant to us? (or any other error
343 * opening the device?) let's close the button again. */
344 button_free(b);
345 }
346
347 return 0;
348 }
349
350 int manager_get_session_by_pid(Manager *m, pid_t pid, Session **ret) {
351 _cleanup_free_ char *unit = NULL;
352 Session *s;
353 int r;
354
355 assert(m);
356
357 if (!pid_is_valid(pid))
358 return -EINVAL;
359
360 s = hashmap_get(m->sessions_by_leader, PID_TO_PTR(pid));
361 if (!s) {
362 r = cg_pid_get_unit(pid, &unit);
363 if (r >= 0)
364 s = hashmap_get(m->session_units, unit);
365 }
366
367 if (ret)
368 *ret = s;
369
370 return !!s;
371 }
372
373 int manager_get_user_by_pid(Manager *m, pid_t pid, User **ret) {
374 _cleanup_free_ char *unit = NULL;
375 User *u = NULL;
376 int r;
377
378 assert(m);
379
380 if (!pid_is_valid(pid))
381 return -EINVAL;
382
383 r = cg_pid_get_slice(pid, &unit);
384 if (r >= 0)
385 u = hashmap_get(m->user_units, unit);
386
387 if (ret)
388 *ret = u;
389
390 return !!u;
391 }
392
393 int manager_get_idle_hint(Manager *m, dual_timestamp *t) {
394 Session *s;
395 bool idle_hint;
396 dual_timestamp ts = DUAL_TIMESTAMP_NULL;
397
398 assert(m);
399
400 idle_hint = !manager_is_inhibited(m, INHIBIT_IDLE, INHIBIT_BLOCK, t, false, false, 0, NULL);
401
402 HASHMAP_FOREACH(s, m->sessions) {
403 dual_timestamp k;
404 int ih;
405
406 ih = session_get_idle_hint(s, &k);
407 if (ih < 0)
408 return ih;
409
410 if (!ih) {
411 if (!idle_hint) {
412 if (k.monotonic < ts.monotonic)
413 ts = k;
414 } else {
415 idle_hint = false;
416 ts = k;
417 }
418 } else if (idle_hint) {
419
420 if (k.monotonic > ts.monotonic)
421 ts = k;
422 }
423 }
424
425 if (t)
426 *t = ts;
427
428 return idle_hint;
429 }
430
431 bool manager_shall_kill(Manager *m, const char *user) {
432 assert(m);
433 assert(user);
434
435 if (!m->kill_exclude_users && streq(user, "root"))
436 return false;
437
438 if (strv_contains(m->kill_exclude_users, user))
439 return false;
440
441 if (!strv_isempty(m->kill_only_users))
442 return strv_contains(m->kill_only_users, user);
443
444 return m->kill_user_processes;
445 }
446
447 int config_parse_n_autovts(
448 const char *unit,
449 const char *filename,
450 unsigned line,
451 const char *section,
452 unsigned section_line,
453 const char *lvalue,
454 int ltype,
455 const char *rvalue,
456 void *data,
457 void *userdata) {
458
459 unsigned *n = data;
460 unsigned o;
461 int r;
462
463 assert(filename);
464 assert(lvalue);
465 assert(rvalue);
466 assert(data);
467
468 r = safe_atou(rvalue, &o);
469 if (r < 0) {
470 log_syntax(unit, LOG_WARNING, filename, line, r,
471 "Failed to parse number of autovts, ignoring: %s", rvalue);
472 return 0;
473 }
474
475 if (o > 15) {
476 log_syntax(unit, LOG_WARNING, filename, line, 0,
477 "A maximum of 15 autovts are supported, ignoring: %s", rvalue);
478 return 0;
479 }
480
481 *n = o;
482 return 0;
483 }
484
485 static int vt_is_busy(unsigned vtnr) {
486 struct vt_stat vt_stat;
487 int r;
488 _cleanup_close_ int fd;
489
490 assert(vtnr >= 1);
491
492 /* VT_GETSTATE "cannot return state for more than 16 VTs, since v_state is short" */
493 assert(vtnr <= 15);
494
495 /* We explicitly open /dev/tty1 here instead of /dev/tty0. If
496 * we'd open the latter we'd open the foreground tty which
497 * hence would be unconditionally busy. By opening /dev/tty1
498 * we avoid this. Since tty1 is special and needs to be an
499 * explicitly loaded getty or DM this is safe. */
500
501 fd = open_terminal("/dev/tty1", O_RDWR|O_NOCTTY|O_CLOEXEC);
502 if (fd < 0)
503 return -errno;
504
505 if (ioctl(fd, VT_GETSTATE, &vt_stat) < 0)
506 r = -errno;
507 else
508 r = !!(vt_stat.v_state & (1 << vtnr));
509
510 return r;
511 }
512
513 int manager_spawn_autovt(Manager *m, unsigned vtnr) {
514 _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
515 char name[sizeof("autovt@tty.service") + DECIMAL_STR_MAX(unsigned)];
516 int r;
517
518 assert(m);
519 assert(vtnr >= 1);
520
521 if (vtnr > m->n_autovts &&
522 vtnr != m->reserve_vt)
523 return 0;
524
525 if (vtnr != m->reserve_vt) {
526 /* If this is the reserved TTY, we'll start the getty
527 * on it in any case, but otherwise only if it is not
528 * busy. */
529
530 r = vt_is_busy(vtnr);
531 if (r < 0)
532 return r;
533 else if (r > 0)
534 return -EBUSY;
535 }
536
537 xsprintf(name, "autovt@tty%u.service", vtnr);
538 r = sd_bus_call_method(
539 m->bus,
540 "org.freedesktop.systemd1",
541 "/org/freedesktop/systemd1",
542 "org.freedesktop.systemd1.Manager",
543 "StartUnit",
544 &error,
545 NULL,
546 "ss", name, "fail");
547 if (r < 0)
548 return log_error_errno(r, "Failed to start %s: %s", name, bus_error_message(&error, r));
549
550 return 0;
551 }
552
553 bool manager_is_lid_closed(Manager *m) {
554 Button *b;
555
556 HASHMAP_FOREACH(b, m->buttons)
557 if (b->lid_closed)
558 return true;
559
560 return false;
561 }
562
563 static bool manager_is_docked(Manager *m) {
564 Button *b;
565
566 HASHMAP_FOREACH(b, m->buttons)
567 if (b->docked)
568 return true;
569
570 return false;
571 }
572
573 static int manager_count_external_displays(Manager *m) {
574 _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
575 sd_device *d;
576 int r, n = 0;
577
578 r = sd_device_enumerator_new(&e);
579 if (r < 0)
580 return r;
581
582 r = sd_device_enumerator_allow_uninitialized(e);
583 if (r < 0)
584 return r;
585
586 r = sd_device_enumerator_add_match_subsystem(e, "drm", true);
587 if (r < 0)
588 return r;
589
590 FOREACH_DEVICE(e, d) {
591 const char *status, *enabled, *dash, *nn, *subsys;
592 sd_device *p;
593
594 if (sd_device_get_parent(d, &p) < 0)
595 continue;
596
597 /* If the parent shares the same subsystem as the
598 * device we are looking at then it is a connector,
599 * which is what we are interested in. */
600 if (sd_device_get_subsystem(p, &subsys) < 0 || !streq(subsys, "drm"))
601 continue;
602
603 if (sd_device_get_sysname(d, &nn) < 0)
604 continue;
605
606 /* Ignore internal displays: the type is encoded in the sysfs name, as the second dash
607 * separated item (the first is the card name, the last the connector number). We implement a
608 * deny list of external displays here, rather than an allow list of internal ones, to ensure
609 * we don't block suspends too eagerly. */
610 dash = strchr(nn, '-');
611 if (!dash)
612 continue;
613
614 dash++;
615 if (!STARTSWITH_SET(dash,
616 "VGA-", "DVI-I-", "DVI-D-", "DVI-A-"
617 "Composite-", "SVIDEO-", "Component-",
618 "DIN-", "DP-", "HDMI-A-", "HDMI-B-", "TV-"))
619 continue;
620
621 /* Ignore ports that are not enabled */
622 if (sd_device_get_sysattr_value(d, "enabled", &enabled) < 0 || !streq(enabled, "enabled"))
623 continue;
624
625 /* We count any connector which is not explicitly
626 * "disconnected" as connected. */
627 if (sd_device_get_sysattr_value(d, "status", &status) < 0 || !streq(status, "disconnected"))
628 n++;
629 }
630
631 return n;
632 }
633
634 bool manager_is_docked_or_external_displays(Manager *m) {
635 int n;
636
637 /* If we are docked don't react to lid closing */
638 if (manager_is_docked(m)) {
639 log_debug("System is docked.");
640 return true;
641 }
642
643 /* If we have more than one display connected,
644 * assume that we are docked. */
645 n = manager_count_external_displays(m);
646 if (n < 0)
647 log_warning_errno(n, "Display counting failed: %m");
648 else if (n >= 1) {
649 log_debug("External (%i) displays connected.", n);
650 return true;
651 }
652
653 return false;
654 }
655
656 bool manager_is_on_external_power(void) {
657 int r;
658
659 /* For now we only check for AC power, but 'external power' can apply to anything that isn't an internal
660 * battery */
661 r = on_ac_power();
662 if (r < 0)
663 log_warning_errno(r, "Failed to read AC power status: %m");
664
665 return r != 0; /* Treat failure as 'on AC' */
666 }
667
668 bool manager_all_buttons_ignored(Manager *m) {
669 assert(m);
670
671 if (m->handle_power_key != HANDLE_IGNORE)
672 return false;
673 if (m->handle_suspend_key != HANDLE_IGNORE)
674 return false;
675 if (m->handle_hibernate_key != HANDLE_IGNORE)
676 return false;
677 if (m->handle_lid_switch != HANDLE_IGNORE)
678 return false;
679 if (!IN_SET(m->handle_lid_switch_ep, _HANDLE_ACTION_INVALID, HANDLE_IGNORE))
680 return false;
681 if (m->handle_lid_switch_docked != HANDLE_IGNORE)
682 return false;
683 if (m->handle_reboot_key != HANDLE_IGNORE)
684 return false;
685
686 return true;
687 }
688
689 int manager_read_utmp(Manager *m) {
690 #if ENABLE_UTMP
691 int r;
692 _cleanup_(utxent_cleanup) bool utmpx = false;
693
694 assert(m);
695
696 if (utmpxname(_PATH_UTMPX) < 0)
697 return log_error_errno(errno, "Failed to set utmp path to " _PATH_UTMPX ": %m");
698
699 utmpx = utxent_start();
700
701 for (;;) {
702 _cleanup_free_ char *t = NULL;
703 struct utmpx *u;
704 const char *c;
705 Session *s;
706
707 errno = 0;
708 u = getutxent();
709 if (!u) {
710 if (errno != 0)
711 log_warning_errno(errno, "Failed to read " _PATH_UTMPX ", ignoring: %m");
712 return 0;
713 }
714
715 if (u->ut_type != USER_PROCESS)
716 continue;
717
718 if (!pid_is_valid(u->ut_pid))
719 continue;
720
721 t = strndup(u->ut_line, sizeof(u->ut_line));
722 if (!t)
723 return log_oom();
724
725 c = path_startswith(t, "/dev/");
726 if (c) {
727 r = free_and_strdup(&t, c);
728 if (r < 0)
729 return log_oom();
730 }
731
732 if (isempty(t))
733 continue;
734
735 s = hashmap_get(m->sessions_by_leader, PID_TO_PTR(u->ut_pid));
736 if (!s)
737 continue;
738
739 if (s->tty_validity == TTY_FROM_UTMP && !streq_ptr(s->tty, t)) {
740 /* This may happen on multiplexed SSH connection (i.e. 'SSH connection sharing'). In
741 * this case PAM and utmp sessions don't match. In such a case let's invalidate the TTY
742 * information and never acquire it again. */
743
744 s->tty = mfree(s->tty);
745 s->tty_validity = TTY_UTMP_INCONSISTENT;
746 log_debug("Session '%s' has inconsistent TTY information, dropping TTY information.", s->id);
747 continue;
748 }
749
750 /* Never override what we figured out once */
751 if (s->tty || s->tty_validity >= 0)
752 continue;
753
754 s->tty = TAKE_PTR(t);
755 s->tty_validity = TTY_FROM_UTMP;
756 log_debug("Acquired TTY information '%s' from utmp for session '%s'.", s->tty, s->id);
757 }
758
759 #else
760 return 0;
761 #endif
762 }
763
764 #if ENABLE_UTMP
765 static int manager_dispatch_utmp(sd_event_source *s, const struct inotify_event *event, void *userdata) {
766 Manager *m = userdata;
767
768 assert(m);
769
770 /* If there's indication the file itself might have been removed or became otherwise unavailable, then let's
771 * reestablish the watch on whatever there's now. */
772 if ((event->mask & (IN_ATTRIB|IN_DELETE_SELF|IN_MOVE_SELF|IN_Q_OVERFLOW|IN_UNMOUNT)) != 0)
773 manager_connect_utmp(m);
774
775 (void) manager_read_utmp(m);
776 return 0;
777 }
778 #endif
779
780 void manager_connect_utmp(Manager *m) {
781 #if ENABLE_UTMP
782 sd_event_source *s = NULL;
783 int r;
784
785 assert(m);
786
787 /* Watch utmp for changes via inotify. We do this to deal with tools such as ssh, which will register the PAM
788 * session early, and acquire a TTY only much later for the connection. Thus during PAM the TTY won't be known
789 * yet. ssh will register itself with utmp when it finally acquired the TTY. Hence, let's make use of this, and
790 * watch utmp for the TTY asynchronously. We use the PAM session's leader PID as key, to find the right entry.
791 *
792 * Yes, relying on utmp is pretty ugly, but it's good enough for informational purposes, as well as idle
793 * detection (which, for tty sessions, relies on the TTY used) */
794
795 r = sd_event_add_inotify(m->event, &s, _PATH_UTMPX, IN_MODIFY|IN_MOVE_SELF|IN_DELETE_SELF|IN_ATTRIB, manager_dispatch_utmp, m);
796 if (r < 0)
797 log_full_errno(r == -ENOENT ? LOG_DEBUG: LOG_WARNING, r, "Failed to create inotify watch on " _PATH_UTMPX ", ignoring: %m");
798 else {
799 r = sd_event_source_set_priority(s, SD_EVENT_PRIORITY_IDLE);
800 if (r < 0)
801 log_warning_errno(r, "Failed to adjust utmp event source priority, ignoring: %m");
802
803 (void) sd_event_source_set_description(s, "utmp");
804 }
805
806 sd_event_source_unref(m->utmp_event_source);
807 m->utmp_event_source = s;
808 #endif
809 }
810
811 void manager_reconnect_utmp(Manager *m) {
812 #if ENABLE_UTMP
813 assert(m);
814
815 if (m->utmp_event_source)
816 return;
817
818 manager_connect_utmp(m);
819 #endif
820 }
821
822 int manager_read_efi_boot_loader_entries(Manager *m) {
823 #if ENABLE_EFI
824 int r;
825
826 assert(m);
827 if (m->efi_boot_loader_entries_set)
828 return 0;
829
830 r = efi_loader_get_entries(&m->efi_boot_loader_entries);
831 if (r == -ENOENT || ERRNO_IS_NOT_SUPPORTED(r)) {
832 log_debug_errno(r, "Boot loader reported no entries.");
833 m->efi_boot_loader_entries_set = true;
834 return 0;
835 }
836 if (r < 0)
837 return log_error_errno(r, "Failed to determine entries reported by boot loader: %m");
838
839 m->efi_boot_loader_entries_set = true;
840 return 1;
841 #else
842 return 0;
843 #endif
844 }