]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/login/logind-user.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / login / logind-user.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
c2f1db8f 2#pragma once
90821c93
LP
3
4/***
5 This file is part of systemd.
6
7 Copyright 2011 Lennart Poettering
8
9 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
90821c93
LP
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2 17 Lesser General Public License for more details.
90821c93 18
5430f7f2 19 You should have received a copy of the GNU Lesser General Public License
90821c93
LP
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21***/
22
23typedef struct User User;
24
25#include "list.h"
90821c93 26#include "logind.h"
90821c93
LP
27
28typedef enum UserState {
0604381b 29 USER_OFFLINE, /* Not logged in at all */
fb6becb4 30 USER_OPENING, /* Is logging in */
0604381b
LP
31 USER_LINGERING, /* Lingering has been enabled by the admin for this user */
32 USER_ONLINE, /* User logged in */
33 USER_ACTIVE, /* User logged in and has a session in the fg */
34 USER_CLOSING, /* User logged out, but processes still remain and lingering is not enabled */
90821c93
LP
35 _USER_STATE_MAX,
36 _USER_STATE_INVALID = -1
37} UserState;
38
39struct User {
40 Manager *manager;
90821c93
LP
41 uid_t uid;
42 gid_t gid;
43 char *name;
90821c93
LP
44 char *state_file;
45 char *runtime_path;
9444b1f2 46 char *slice;
090d92bd 47 char *service;
90821c93 48
fb6becb4
LP
49 char *service_job;
50 char *slice_job;
51
90821c93
LP
52 Session *display;
53
54 dual_timestamp timestamp;
55
14c3baca 56 bool in_gc_queue:1;
9418f147 57 bool started:1;
5f41d1f1 58 bool stopping:1;
14c3baca 59
90821c93 60 LIST_HEAD(Session, sessions);
14c3baca 61 LIST_FIELDS(User, gc_queue);
90821c93
LP
62};
63
157f5057
DH
64int user_new(User **out, Manager *m, uid_t uid, gid_t gid, const char *name);
65User *user_free(User *u);
66
67DEFINE_TRIVIAL_CLEANUP_FUNC(User *, user_free);
68
cc377381 69bool user_check_gc(User *u, bool drop_not_started);
14c3baca 70void user_add_to_gc_queue(User *u);
90821c93 71int user_start(User *u);
9bb69af4 72int user_stop(User *u, bool force);
405e0255 73int user_finalize(User *u);
90821c93 74UserState user_get_state(User *u);
a185c5aa 75int user_get_idle_hint(User *u, dual_timestamp *t);
90821c93
LP
76int user_save(User *u);
77int user_load(User *u);
de07ab16 78int user_kill(User *u, int signo);
3a9f7a30 79int user_check_linger_file(User *u);
952d3260 80void user_elect_display(User *u);
90821c93 81
cc377381 82extern const sd_bus_vtable user_vtable[];
f00c3121
LP
83int user_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error);
84int user_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error);
3f49d45a
LP
85char *user_bus_path(User *s);
86
da119395 87int user_send_signal(User *u, bool new_user);
cc377381 88int user_send_changed(User *u, const char *properties, ...) _sentinel_;
da119395 89
44a6b1b6
ZJS
90const char* user_state_to_string(UserState s) _const_;
91UserState user_state_from_string(const char *s) _pure_;
c529695e 92
19070062
LP
93int bus_user_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error);
94int bus_user_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error);