]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
22e3a02b LP |
2 | #pragma once |
3 | ||
22e3a02b LP |
4 | #include <inttypes.h> |
5 | #include <sys/types.h> | |
6 | ||
7 | #include "sd-id128.h" | |
8 | ||
9 | typedef struct ClientContext ClientContext; | |
10 | ||
11 | #include "journald-server.h" | |
12 | ||
13 | struct 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; | |
d3070fbd LP |
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; | |
22e3a02b LP |
52 | }; |
53 | ||
54 | int client_context_get( | |
55 | Server *s, | |
56 | pid_t pid, | |
57 | const struct ucred *ucred, | |
58 | const char *label, size_t label_len, | |
59 | const char *unit_id, | |
60 | ClientContext **ret); | |
61 | ||
62 | int client_context_acquire( | |
63 | Server *s, | |
64 | pid_t pid, | |
65 | const struct ucred *ucred, | |
66 | const char *label, size_t label_len, | |
67 | const char *unit_id, | |
68 | ClientContext **ret); | |
69 | ||
70 | ClientContext* client_context_release(Server *s, ClientContext *c); | |
71 | ||
72 | void client_context_maybe_refresh( | |
73 | Server *s, | |
74 | ClientContext *c, | |
75 | const struct ucred *ucred, | |
76 | const char *label, size_t label_size, | |
77 | const char *unit_id, | |
78 | usec_t tstamp); | |
79 | ||
80 | void client_context_acquire_default(Server *s); | |
81 | void client_context_flush_all(Server *s); | |
d3070fbd LP |
82 | |
83 | static inline size_t client_context_extra_fields_n_iovec(const ClientContext *c) { | |
84 | return c ? c->extra_fields_n_iovec : 0; | |
85 | } | |
86 | ||
87 | static inline bool client_context_test_priority(const ClientContext *c, int priority) { | |
88 | if (!c) | |
89 | return true; | |
90 | ||
91 | if (c->log_level_max < 0) | |
92 | return true; | |
93 | ||
94 | return LOG_PRI(priority) <= c->log_level_max; | |
95 | } |