~daniel-sonck/upstart/cron-replacement

« back to all changes in this revision

Viewing changes to init/session.h

  • Committer: dsonck
  • Date: 2011-10-14 14:32:00 UTC
  • mfrom: (1282.1.47 upstart)
  • Revision ID: dsonck@daniel-desktop-20111014143200-ezekcd0k43ykog2l
Merged with the latest startup branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* upstart
 
2
 *
 
3
 * Copyright © 2010,2011 Canonical Ltd.
 
4
 * Author: Scott James Remnant <scott@netsplit.com>.
 
5
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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.
 
18
 */
 
19
 
 
20
#ifndef INIT_SESSION_H
 
21
#define INIT_SESSION_H
 
22
 
 
23
#include <sys/types.h>
 
24
 
 
25
#include <nih/macros.h>
 
26
#include <nih/list.h>
 
27
 
 
28
#include <nih-dbus/dbus_message.h>
 
29
 
 
30
 
 
31
/**
 
32
 * Session:
 
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)).
 
39
 *
 
40
 * This structure is used to identify collections of jobs
 
41
 * that share either a common @chroot and/or common @user.
 
42
 *
 
43
 * Summary of Session values for different environments:
 
44
 *
 
45
 * +-------------+--------------------------------------------------+
 
46
 * |    D-Bus    |             Session                              |
 
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
 * +------+------+--------+-----+-----------------------------------+
 
55
 *
 
56
 * Notes:
 
57
 *
 
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)).
 
61
 *
 
62
 * (*2) - error is:
 
63
 *
 
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
 
66
 * 
 
67
 **/
 
68
typedef struct session {
 
69
        NihList entry;
 
70
        char *  chroot;
 
71
        uid_t   user;
 
72
        char *  conf_path;
 
73
} Session;
 
74
 
 
75
 
 
76
NIH_BEGIN_EXTERN
 
77
 
 
78
extern NihList *sessions;
 
79
 
 
80
void     session_init      (void);
 
81
 
 
82
Session *session_new       (const void *parent, const char *chroot, uid_t user)
 
83
        __attribute__ ((malloc, warn_unused_result));
 
84
 
 
85
Session *session_from_dbus (const void *parent, NihDBusMessage *message);
 
86
 
 
87
NIH_END_EXTERN
 
88
 
 
89
#endif /* INIT_SESSION_H */