#include "missing_ioprio.h"
#include "mountpoint-util.h"
#include "nulstr-util.h"
+#include "open-file.h"
#include "parse-helpers.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pcre2-util.h"
#include "percent-util.h"
#include "process-util.h"
#if HAVE_SECCOMP
DEFINE_CONFIG_PARSE_PTR(config_parse_cg_weight, cg_weight_parse, uint64_t, "Invalid weight");
DEFINE_CONFIG_PARSE_PTR(config_parse_cg_cpu_weight, cg_cpu_weight_parse, uint64_t, "Invalid CPU weight");
static DEFINE_CONFIG_PARSE_PTR(config_parse_cpu_shares_internal, cg_cpu_shares_parse, uint64_t, "Invalid CPU shares");
-DEFINE_CONFIG_PARSE_PTR(config_parse_exec_mount_flags, mount_propagation_flags_from_string, unsigned long, "Failed to parse mount flag");
+DEFINE_CONFIG_PARSE_PTR(config_parse_exec_mount_flags, mount_propagation_flag_from_string, unsigned long, "Failed to parse mount flag");
DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_numa_policy, mpol, int, -1, "Invalid NUMA policy type");
DEFINE_CONFIG_PARSE_ENUM(config_parse_status_unit_format, status_unit_format, StatusUnitFormat, "Failed to parse status unit format");
DEFINE_CONFIG_PARSE_ENUM_FULL(config_parse_socket_timestamping, socket_timestamping_from_string_harder, SocketTimestamping, "Failed to parse timestamping precision");
void *userdata) {
_cleanup_free_ char *k = NULL;
- const Unit *u = userdata;
+ const Unit *u = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
r = unit_full_printf(u, rvalue, &k);
if (r < 0) {
void *data,
void *userdata) {
- const Unit *u = userdata;
+ const Unit *u = ASSERT_PTR(userdata);
_cleanup_free_ char *k = NULL;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
r = unit_full_printf(u, rvalue, &k);
if (r < 0) {
void *userdata) {
_cleanup_free_ char *k = NULL;
- const Unit *u = userdata;
+ const Unit *u = ASSERT_PTR(userdata);
int r;
bool fatal = ltype;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
r = unit_path_printf(u, rvalue, &k);
if (r < 0) {
const char *rvalue,
void *data,
void *userdata) {
- char ***sv = data;
+ char ***sv = ASSERT_PTR(data);
const Unit *u = userdata;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
void *userdata) {
char ***x = data;
- const Unit *u = userdata;
+ const Unit *u = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
if (isempty(rvalue)) {
*x = strv_free(*x);
p->type = SOCKET_SOCKET;
}
- p->fd = -1;
+ p->fd = -EBADF;
p->auxiliary_fds = NULL;
p->n_auxiliary_fds = 0;
p->socket = s;
- LIST_FIND_TAIL(port, s->ports, tail);
+ tail = LIST_FIND_TAIL(port, s->ports);
LIST_INSERT_AFTER(port, s->ports, tail, p);
p = NULL;
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
int priority, r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->nice_set = false;
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
int oa, r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->oom_score_adjust_set = false;
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->coredump_filter = 0;
void *data,
void *userdata) {
- ExecCommand **e = data;
+ ExecCommand **e = ASSERT_PTR(data);
const Unit *u = userdata;
const char *p;
bool semicolon;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(e);
e += ltype;
void *data,
void *userdata) {
- Socket *s = data;
+ Socket *s = ASSERT_PTR(data);
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue) || streq(rvalue, "*")) {
s->bind_to_device = mfree(s->bind_to_device);
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
const char *n;
ExecInput ei;
int r;
- assert(data);
assert(filename);
assert(line);
assert(rvalue);
void *userdata) {
_cleanup_free_ char *unescaped = NULL, *resolved = NULL;
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
int r;
- assert(data);
assert(filename);
assert(line);
assert(rvalue);
void *userdata) {
_cleanup_free_ void *p = NULL;
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
size_t sz;
void *q;
int r;
- assert(data);
assert(filename);
assert(line);
assert(rvalue);
_cleanup_free_ char *resolved = NULL;
const char *n;
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
bool obsolete = false;
ExecOutput eo;
int r;
- assert(data);
assert(filename);
assert(line);
assert(lvalue);
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
int x;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->ioprio_set = false;
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
int i, r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->ioprio_set = false;
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
int x;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->cpu_sched_set = false;
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
int k;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->mount_apivfs_set = false;
void *data,
void *userdata) {
int r;
- NUMAPolicy *p = data;
+ NUMAPolicy *p = ASSERT_PTR(data);
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (streq(rvalue, "all")) {
r = numa_mask_add_all(&p->nodes);
void *data,
void *userdata) {
- ExecContext *c = data;
- int i, min, max, r;
+ ExecContext *c = ASSERT_PTR(data);
+ int i, r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = safe_atoi(rvalue, &i);
if (r < 0) {
return 0;
}
- /* On Linux RR/FIFO range from 1 to 99 and OTHER/BATCH may only be 0 */
- min = sched_get_priority_min(c->cpu_sched_policy);
- max = sched_get_priority_max(c->cpu_sched_policy);
-
- if (i < min || i > max) {
+ /* On Linux RR/FIFO range from 1 to 99 and OTHER/BATCH may only be 0. Policy might be set later so
+ * we do not check the precise range, but only the generic outer bounds. */
+ if (i < 0 || i > 99) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "CPU scheduling priority is out of range, ignoring: %s", rvalue);
return 0;
}
_cleanup_(mount_options_free_allp) MountOptions *options = NULL;
_cleanup_strv_free_ char **l = NULL;
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->root_image_options = mount_options_free_all(c->root_image_options);
void *userdata) {
_cleanup_free_ void *roothash_decoded = NULL;
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
size_t roothash_decoded_size = 0;
int r;
- assert(data);
assert(filename);
assert(line);
assert(rvalue);
_cleanup_free_ void *roothash_sig_decoded = NULL;
char *value;
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
size_t roothash_sig_decoded_size = 0;
int r;
- assert(data);
assert(filename);
assert(line);
assert(rvalue);
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
_cleanup_free_ char *k = NULL;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (streq(rvalue, "numa")) {
c->cpu_affinity_from_numa = true;
void *data,
void *userdata) {
- uint64_t *capability_set = data;
+ uint64_t *capability_set = ASSERT_PTR(data);
uint64_t sum = 0, initial = 0;
bool invert = false;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (rvalue[0] == '~') {
invert = true;
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
bool ignore;
char *k;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->selinux_context = mfree(c->selinux_context);
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
bool ignore;
char *k;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->apparmor_profile = mfree(c->apparmor_profile);
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
bool ignore;
char *k;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->smack_process_label = mfree(c->smack_process_label);
_cleanup_(calendar_spec_freep) CalendarSpec *c = NULL;
_cleanup_free_ char *k = NULL;
const Unit *u = userdata;
- Timer *t = data;
+ Timer *t = ASSERT_PTR(data);
usec_t usec = 0;
TimerValue *v;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets list */
void *userdata) {
_cleanup_free_ char *p = NULL;
- Unit *u = data;
+ Unit *u = ASSERT_PTR(data);
UnitType type;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (UNIT_TRIGGER(u)) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Multiple units to trigger specified, ignoring: %s", rvalue);
void *data,
void *userdata) {
- Path *p = data;
+ Path *p = ASSERT_PTR(data);
PathSpec *s;
PathType b;
_cleanup_free_ char *k = NULL;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment clears list */
s->unit = UNIT(p);
s->path = TAKE_PTR(k);
s->type = b;
- s->inotify_fd = -1;
+ s->inotify_fd = -EBADF;
LIST_PREPEND(spec, p->specs, s);
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_free_ char *p = NULL;
- Socket *s = data;
+ Socket *s = ASSERT_PTR(data);
Unit *x;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = unit_name_printf(UNIT(s), rvalue, &p);
if (r < 0) {
void *userdata) {
_cleanup_free_ char *p = NULL;
- Socket *s = data;
+ Socket *s = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
s->fdname = mfree(s->fdname);
void *data,
void *userdata) {
- Service *s = data;
+ Service *s = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
for (const char *p = rvalue;;) {
_cleanup_free_ char *word = NULL, *k = NULL;
void *userdata) {
_cleanup_free_ char *k = NULL;
- const Unit *u = userdata;
+ const Unit *u = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
r = unit_full_printf_full(u, rvalue, SD_BUS_MAXIMUM_NAME_LENGTH, &k);
if (r < 0) {
void *data,
void *userdata) {
- Service *s = userdata;
+ Service *s = ASSERT_PTR(userdata);
usec_t usec;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(s);
/* This is called for two cases: TimeoutSec= and TimeoutStartSec=. */
void *data,
void *userdata) {
- usec_t *ret = data;
+ usec_t *ret = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(ret);
/* Note: apart from setting the arg, this returns an extra bit of information in the return value. */
void *data,
void *userdata) {
- Service *s = userdata;
+ Service *s = ASSERT_PTR(userdata);
int r;
- assert(s);
-
r = config_parse_timeout_abort(unit, filename, line, section, section_line, lvalue, ltype, rvalue,
&s->timeout_abort_usec, s);
if (r >= 0)
_cleanup_free_ char *k = NULL;
char **user = data;
- const Unit *u = userdata;
+ const Unit *u = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
if (isempty(rvalue)) {
*user = mfree(*user);
void *userdata) {
char ***users = data;
- const Unit *u = userdata;
+ const Unit *u = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
if (isempty(rvalue)) {
*users = strv_free(*users);
void *data,
void *userdata) {
- ExecContext *c = data;
- const Unit *u = userdata;
+ ExecContext *c = ASSERT_PTR(data);
+ const Unit *u = ASSERT_PTR(userdata);
bool missing_ok;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(c);
- assert(u);
if (isempty(rvalue)) {
c->working_directory_home = false;
void *data,
void *userdata) {
- char ***env = data;
+ char ***env = ASSERT_PTR(data);
const Unit *u = userdata;
_cleanup_free_ char *n = NULL;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment frees the list */
void *userdata) {
const Unit *u = userdata;
- char ***env = data;
+ char ***env = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
_cleanup_strv_free_ char **n = NULL;
const Unit *u = userdata;
- char*** passenv = data;
+ char*** passenv = ASSERT_PTR(data);
size_t nlen = 0;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
void *userdata) {
_cleanup_strv_free_ char **n = NULL;
- char*** unsetenv = data;
+ char*** unsetenv = ASSERT_PTR(data);
const Unit *u = userdata;
size_t nlen = 0;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(c);
if (isempty(rvalue)) {
exec_context_free_log_extra_fields(c);
void *userdata) {
_cleanup_free_ char *k = NULL;
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(c);
if (isempty(rvalue)) {
c->log_namespace = mfree(c->log_namespace);
void *userdata) {
_cleanup_free_ char *p = NULL;
- Condition **list = data, *c;
+ Condition **list = ASSERT_PTR(data), *c;
ConditionType t = ltype;
bool trigger, negate;
const Unit *u = userdata;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
void *userdata) {
_cleanup_free_ char *s = NULL;
- Condition **list = data, *c;
+ Condition **list = ASSERT_PTR(data), *c;
ConditionType t = ltype;
bool trigger, negate;
const Unit *u = userdata;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
void *data,
void *userdata) {
- Unit *u = userdata;
+ Unit *u = ASSERT_PTR(userdata);
int r;
char **a, **b;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
void *userdata) {
ExecContext *c = data;
- _unused_ const Unit *u = userdata;
+ _unused_ const Unit *u = ASSERT_PTR(userdata);
bool invert = false;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
void *userdata) {
ExecContext *c = data;
- _unused_ const Unit *u = userdata;
+ _unused_ const Unit *u = ASSERT_PTR(userdata);
bool invert = false;
const char *p;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
const char *rvalue,
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
bool invert = false;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
bytes = physical_memory_scale(r, 10000U);
if (bytes >= UINT64_MAX ||
- (bytes <= 0 && !STR_IN_SET(lvalue, "MemorySwapMax", "MemoryLow", "MemoryMin", "DefaultMemoryLow", "DefaultMemoryMin"))) {
+ (bytes <= 0 && !STR_IN_SET(lvalue, "MemorySwapMax", "MemoryZSwapMax", "MemoryLow", "MemoryMin", "DefaultMemoryLow", "DefaultMemoryMin"))) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Memory limit '%s' out of range, ignoring.", rvalue);
return 0;
}
c->memory_max = bytes;
else if (streq(lvalue, "MemorySwapMax"))
c->memory_swap_max = bytes;
+ else if (streq(lvalue, "MemoryZSwapMax"))
+ c->memory_zswap_max = bytes;
else if (streq(lvalue, "MemoryLimit")) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Unit uses MemoryLimit=; please use MemoryMax= instead. Support for MemoryLimit= will be removed soon.");
_cleanup_free_ char *path = NULL, *resolved = NULL;
CGroupIODeviceWeight *w;
CGroupContext *c = data;
- const char *p = rvalue;
+ const char *p = ASSERT_PTR(rvalue);
uint64_t u;
int r;
assert(filename);
assert(lvalue);
- assert(rvalue);
if (isempty(rvalue)) {
while (c->io_device_weights)
_cleanup_free_ char *path = NULL, *resolved = NULL;
CGroupIODeviceLatency *l;
CGroupContext *c = data;
- const char *p = rvalue;
+ const char *p = ASSERT_PTR(rvalue);
usec_t usec;
int r;
assert(filename);
assert(lvalue);
- assert(rvalue);
if (isempty(rvalue)) {
while (c->io_device_latencies)
CGroupIODeviceLimit *l = NULL;
CGroupContext *c = data;
CGroupIOLimitType type;
- const char *p = rvalue;
+ const char *p = ASSERT_PTR(rvalue);
uint64_t num;
int r;
assert(filename);
assert(lvalue);
- assert(rvalue);
type = cgroup_io_limit_type_from_string(lvalue);
assert(type >= 0);
_cleanup_free_ char *path = NULL, *resolved = NULL;
CGroupBlockIODeviceWeight *w;
CGroupContext *c = data;
- const char *p = rvalue;
+ const char *p = ASSERT_PTR(rvalue);
uint64_t u;
int r;
assert(filename);
assert(lvalue);
- assert(rvalue);
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Unit uses %s=; please use IO*= settings instead. Support for %s= will be removed soon.",
_cleanup_free_ char *path = NULL, *resolved = NULL;
CGroupBlockIODeviceBandwidth *b = NULL;
CGroupContext *c = data;
- const char *p = rvalue;
+ const char *p = ASSERT_PTR(rvalue);
uint64_t bytes;
bool read;
int r;
assert(filename);
assert(lvalue);
- assert(rvalue);
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Unit uses %s=; please use IO*= settings instead. Support for %s= will be removed soon.",
void *data,
void *userdata) {
- ExecDirectory *ed = data;
+ ExecDirectory *ed = ASSERT_PTR(data);
const Unit *u = userdata;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
/* For State and Runtime directories we support an optional destination parameter, which
* will be used to create a symlink to the source. */
- _cleanup_strv_free_ char **symlinks = NULL;
+ _cleanup_free_ char *dresolved = NULL;
if (!isempty(dest)) {
- _cleanup_free_ char *dresolved = NULL;
-
if (streq(lvalue, "ConfigurationDirectory")) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Destination parameter is not supported for ConfigurationDirectory, ignoring: %s", tuple);
r = path_simplify_and_warn(dresolved, PATH_CHECK_RELATIVE, unit, filename, line, lvalue);
if (r < 0)
continue;
-
- r = strv_consume(&symlinks, TAKE_PTR(dresolved));
- if (r < 0)
- return log_oom();
}
- r = exec_directory_add(&ed->items, &ed->n_items, sresolved, symlinks);
+ r = exec_directory_add(ed, sresolved, dresolved);
if (r < 0)
return log_oom();
}
_cleanup_free_ char *word = NULL, *k = NULL;
_cleanup_free_ void *d = NULL;
- ExecContext *context = data;
+ ExecContext *context = ASSERT_PTR(data);
ExecSetCredential *old;
Unit *u = userdata;
bool encrypted = ltype;
- const char *p = rvalue;
+ const char *p = ASSERT_PTR(rvalue);
size_t size;
int r;
assert(filename);
assert(lvalue);
- assert(rvalue);
- assert(context);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
void *userdata) {
_cleanup_free_ char *word = NULL, *k = NULL, *q = NULL;
- ExecContext *context = data;
+ ExecContext *context = ASSERT_PTR(data);
ExecLoadCredential *old;
bool encrypted = ltype;
Unit *u = userdata;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(context);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
void *data,
void *userdata) {
- ExitStatusSet *status_set = data;
+ ExitStatusSet *status_set = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(status_set);
/* Empty assignment resets the list */
if (isempty(rvalue)) {
void *userdata) {
const Unit *u = userdata;
- char*** sv = data;
+ char*** sv = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
void *userdata) {
const Unit *u = userdata;
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
void *data,
void *userdata) {
- Unit *u = data;
+ Unit *u = ASSERT_PTR(data);
usec_t usec;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
r = parse_sec_fix_0(rvalue, &usec);
if (r < 0) {
void *data,
void *userdata) {
- Unit *u = data;
+ Unit *u = ASSERT_PTR(data);
usec_t usec;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
r = parse_sec_fix_0(rvalue, &usec);
if (r < 0) {
void *data,
void *userdata) {
- Manager *m = NULL;
- EmergencyAction *x = data;
+ EmergencyAction *x = ASSERT_PTR(data);
+ bool is_system;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
+ /* If we have a unit determine the scope based on it */
if (unit)
- m = ((Unit*) userdata)->manager;
+ is_system = MANAGER_IS_SYSTEM(((Unit*) ASSERT_PTR(userdata))->manager);
else
- m = data;
+ is_system = ltype; /* otherwise, assume the scope is passed in via ltype */
- r = parse_emergency_action(rvalue, MANAGER_IS_SYSTEM(m), x);
+ r = parse_emergency_action(rvalue, is_system, x);
if (r < 0) {
- if (r == -EOPNOTSUPP && MANAGER_IS_USER(m)) {
- /* Compat mode: remove for systemd 241. */
-
- log_syntax(unit, LOG_INFO, filename, line, r,
- "%s= in user mode specified as \"%s\", using \"exit-force\" instead.",
- lvalue, rvalue);
- *x = EMERGENCY_ACTION_EXIT_FORCE;
- return 0;
- }
-
if (r == -EOPNOTSUPP)
log_syntax(unit, LOG_WARNING, filename, line, r,
"%s= specified as %s mode action, ignoring: %s",
- lvalue, MANAGER_IS_SYSTEM(m) ? "user" : "system", rvalue);
+ lvalue, is_system ? "user" : "system", rvalue);
else
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse %s=, ignoring: %s", lvalue, rvalue);
void *userdata) {
_cleanup_free_ char *k = NULL, *n = NULL;
- const Unit *u = userdata;
+ const Unit *u = ASSERT_PTR(userdata);
char **s = data;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
if (isempty(rvalue)) {
/* An empty assignment removes already set value. */
_cleanup_free_ char *resolved = NULL;
const Unit *u = userdata;
- char ***paths = data;
+ char ***paths = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(paths);
if (isempty(rvalue)) {
*paths = strv_free(*paths);
void *userdata) {
_cleanup_free_ char *resolved = NULL, *word = NULL;
CGroupContext *c = data;
- const char *p = rvalue;
+ const char *p = ASSERT_PTR(rvalue);
Unit *u = userdata;
int attach_type, r;
assert(filename);
assert(lvalue);
- assert(rvalue);
if (isempty(rvalue)) {
while (c->bpf_foreign_programs)
const char *rvalue,
void *data,
void *userdata) {
- CGroupContext *c = data;
+ CGroupContext *c = ASSERT_PTR(data);
bool is_allow_rule = true;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
{ config_parse_job_mode, "MODE" },
{ config_parse_job_mode_isolate, "BOOLEAN" },
{ config_parse_personality, "PERSONALITY" },
+ { config_parse_log_filter_patterns, "REGEX" },
};
const char *prev = NULL;
- const char *i;
assert(f);
void *data,
void *userdata) {
- CPUSet *affinity = data;
-
- assert(affinity);
+ CPUSet *affinity = ASSERT_PTR(data);
(void) parse_cpu_set_extend(rvalue, affinity, true, unit, filename, line, lvalue);
void *userdata) {
int k;
- ShowStatus *b = data;
+ ShowStatus *b = ASSERT_PTR(data);
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
k = parse_show_status(rvalue, b);
if (k < 0)
void *data,
void *userdata) {
- ExecOutput t, *eo = data;
+ ExecOutput t, *eo = ASSERT_PTR(data);
bool obsolete = false;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (streq(rvalue, "syslog")) {
t = EXEC_OUTPUT_JOURNAL;
void *data,
void *userdata) {
- Swap *s = userdata;
+ Swap *s = ASSERT_PTR(userdata);
int r, priority;
- assert(s);
assert(filename);
assert(lvalue);
assert(rvalue);
return config_parse_unsigned(unit, filename, line, section, section_line, lvalue, ltype, rvalue, data, userdata);
}
+
+int config_parse_log_filter_patterns(
+ const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ ExecContext *c = ASSERT_PTR(data);
+ const char *pattern = ASSERT_PTR(rvalue);
+ bool is_allowlist = true;
+ int r;
+
+ assert(filename);
+ assert(lvalue);
+
+ if (isempty(pattern)) {
+ /* Empty assignment resets the lists. */
+ c->log_filter_allowed_patterns = set_free(c->log_filter_allowed_patterns);
+ c->log_filter_denied_patterns = set_free(c->log_filter_denied_patterns);
+ return 0;
+ }
+
+ if (pattern[0] == '~') {
+ is_allowlist = false;
+ pattern++;
+ if (isempty(pattern))
+ /* LogFilterPatterns=~ is not considered a valid pattern. */
+ return log_syntax(unit, LOG_WARNING, filename, line, 0,
+ "Regex pattern invalid, ignoring: %s=%s", lvalue, rvalue);
+ }
+
+ if (pattern_compile_and_log(pattern, 0, NULL) < 0)
+ return 0;
+
+ r = set_put_strdup(is_allowlist ? &c->log_filter_allowed_patterns : &c->log_filter_denied_patterns,
+ pattern);
+ if (r < 0) {
+ log_syntax(unit, LOG_WARNING, filename, line, r,
+ "Failed to store log filtering pattern, ignoring: %s=%s", lvalue, rvalue);
+ return 0;
+ }
+
+ return 0;
+}
+
+int config_parse_open_file(
+ const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ _cleanup_(open_file_freep) OpenFile *of = NULL;
+ OpenFile **head = ASSERT_PTR(data);
+ int r;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+
+ if (isempty(rvalue)) {
+ open_file_free_many(head);
+ return 0;
+ }
+
+ r = open_file_parse(rvalue, &of);
+ if (r < 0) {
+ log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse OpenFile= setting, ignoring: %s", rvalue);
+ return 0;
+ }
+
+ LIST_APPEND(open_files, *head, TAKE_PTR(of));
+
+ return 0;
+}