logind-user.h revision 3a9f7a30ce89b44097731310221802f6d72ea752
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen#pragma once
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen/***
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen This file is part of systemd.
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen Copyright 2011 Lennart Poettering
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen systemd is free software; you can redistribute it and/or modify it
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen under the terms of the GNU Lesser General Public License as published by
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen the Free Software Foundation; either version 2.1 of the License, or
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen (at your option) any later version.
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen systemd is distributed in the hope that it will be useful, but
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen WITHOUT ANY WARRANTY; without even the implied warranty of
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen Lesser General Public License for more details.
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen You should have received a copy of the GNU Lesser General Public License
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen***/
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersentypedef struct User User;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen#include "list.h"
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen#include "util.h"
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen#include "logind.h"
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen#include "logind-session.h"
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersentypedef enum UserState {
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen USER_OFFLINE, /* Not logged in at all */
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen USER_OPENING, /* Is logging in */
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen USER_LINGERING, /* Lingering has been enabled by the admin for this user */
c62c294fd521e5b65bb52f831773916bbc4cd90aThomas Hindoe Paaboel Andersen USER_ONLINE, /* User logged in */
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen USER_ACTIVE, /* User logged in and has a session in the fg */
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen USER_CLOSING, /* User logged out, but processes still remain and lingering is not enabled */
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen _USER_STATE_MAX,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen _USER_STATE_INVALID = -1
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen} UserState;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenstruct User {
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen Manager *manager;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen uid_t uid;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen gid_t gid;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen char *name;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen char *state_file;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen char *runtime_path;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen char *service;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen char *slice;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen char *service_job;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen char *slice_job;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen Session *display;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen dual_timestamp timestamp;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen bool in_gc_queue:1;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen bool started:1;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen bool closing:1;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen LIST_HEAD(Session, sessions);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen LIST_FIELDS(User, gc_queue);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen};
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel AndersenUser* user_new(Manager *m, uid_t uid, gid_t gid, const char *name);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenvoid user_free(User *u);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenbool user_check_gc(User *u, bool drop_not_started);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenvoid user_add_to_gc_queue(User *u);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenint user_start(User *u);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenint user_stop(User *u);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenint user_finalize(User *u);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel AndersenUserState user_get_state(User *u);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenint user_get_idle_hint(User *u, dual_timestamp *t);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenint user_save(User *u);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenint user_load(User *u);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenint user_kill(User *u, int signo);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenint user_check_linger_file(User *u);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenextern const sd_bus_vtable user_vtable[];
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenint user_node_enumerator(sd_bus *bus, const char *path, char ***nodes, void *userdata);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenint user_object_find(sd_bus *bus, const char *path, const char *interface, void **found, void *userdata);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenchar *user_bus_path(User *s);
f168c27313e4d7b0aabee037dc9c78a5799f0597Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenint user_send_signal(User *u, bool new_user);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenint user_send_changed(User *u, const char *properties, ...) _sentinel_;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersenconst char* user_state_to_string(UserState s) _const_;
UserState user_state_from_string(const char *s) _pure_;