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