1 /* SPDX-License-Identifier: LGPL-2.1+ */
4 typedef struct User User
;
6 #include "conf-parser.h"
10 typedef enum UserState
{
11 USER_OFFLINE
, /* Not logged in at all */
12 USER_OPENING
, /* Is logging in */
13 USER_LINGERING
, /* Lingering has been enabled by the admin for this user */
14 USER_ONLINE
, /* User logged in */
15 USER_ACTIVE
, /* User logged in and has a session in the fg */
16 USER_CLOSING
, /* User logged out, but processes still remain and lingering is not enabled */
18 _USER_STATE_INVALID
= -1
30 char *slice
; /* user-UID.slice */
31 char *service
; /* user@UID.service */
32 char *runtime_dir_service
; /* user-runtime-dir@UID.service */
38 dual_timestamp timestamp
; /* When this User object was 'started' the first time */
39 usec_t last_session_timestamp
; /* When the number of sessions of this user went from 1 to 0 the last time */
41 /* Set up when the last session of the user logs out */
42 sd_event_source
*timer_event_source
;
46 bool started
:1; /* Whenever the user being started, has been started or is being stopped again. */
47 bool stopping
:1; /* Whenever the user is being stopped or has been stopped. */
49 LIST_HEAD(Session
, sessions
);
50 LIST_FIELDS(User
, gc_queue
);
53 int user_new(User
**out
, Manager
*m
, uid_t uid
, gid_t gid
, const char *name
, const char *home
);
54 User
*user_free(User
*u
);
56 DEFINE_TRIVIAL_CLEANUP_FUNC(User
*, user_free
);
58 bool user_may_gc(User
*u
, bool drop_not_started
);
59 void user_add_to_gc_queue(User
*u
);
60 int user_start(User
*u
);
61 int user_stop(User
*u
, bool force
);
62 int user_finalize(User
*u
);
63 UserState
user_get_state(User
*u
);
64 int user_get_idle_hint(User
*u
, dual_timestamp
*t
);
65 int user_save(User
*u
);
66 int user_load(User
*u
);
67 int user_kill(User
*u
, int signo
);
68 int user_check_linger_file(User
*u
);
69 void user_elect_display(User
*u
);
70 void user_update_last_session_timer(User
*u
);
72 extern const sd_bus_vtable user_vtable
[];
73 int user_node_enumerator(sd_bus
*bus
, const char *path
, void *userdata
, char ***nodes
, sd_bus_error
*error
);
74 int user_object_find(sd_bus
*bus
, const char *path
, const char *interface
, void *userdata
, void **found
, sd_bus_error
*error
);
75 char *user_bus_path(User
*s
);
77 int user_send_signal(User
*u
, bool new_user
);
78 int user_send_changed(User
*u
, const char *properties
, ...) _sentinel_
;
80 const char* user_state_to_string(UserState s
) _const_
;
81 UserState
user_state_from_string(const char *s
) _pure_
;
83 int bus_user_method_terminate(sd_bus_message
*message
, void *userdata
, sd_bus_error
*error
);
84 int bus_user_method_kill(sd_bus_message
*message
, void *userdata
, sd_bus_error
*error
);
86 CONFIG_PARSER_PROTOTYPE(config_parse_compat_user_tasks_max
);