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