]>
Commit | Line | Data |
---|---|---|
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 | ||
23 | typedef struct User User; | |
24 | ||
25 | #include "list.h" | |
90821c93 | 26 | #include "logind.h" |
90821c93 LP |
27 | |
28 | typedef 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 | ||
39 | struct 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 |
64 | int user_new(User **out, Manager *m, uid_t uid, gid_t gid, const char *name); |
65 | User *user_free(User *u); | |
66 | ||
67 | DEFINE_TRIVIAL_CLEANUP_FUNC(User *, user_free); | |
68 | ||
cc377381 | 69 | bool user_check_gc(User *u, bool drop_not_started); |
14c3baca | 70 | void user_add_to_gc_queue(User *u); |
90821c93 | 71 | int user_start(User *u); |
9bb69af4 | 72 | int user_stop(User *u, bool force); |
405e0255 | 73 | int user_finalize(User *u); |
90821c93 | 74 | UserState user_get_state(User *u); |
a185c5aa | 75 | int user_get_idle_hint(User *u, dual_timestamp *t); |
90821c93 LP |
76 | int user_save(User *u); |
77 | int user_load(User *u); | |
de07ab16 | 78 | int user_kill(User *u, int signo); |
3a9f7a30 | 79 | int user_check_linger_file(User *u); |
952d3260 | 80 | void user_elect_display(User *u); |
90821c93 | 81 | |
cc377381 | 82 | extern const sd_bus_vtable user_vtable[]; |
f00c3121 LP |
83 | int user_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error); |
84 | int user_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error); | |
3f49d45a LP |
85 | char *user_bus_path(User *s); |
86 | ||
da119395 | 87 | int user_send_signal(User *u, bool new_user); |
cc377381 | 88 | int user_send_changed(User *u, const char *properties, ...) _sentinel_; |
da119395 | 89 | |
44a6b1b6 ZJS |
90 | const char* user_state_to_string(UserState s) _const_; |
91 | UserState user_state_from_string(const char *s) _pure_; | |
c529695e | 92 | |
19070062 LP |
93 | int bus_user_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error); |
94 | int bus_user_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error); |