]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal/journald-context.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / journal / journald-context.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 This file is part of systemd.
6
7 Copyright 2017 Lennart Poettering
8
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 ***/
22
23 #include <inttypes.h>
24 #include <sys/types.h>
25
26 #include "sd-id128.h"
27
28 typedef struct ClientContext ClientContext;
29
30 #include "journald-server.h"
31
32 struct ClientContext {
33 unsigned n_ref;
34 unsigned lru_index;
35 usec_t timestamp;
36 bool in_lru;
37
38 pid_t pid;
39 uid_t uid;
40 gid_t gid;
41
42 char *comm;
43 char *exe;
44 char *cmdline;
45 char *capeff;
46
47 uint32_t auditid;
48 uid_t loginuid;
49
50 char *cgroup;
51 char *session;
52 uid_t owner_uid;
53
54 char *unit;
55 char *user_unit;
56
57 char *slice;
58 char *user_slice;
59
60 sd_id128_t invocation_id;
61
62 char *label;
63 size_t label_size;
64
65 int log_level_max;
66
67 struct iovec *extra_fields_iovec;
68 size_t extra_fields_n_iovec;
69 void *extra_fields_data;
70 nsec_t extra_fields_mtime;
71 };
72
73 int client_context_get(
74 Server *s,
75 pid_t pid,
76 const struct ucred *ucred,
77 const char *label, size_t label_len,
78 const char *unit_id,
79 ClientContext **ret);
80
81 int client_context_acquire(
82 Server *s,
83 pid_t pid,
84 const struct ucred *ucred,
85 const char *label, size_t label_len,
86 const char *unit_id,
87 ClientContext **ret);
88
89 ClientContext* client_context_release(Server *s, ClientContext *c);
90
91 void client_context_maybe_refresh(
92 Server *s,
93 ClientContext *c,
94 const struct ucred *ucred,
95 const char *label, size_t label_size,
96 const char *unit_id,
97 usec_t tstamp);
98
99 void client_context_acquire_default(Server *s);
100 void client_context_flush_all(Server *s);
101
102 static inline size_t client_context_extra_fields_n_iovec(const ClientContext *c) {
103 return c ? c->extra_fields_n_iovec : 0;
104 }
105
106 static inline bool client_context_test_priority(const ClientContext *c, int priority) {
107 if (!c)
108 return true;
109
110 if (c->log_level_max < 0)
111 return true;
112
113 return LOG_PRI(priority) <= c->log_level_max;
114 }