3
* Copyright © 2010,2011 Canonical Ltd.
4
* Author: Scott James Remnant <scott@netsplit.com>.
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 2, as
8
* published by the Free Software Foundation.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License along
16
* with this program; if not, write to the Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
#ifndef INIT_SESSION_H
21
#define INIT_SESSION_H
23
#include <sys/types.h>
25
#include <nih/macros.h>
28
#include <nih-dbus/dbus_message.h>
33
* @entry: list header,
34
* @chroot: path all jobs are chrooted to,
35
* @user: uid all jobs are switched to,
36
* @conf_path: configuration path (either full path to chroot root, or
37
* full path to users job directory (which may itself be prepended
38
* with a chroot path)).
40
* This structure is used to identify collections of jobs
41
* that share either a common @chroot and/or common @user.
43
* Summary of Session values for different environments:
45
* +-------------+--------------------------------------------------+
47
* +------+------+--------+-----+-----------------------------------+
48
* | user | PID | chroot | uid | Object contents |
49
* +------+------+--------+-----+-----------------------------------+
50
* | 0 | >0 | no | 0 | NULL (*1) |
51
* | >0 | "0" | no | >0 | uid + conf_path set to "~/.init". |
52
* | 0 | >0 | yes | 0 | chroot + conf_path set |
53
* | >0 | ?? | yes | >0 | XXX: fails (*2) |
54
* +------+------+--------+-----+-----------------------------------+
58
* (*1) - The "NULL session" represents the "traditional" environment
59
* before sessions were introduced (namely a non-chroot environment
60
* where all job and event operations were handled by uid 0 (root)).
64
* initctl: Unable to connect to system bus: Failed to connect to socket
65
* /var/run/dbus/system_bus_socket: No such file or directory
68
typedef struct session {
78
extern NihList *sessions;
80
void session_init (void);
82
Session *session_new (const void *parent, const char *chroot, uid_t user)
83
__attribute__ ((malloc, warn_unused_result));
85
Session *session_from_dbus (const void *parent, NihDBusMessage *message);
89
#endif /* INIT_SESSION_H */