|
Hermes 0.7.0
Linux game streaming host
|
Ask the privileged broker for a client's own Unix account, and for a session running under it. More...
#include <optional>#include <string>#include <sys/types.h>#include <vector>Go to the source code of this file.
Classes | |
| struct | platf::session_broker::account_t |
| The account a paired client owns. More... | |
Functions | |
| bool | platf::session_broker::available () |
| Whether a broker socket is there to talk to. | |
| std::optional< account_t > | platf::session_broker::ensure (const std::string &client_uuid) |
| The client's account, created if this is the first time it asked. | |
| std::optional< account_t > | platf::session_broker::lookup (const std::string &client_uuid) |
| The client's account if it already has one, without creating it. | |
| std::optional< std::string > | platf::session_broker::start (const std::string &client_uuid, const std::vector< std::string > &arguments, const std::vector< std::string > &environment, const std::string &scope={}) |
| Start arguments as the client's account, and return the unit name. | |
| std::optional< std::string > | platf::session_broker::wayland_socket (const std::string &client_uuid) |
| The name of the Wayland socket the session's compositor created. | |
| bool | platf::session_broker::active (const std::string &client_uuid) |
| Whether the client's session is running right now. | |
| std::optional< bool > | platf::session_broker::query_active (const std::string &client_uuid) |
| Query liveness without treating communication failure as session exit. | |
| bool | platf::session_broker::stop (const std::string &client_uuid) |
| Stop the client's session unit. Stopping one that is already gone succeeds, so this is safe to call on a teardown path that may run twice. | |
Ask the privileged broker for a client's own Unix account, and for a session running under it.
Definition in file session_broker.h.
| bool platf::session_broker::active | ( | const std::string & | client_uuid | ) |
Whether the client's session is running right now.
A session started this way is a systemd unit, not a child of Hermes, so there is no process handle on this side to ask. systemd is the only thing that knows, and the broker is how this side reaches it.
Definition at line 245 of file session_broker.cpp.
| bool platf::session_broker::available | ( | ) |
Whether a broker socket is there to talk to.
False on every host that has not installed and enabled the broker, which is the normal case. A caller that finds none runs the session as the Hermes user, the way it did before accounts existed - less isolated, but working.
Definition at line 124 of file session_broker.cpp.
| std::optional< account_t > platf::session_broker::ensure | ( | const std::string & | client_uuid | ) |
The client's account, created if this is the first time it asked.
Idempotent: a client that comes back gets the account it had, which is what makes its files still be there. Fails when the Hermes user is not in the broker's allow file, or when every configured slot is in use. Account and lifetime mutations have a bounded three-minute budget, including queues; read-only queries retain their short deadline.
Definition at line 130 of file session_broker.cpp.
| std::optional< account_t > platf::session_broker::lookup | ( | const std::string & | client_uuid | ) |
The client's account if it already has one, without creating it.
Definition at line 142 of file session_broker.cpp.
| std::optional< bool > platf::session_broker::query_active | ( | const std::string & | client_uuid | ) |
Query liveness without treating communication failure as session exit.
Lifecycle monitoring should use this query and preserve a live session on nullopt. The bool active() wrapper retains its older false-on-error contract.
Definition at line 215 of file session_broker.cpp.
| std::optional< std::string > platf::session_broker::start | ( | const std::string & | client_uuid, |
| const std::vector< std::string > & | arguments, | ||
| const std::vector< std::string > & | environment, | ||
| const std::string & | scope = {} ) |
Start arguments as the client's account, and return the unit name.
The session becomes a transient systemd unit rather than a child of Hermes: it needs a uid Hermes cannot assume, and a unit is also what gives it a cgroup, a lifetime and a sandbox of its own. arguments[0] must be an absolute path - the broker resolves nothing and no shell is involved on either side, so nothing here needs quoting. environment is a list of NAME=VALUE assignments; XDG_RUNTIME_DIR is set by the broker to match the account and cannot be overridden from here.
scope names a second unit beside the session's own, for what runs inside the session once it is up; an empty scope is the session itself. A scoped unit is bound to the session's, so stopping the session stops it too - the way terminating the process group did when all of this was a child of Hermes.
Definition at line 149 of file session_broker.cpp.
| bool platf::session_broker::stop | ( | const std::string & | client_uuid | ) |
Stop the client's session unit. Stopping one that is already gone succeeds, so this is safe to call on a teardown path that may run twice.
Definition at line 249 of file session_broker.cpp.
| std::optional< std::string > platf::session_broker::wayland_socket | ( | const std::string & | client_uuid | ) |
The name of the Wayland socket the session's compositor created.
Hermes cannot list the session's runtime directory once it belongs to another user, so the broker lists it and returns only the name. A name is all that is needed: whatever connects to the socket is launched into the session rather than run by Hermes. Nothing yet is not an error - a compositor that has not finished starting has not made one - so this is meant to be polled.
Definition at line 198 of file session_broker.cpp.