logind.h revision 1389f4b95877f29cb357baee837d9c05e64df0c6
65410a6c1c900489c9028f7c235484f137e42df1sf/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
65410a6c1c900489c9028f7c235484f137e42df1sf
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd#pragma once
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd/***
65410a6c1c900489c9028f7c235484f137e42df1sf This file is part of systemd.
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sf Copyright 2011 Lennart Poettering
65410a6c1c900489c9028f7c235484f137e42df1sf
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc systemd is free software; you can redistribute it and/or modify it
65410a6c1c900489c9028f7c235484f137e42df1sf under the terms of the GNU Lesser General Public License as published by
65410a6c1c900489c9028f7c235484f137e42df1sf the Free Software Foundation; either version 2.1 of the License, or
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen (at your option) any later version.
2e545ce2450a9953665f701bb05350f0d3f26275nd
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen systemd is distributed in the hope that it will be useful, but
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen WITHOUT ANY WARRANTY; without even the implied warranty of
65410a6c1c900489c9028f7c235484f137e42df1sf MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
65410a6c1c900489c9028f7c235484f137e42df1sf Lesser General Public License for more details.
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen
3f08db06526d6901aa08c110b5bc7dde6bc39905nd You should have received a copy of the GNU Lesser General Public License
65410a6c1c900489c9028f7c235484f137e42df1sf along with systemd; If not, see <http://www.gnu.org/licenses/>.
65410a6c1c900489c9028f7c235484f137e42df1sf***/
65410a6c1c900489c9028f7c235484f137e42df1sf
3f08db06526d6901aa08c110b5bc7dde6bc39905nd#include <stdbool.h>
65410a6c1c900489c9028f7c235484f137e42df1sf#include <libudev.h>
8e9c6d6438af1ccb46adaa60d34caa3ac98f3851igalic
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung#include "sd-event.h"
65410a6c1c900489c9028f7c235484f137e42df1sf#include "sd-bus.h"
65410a6c1c900489c9028f7c235484f137e42df1sf#include "list.h"
4cbff57fa97f2fce73b84102fa4f58ed8ea7a92end#include "hashmap.h"
4cbff57fa97f2fce73b84102fa4f58ed8ea7a92end#include "set.h"
4cbff57fa97f2fce73b84102fa4f58ed8ea7a92end
4cbff57fa97f2fce73b84102fa4f58ed8ea7a92endtypedef struct Manager Manager;
4cbff57fa97f2fce73b84102fa4f58ed8ea7a92end
65410a6c1c900489c9028f7c235484f137e42df1sf#include "logind-device.h"
f9442c8a9869d3525a1ae6ed3e85c65d408e8a70sf#include "logind-inhibit.h"
4cbff57fa97f2fce73b84102fa4f58ed8ea7a92end#include "logind-button.h"
4cbff57fa97f2fce73b84102fa4f58ed8ea7a92end#include "logind-action.h"
65410a6c1c900489c9028f7c235484f137e42df1sf
7159c12b7697fe9f5ab3a533cc6dfc3d57803053igalicstruct Manager {
65410a6c1c900489c9028f7c235484f137e42df1sf sd_event *event;
65410a6c1c900489c9028f7c235484f137e42df1sf sd_bus *bus;
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sf Hashmap *devices;
b50909667b85d487fe0cd963db094f48d6ccdaf7humbedooh Hashmap *seats;
02c4e4fe19f1120c6bdf561950ab60077c61cc5fsf Hashmap *sessions;
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf Hashmap *users;
10a8bf3f22c70c4cb3cecda054e487e3f6fd75bfrjung Hashmap *inhibitors;
07fffcc8a67e1940622deebc428a9b712930d2d7minfrin Hashmap *buttons;
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sf LIST_HEAD(Seat, seat_gc_queue);
7159c12b7697fe9f5ab3a533cc6dfc3d57803053igalic LIST_HEAD(Session, session_gc_queue);
65410a6c1c900489c9028f7c235484f137e42df1sf LIST_HEAD(User, user_gc_queue);
4cbff57fa97f2fce73b84102fa4f58ed8ea7a92end
4cbff57fa97f2fce73b84102fa4f58ed8ea7a92end struct udev *udev;
4cbff57fa97f2fce73b84102fa4f58ed8ea7a92end struct udev_monitor *udev_seat_monitor, *udev_device_monitor, *udev_vcsa_monitor, *udev_button_monitor;
9a74115b71b8e85c015b4005e0313fca86ea9c59jailletc
9a74115b71b8e85c015b4005e0313fca86ea9c59jailletc sd_event_source *console_active_event_source;
4cbff57fa97f2fce73b84102fa4f58ed8ea7a92end sd_event_source *udev_seat_event_source;
4cbff57fa97f2fce73b84102fa4f58ed8ea7a92end sd_event_source *udev_device_event_source;
4cbff57fa97f2fce73b84102fa4f58ed8ea7a92end sd_event_source *udev_vcsa_event_source;
a343f97443af94a56b903dfa1226eddcccf32b66gryzor sd_event_source *udev_button_event_source;
9a74115b71b8e85c015b4005e0313fca86ea9c59jailletc
4aa603e6448b99f9371397d439795c91a93637eand int console_active_fd;
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sf unsigned n_autovts;
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sf unsigned reserve_vt;
65410a6c1c900489c9028f7c235484f137e42df1sf int reserve_vt_fd;
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sf Seat *seat0;
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sf char **kill_only_users, **kill_exclude_users;
65410a6c1c900489c9028f7c235484f137e42df1sf bool kill_user_processes;
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sf unsigned long session_counter;
65410a6c1c900489c9028f7c235484f137e42df1sf unsigned long inhibit_counter;
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sf Hashmap *session_units;
65410a6c1c900489c9028f7c235484f137e42df1sf Hashmap *user_units;
02c4e4fe19f1120c6bdf561950ab60077c61cc5fsf
02c4e4fe19f1120c6bdf561950ab60077c61cc5fsf usec_t inhibit_delay_max;
02c4e4fe19f1120c6bdf561950ab60077c61cc5fsf
02c4e4fe19f1120c6bdf561950ab60077c61cc5fsf /* If an action is currently being executed or is delayed,
02c4e4fe19f1120c6bdf561950ab60077c61cc5fsf * this is != 0 and encodes what is being done */
02c4e4fe19f1120c6bdf561950ab60077c61cc5fsf InhibitWhat action_what;
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sf /* If a shutdown/suspend was delayed due to a inhibitor this
65410a6c1c900489c9028f7c235484f137e42df1sf contains the unit name we are supposed to start after the
65410a6c1c900489c9028f7c235484f137e42df1sf delay is over */
65410a6c1c900489c9028f7c235484f137e42df1sf const char *action_unit;
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sf /* If a shutdown/suspend is currently executed, then this is
65410a6c1c900489c9028f7c235484f137e42df1sf * the job of it */
65410a6c1c900489c9028f7c235484f137e42df1sf char *action_job;
65410a6c1c900489c9028f7c235484f137e42df1sf sd_event_source *inhibit_timeout_source;
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sf char *scheduled_shutdown_type;
65410a6c1c900489c9028f7c235484f137e42df1sf usec_t scheduled_shutdown_timeout;
65410a6c1c900489c9028f7c235484f137e42df1sf sd_event_source *scheduled_shutdown_timeout_source;
65410a6c1c900489c9028f7c235484f137e42df1sf uid_t scheduled_shutdown_uid;
65410a6c1c900489c9028f7c235484f137e42df1sf char *scheduled_shutdown_tty;
02c4e4fe19f1120c6bdf561950ab60077c61cc5fsf sd_event_source *nologin_timeout_source;
65410a6c1c900489c9028f7c235484f137e42df1sf bool unlink_nologin;
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sf char *wall_message;
65410a6c1c900489c9028f7c235484f137e42df1sf unsigned enable_wall_messages;
65410a6c1c900489c9028f7c235484f137e42df1sf sd_event_source *wall_message_timeout_source;
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sf bool shutdown_dry_run;
02c4e4fe19f1120c6bdf561950ab60077c61cc5fsf
65410a6c1c900489c9028f7c235484f137e42df1sf sd_event_source *idle_action_event_source;
65410a6c1c900489c9028f7c235484f137e42df1sf usec_t idle_action_usec;
65410a6c1c900489c9028f7c235484f137e42df1sf usec_t idle_action_not_before_usec;
65410a6c1c900489c9028f7c235484f137e42df1sf HandleAction idle_action;
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sf HandleAction handle_power_key;
65410a6c1c900489c9028f7c235484f137e42df1sf HandleAction handle_suspend_key;
02c4e4fe19f1120c6bdf561950ab60077c61cc5fsf HandleAction handle_hibernate_key;
02c4e4fe19f1120c6bdf561950ab60077c61cc5fsf HandleAction handle_lid_switch;
172025a566937b5a0492a7060e4ba52f121047f4covener HandleAction handle_lid_switch_docked;
65410a6c1c900489c9028f7c235484f137e42df1sf
4aa603e6448b99f9371397d439795c91a93637eand bool power_key_ignore_inhibited;
9a74115b71b8e85c015b4005e0313fca86ea9c59jailletc bool suspend_key_ignore_inhibited;
65410a6c1c900489c9028f7c235484f137e42df1sf bool hibernate_key_ignore_inhibited;
65410a6c1c900489c9028f7c235484f137e42df1sf bool lid_switch_ignore_inhibited;
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sf bool remove_ipc;
65410a6c1c900489c9028f7c235484f137e42df1sf
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sf Hashmap *polkit_registry;
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sf
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sf usec_t holdoff_timeout_usec;
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sf sd_event_source *lid_switch_ignore_event_source;
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sf
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sf size_t runtime_dir_size;
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sf};
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sf
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sfint manager_add_device(Manager *m, const char *sysfs, bool master, Device **_device);
e9d6361d862c6b6ac889c9f2763112f3a90d8e83humbedoohint manager_add_button(Manager *m, const char *name, Button **_button);
c11bfe6804eff2f4c7054cf2f7b06f0c8b32e596sfint manager_add_seat(Manager *m, const char *id, Seat **_seat);
c11bfe6804eff2f4c7054cf2f7b06f0c8b32e596sfint manager_add_session(Manager *m, const char *id, Session **_session);
c11bfe6804eff2f4c7054cf2f7b06f0c8b32e596sfint manager_add_user(Manager *m, uid_t uid, gid_t gid, const char *name, User **_user);
a53a4e3dd20966aa123640e6639e75545c1e4768sfint manager_add_user_by_name(Manager *m, const char *name, User **_user);
a53a4e3dd20966aa123640e6639e75545c1e4768sfint manager_add_user_by_uid(Manager *m, uid_t uid, User **_user);
a53a4e3dd20966aa123640e6639e75545c1e4768sfint manager_add_inhibitor(Manager *m, const char* id, Inhibitor **_inhibitor);
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sfint manager_process_seat_device(Manager *m, struct udev_device *d);
65410a6c1c900489c9028f7c235484f137e42df1sfint manager_process_button_device(Manager *m, struct udev_device *d);
9a74115b71b8e85c015b4005e0313fca86ea9c59jailletc
9a74115b71b8e85c015b4005e0313fca86ea9c59jailletcint manager_spawn_autovt(Manager *m, unsigned int vtnr);
9a74115b71b8e85c015b4005e0313fca86ea9c59jailletc
9a74115b71b8e85c015b4005e0313fca86ea9c59jailletcbool manager_shall_kill(Manager *m, const char *user);
9a74115b71b8e85c015b4005e0313fca86ea9c59jailletc
9a74115b71b8e85c015b4005e0313fca86ea9c59jailletcint manager_get_idle_hint(Manager *m, dual_timestamp *t);
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sfint manager_get_user_by_pid(Manager *m, pid_t pid, User **user);
65410a6c1c900489c9028f7c235484f137e42df1sfint manager_get_session_by_pid(Manager *m, pid_t pid, Session **session);
65410a6c1c900489c9028f7c235484f137e42df1sf
65410a6c1c900489c9028f7c235484f137e42df1sfbool manager_is_docked_or_external_displays(Manager *m);
65410a6c1c900489c9028f7c235484f137e42df1sf
63581ee088272ef76aa8d053609dc1705c222deesfextern const sd_bus_vtable manager_vtable[];
75958e95ce626be1ddfe5ba9d2317c607f3ed3fasf
65410a6c1c900489c9028f7c235484f137e42df1sfint match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *error);
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sfint match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *error);
65410a6c1c900489c9028f7c235484f137e42df1sfint match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_error *error);
0844fff26cb7719e0f0a368d88544156ed6374b6sfint match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error);
fcd7f1f7d11d39b8379972a455e1c7e67a5dfa9dsfint match_name_owner_changed(sd_bus_message *message, void *userdata, sd_bus_error *error);
9a74115b71b8e85c015b4005e0313fca86ea9c59jailletc
fcd7f1f7d11d39b8379972a455e1c7e67a5dfa9dsfint bus_manager_shutdown_or_sleep_now_or_later(Manager *m, const char *unit_name, InhibitWhat w, sd_bus_error *error);
f9442c8a9869d3525a1ae6ed3e85c65d408e8a70sf
f9442c8a9869d3525a1ae6ed3e85c65d408e8a70sfint manager_send_changed(Manager *manager, const char *property, ...) _sentinel_;
f9442c8a9869d3525a1ae6ed3e85c65d408e8a70sf
f9442c8a9869d3525a1ae6ed3e85c65d408e8a70sfint manager_start_scope(Manager *manager, const char *scope, pid_t pid, const char *slice, const char *description, const char *after, const char *after2, sd_bus_error *error, char **job);
f9442c8a9869d3525a1ae6ed3e85c65d408e8a70sfint manager_start_unit(Manager *manager, const char *unit, sd_bus_error *error, char **job);
fcd7f1f7d11d39b8379972a455e1c7e67a5dfa9dsfint manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, char **job);
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sfint manager_abandon_scope(Manager *manager, const char *scope, sd_bus_error *error);
fcd7f1f7d11d39b8379972a455e1c7e67a5dfa9dsfint manager_kill_unit(Manager *manager, const char *unit, KillWho who, int signo, sd_bus_error *error);
fcd7f1f7d11d39b8379972a455e1c7e67a5dfa9dsfint manager_unit_is_active(Manager *manager, const char *unit);
fcd7f1f7d11d39b8379972a455e1c7e67a5dfa9dsfint manager_job_is_active(Manager *manager, const char *path);
fcd7f1f7d11d39b8379972a455e1c7e67a5dfa9dsf
fcd7f1f7d11d39b8379972a455e1c7e67a5dfa9dsf/* gperf lookup function */
7dffdb75ed6be39c05d25cc5f60334a9b73be7acsfconst struct ConfigPerfItem* logind_gperf_lookup(const char *key, unsigned length);
7dffdb75ed6be39c05d25cc5f60334a9b73be7acsf
7dffdb75ed6be39c05d25cc5f60334a9b73be7acsfint manager_set_lid_switch_ignore(Manager *m, usec_t until);
7dffdb75ed6be39c05d25cc5f60334a9b73be7acsf
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sfint config_parse_tmpfs_size(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
f9442c8a9869d3525a1ae6ed3e85c65d408e8a70sf
f9442c8a9869d3525a1ae6ed3e85c65d408e8a70sfint manager_get_session_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Session **ret);
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sfint manager_get_user_from_creds(Manager *m, sd_bus_message *message, uid_t uid, sd_bus_error *error, User **ret);
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sfint manager_get_seat_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Seat **ret);
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sf
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sfint manager_setup_wall_message_timer(Manager *m);
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sfbool logind_wall_tty_filter(const char *tty, void *userdata);
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sf
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sfint manager_dispatch_delayed(Manager *manager, bool timeout);
7b0d7e264bfafbd2386a1a94e59d4628335b8f29sf