]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal/journald-context.h
Merge pull request #28697 from 1awesomeJ/new_bsod
[thirdparty/systemd.git] / src / journal / journald-context.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <inttypes.h>
5 #include <sys/socket.h>
6 #include <sys/types.h>
7
8 #include "sd-id128.h"
9
10 #include "set.h"
11 #include "time-util.h"
12
13 typedef struct ClientContext ClientContext;
14
15 #include "journald-server.h"
16
17 struct ClientContext {
18 unsigned n_ref;
19 unsigned lru_index;
20 usec_t timestamp;
21 bool in_lru;
22
23 pid_t pid;
24 uid_t uid;
25 gid_t gid;
26
27 char *comm;
28 char *exe;
29 char *cmdline;
30 char *capeff;
31
32 uint32_t auditid;
33 uid_t loginuid;
34
35 char *cgroup;
36 char *session;
37 uid_t owner_uid;
38
39 char *unit;
40 char *user_unit;
41
42 char *slice;
43 char *user_slice;
44
45 sd_id128_t invocation_id;
46
47 char *label;
48 size_t label_size;
49
50 int log_level_max;
51
52 struct iovec *extra_fields_iovec;
53 size_t extra_fields_n_iovec;
54 void *extra_fields_data;
55 nsec_t extra_fields_mtime;
56
57 usec_t log_ratelimit_interval;
58 unsigned log_ratelimit_burst;
59
60 Set *log_filter_allowed_patterns;
61 Set *log_filter_denied_patterns;
62 };
63
64 int client_context_get(
65 Server *s,
66 pid_t pid,
67 const struct ucred *ucred,
68 const char *label, size_t label_len,
69 const char *unit_id,
70 ClientContext **ret);
71
72 int client_context_acquire(
73 Server *s,
74 pid_t pid,
75 const struct ucred *ucred,
76 const char *label, size_t label_len,
77 const char *unit_id,
78 ClientContext **ret);
79
80 ClientContext* client_context_release(Server *s, ClientContext *c);
81
82 void client_context_maybe_refresh(
83 Server *s,
84 ClientContext *c,
85 const struct ucred *ucred,
86 const char *label, size_t label_size,
87 const char *unit_id,
88 usec_t tstamp);
89
90 void client_context_acquire_default(Server *s);
91 void client_context_flush_all(Server *s);
92 void client_context_flush_regular(Server *s);
93
94 static inline size_t client_context_extra_fields_n_iovec(const ClientContext *c) {
95 return c ? c->extra_fields_n_iovec : 0;
96 }
97
98 static inline bool client_context_test_priority(const ClientContext *c, int priority) {
99 if (!c)
100 return true;
101
102 if (c->log_level_max < 0)
103 return true;
104
105 return LOG_PRI(priority) <= c->log_level_max;
106 }