chiark / gitweb /
core: Refuse to run a user instance when the system hasn't been booted with systemd.
[elogind.git] / src / journal / journald.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6   This file is part of systemd.
7
8   Copyright 2011 Lennart Poettering
9
10   systemd is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   systemd is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 ***/
23
24 #include <inttypes.h>
25 #include <stdbool.h>
26 #include <sys/types.h>
27 #include <sys/socket.h>
28
29 #include "journal-file.h"
30 #include "hashmap.h"
31 #include "util.h"
32 #include "audit.h"
33 #include "journald-rate-limit.h"
34 #include "list.h"
35
36 typedef enum Storage {
37         STORAGE_AUTO,
38         STORAGE_VOLATILE,
39         STORAGE_PERSISTENT,
40         STORAGE_NONE,
41         _STORAGE_MAX,
42         _STORAGE_INVALID = -1
43 } Storage;
44
45 typedef enum SplitMode {
46         SPLIT_LOGIN,
47         SPLIT_UID,
48         SPLIT_NONE,
49         _SPLIT_MAX,
50         _SPLIT_INVALID = -1
51 } SplitMode;
52
53 typedef struct StdoutStream StdoutStream;
54
55 typedef struct Server {
56         int epoll_fd;
57         int signal_fd;
58         int syslog_fd;
59         int native_fd;
60         int stdout_fd;
61         int dev_kmsg_fd;
62
63         JournalFile *runtime_journal;
64         JournalFile *system_journal;
65         Hashmap *user_journals;
66
67         uint64_t seqnum;
68
69         char *buffer;
70         size_t buffer_size;
71
72         JournalRateLimit *rate_limit;
73         usec_t rate_limit_interval;
74         unsigned rate_limit_burst;
75
76         JournalMetrics runtime_metrics;
77         JournalMetrics system_metrics;
78
79         bool compress;
80         bool seal;
81
82         bool forward_to_kmsg;
83         bool forward_to_syslog;
84         bool forward_to_console;
85
86         unsigned n_forward_syslog_missed;
87         usec_t last_warn_forward_syslog_missed;
88
89         uint64_t cached_available_space;
90         usec_t cached_available_space_timestamp;
91
92         uint64_t var_available_timestamp;
93
94         gid_t file_gid;
95         bool file_gid_valid;
96
97         LIST_HEAD(StdoutStream, stdout_streams);
98         unsigned n_stdout_streams;
99
100         char *tty_path;
101
102         int max_level_store;
103         int max_level_syslog;
104         int max_level_kmsg;
105         int max_level_console;
106
107         Storage storage;
108         SplitMode split_mode;
109
110         MMapCache *mmap;
111
112         bool dev_kmsg_readable;
113
114         uint64_t *kernel_seqnum;
115
116         struct udev *udev;
117 } Server;
118
119 #define N_IOVEC_META_FIELDS 17
120 #define N_IOVEC_KERNEL_FIELDS 64
121 #define N_IOVEC_UDEV_FIELDS 32
122
123 void server_dispatch_message(Server *s, struct iovec *iovec, unsigned n, unsigned m, struct ucred *ucred, struct timeval *tv, const char *label, size_t label_len, const char *unit_id, int priority);
124 void server_driver_message(Server *s, sd_id128_t message_id, const char *format, ...);
125
126 /* gperf lookup function */
127 const struct ConfigPerfItem* journald_gperf_lookup(const char *key, unsigned length);
128
129 int config_parse_storage(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
130
131 const char *storage_to_string(Storage s);
132 Storage storage_from_string(const char *s);
133
134 int config_parse_split_mode(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
135
136 const char *split_mode_to_string(SplitMode s);
137 SplitMode split_mode_from_string(const char *s);