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