2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2012-07-18 19:07:51 +02:00
|
|
|
#pragma once
|
2011-05-24 00:19:22 +02:00
|
|
|
|
|
|
|
typedef struct User User;
|
|
|
|
|
2018-05-22 13:10:17 +02:00
|
|
|
#include "conf-parser.h"
|
2011-05-24 00:19:22 +02:00
|
|
|
#include "list.h"
|
|
|
|
#include "logind.h"
|
|
|
|
|
|
|
|
typedef enum UserState {
|
2012-06-21 16:14:53 +02:00
|
|
|
USER_OFFLINE, /* Not logged in at all */
|
2013-07-02 01:46:30 +02:00
|
|
|
USER_OPENING, /* Is logging in */
|
2012-06-21 16:14:53 +02:00
|
|
|
USER_LINGERING, /* Lingering has been enabled by the admin for this user */
|
|
|
|
USER_ONLINE, /* User logged in */
|
|
|
|
USER_ACTIVE, /* User logged in and has a session in the fg */
|
|
|
|
USER_CLOSING, /* User logged out, but processes still remain and lingering is not enabled */
|
2011-05-24 00:19:22 +02:00
|
|
|
_USER_STATE_MAX,
|
|
|
|
_USER_STATE_INVALID = -1
|
|
|
|
} UserState;
|
|
|
|
|
|
|
|
struct User {
|
|
|
|
Manager *manager;
|
|
|
|
uid_t uid;
|
|
|
|
gid_t gid;
|
|
|
|
char *name;
|
|
|
|
char *state_file;
|
|
|
|
char *runtime_path;
|
2013-06-20 03:45:08 +02:00
|
|
|
char *slice;
|
2015-09-29 11:20:52 +02:00
|
|
|
char *service;
|
2011-05-24 00:19:22 +02:00
|
|
|
|
2013-07-02 01:46:30 +02:00
|
|
|
char *service_job;
|
|
|
|
char *slice_job;
|
|
|
|
|
2011-05-24 00:19:22 +02:00
|
|
|
Session *display;
|
|
|
|
|
|
|
|
dual_timestamp timestamp;
|
|
|
|
|
2011-05-25 00:55:58 +02:00
|
|
|
bool in_gc_queue:1;
|
2011-06-21 21:46:13 +02:00
|
|
|
bool started:1;
|
2014-02-06 18:32:14 +01:00
|
|
|
bool stopping:1;
|
2011-05-25 00:55:58 +02:00
|
|
|
|
2011-05-24 00:19:22 +02:00
|
|
|
LIST_HEAD(Session, sessions);
|
2011-05-25 00:55:58 +02:00
|
|
|
LIST_FIELDS(User, gc_queue);
|
2011-05-24 00:19:22 +02:00
|
|
|
};
|
|
|
|
|
2015-09-29 11:10:01 +02:00
|
|
|
int user_new(User **out, Manager *m, uid_t uid, gid_t gid, const char *name);
|
|
|
|
User *user_free(User *u);
|
|
|
|
|
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(User *, user_free);
|
|
|
|
|
2018-02-15 13:14:35 +01:00
|
|
|
bool user_may_gc(User *u, bool drop_not_started);
|
2011-05-25 00:55:58 +02:00
|
|
|
void user_add_to_gc_queue(User *u);
|
2011-05-24 00:19:22 +02:00
|
|
|
int user_start(User *u);
|
2014-02-09 02:29:56 +01:00
|
|
|
int user_stop(User *u, bool force);
|
2013-08-13 17:59:28 +02:00
|
|
|
int user_finalize(User *u);
|
2011-05-24 00:19:22 +02:00
|
|
|
UserState user_get_state(User *u);
|
2011-06-17 15:59:18 +02:00
|
|
|
int user_get_idle_hint(User *u, dual_timestamp *t);
|
2011-05-24 00:19:22 +02:00
|
|
|
int user_save(User *u);
|
|
|
|
int user_load(User *u);
|
2011-07-13 19:58:35 +02:00
|
|
|
int user_kill(User *u, int signo);
|
2013-11-05 01:27:27 +01:00
|
|
|
int user_check_linger_file(User *u);
|
2014-05-19 02:03:20 +02:00
|
|
|
void user_elect_display(User *u);
|
2011-05-24 00:19:22 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
extern const sd_bus_vtable user_vtable[];
|
2013-11-22 01:14:57 +01:00
|
|
|
int user_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error);
|
|
|
|
int user_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error);
|
2011-05-26 02:21:16 +02:00
|
|
|
char *user_bus_path(User *s);
|
|
|
|
|
2011-06-21 20:43:34 +02:00
|
|
|
int user_send_signal(User *u, bool new_user);
|
2013-11-05 01:10:21 +01:00
|
|
|
int user_send_changed(User *u, const char *properties, ...) _sentinel_;
|
2011-06-21 20:43:34 +02:00
|
|
|
|
2013-05-03 04:51:50 +02:00
|
|
|
const char* user_state_to_string(UserState s) _const_;
|
|
|
|
UserState user_state_from_string(const char *s) _pure_;
|
2015-02-18 12:55:25 +01:00
|
|
|
|
2015-04-29 18:35:10 +02:00
|
|
|
int bus_user_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error);
|
|
|
|
int bus_user_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error);
|
2017-12-07 22:25:26 +01:00
|
|
|
|
2018-05-22 13:10:17 +02:00
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_compat_user_tasks_max);
|