mirror of
https://github.com/systemd/systemd
synced 2025-09-24 14:24:46 +02:00
Compare commits
No commits in common. "f00c36641a253f4ea659ec3def5d87ba1336eb3b" and "cb1277fa3b1d7a5b6e1b7cce31b91cd2efdad97a" have entirely different histories.
f00c36641a
...
cb1277fa3b
2
TODO
2
TODO
@ -68,6 +68,8 @@ Features:
|
||||
* homed: add a way to "adopt" a home directory, i.e. strip foreign signatures
|
||||
and insert a local signature instead.
|
||||
|
||||
* Maybe expose path_is_encrypted() as a new ConditionPathIsEncrypted=?
|
||||
|
||||
* homed: as an extension to the directory+subvolume backend: if located on
|
||||
especially marked fs, then sync down password into LUKS header of that fs,
|
||||
and always verify passwords against it too. Bootstrapping is a problem
|
||||
|
@ -9,5 +9,3 @@ layout: default
|
||||
If you discover a security vulnerability, we'd appreciate a non-public disclosure. systemd developers can be contacted privately on the **[systemd-security@redhat.com](mailto:systemd-security@redhat.com) mailing list**. The disclosure will be coordinated with distributions.
|
||||
|
||||
(The [issue tracker](https://github.com/systemd/systemd/issues) and [systemd-devel mailing list](https://lists.freedesktop.org/mailman/listinfo/systemd-devel) are fully public.)
|
||||
|
||||
Subscription to the systemd-security mailing list is open to **regular systemd contributors and people working in the security teams of various distributions**. Those conditions should be backed by publicly accessible information (ideally, a track of posts and commits from the mail address in question). If you fall into one of those categories and wish to be subscribed, submit a **[subscription request](https://www.redhat.com/mailman/listinfo/systemd-security)**.
|
||||
|
@ -81,24 +81,6 @@
|
||||
<citerefentry><refentrytitle>pstore.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
|
||||
</para>
|
||||
</refsect2>
|
||||
|
||||
<refsect2>
|
||||
<title>Controlling kernel parameters</title>
|
||||
|
||||
<para> The kernel has two parameters,
|
||||
<filename>/sys/module/kernel/parameters/crash_kexec_post_notifiers</filename> and
|
||||
<filename>/sys/module/printk/parameters/always_kmsg_dump</filename>,
|
||||
that control writes into pstore.
|
||||
The crash_kexec_post_notifiers parameter enables the kernel to write
|
||||
dmesg (including stack trace) into pstore upon a panic or crash, and
|
||||
printk.always_kmsg_dump parameter enables the kernel to write dmesg
|
||||
upon a normal shutdown (shutdown, reboot, halt). These kernel
|
||||
parameters are managed via the
|
||||
<citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
||||
mechanism, specifically the file <filename>/usr/lib/tmpfiles/systemd-pstore.conf</filename>.
|
||||
</para>
|
||||
</refsect2>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
|
@ -1226,24 +1226,6 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>ConditionEnvironment=</varname></term>
|
||||
|
||||
<listitem><para><varname>ConditionEnvironment=</varname> may be used to check whether a specific
|
||||
environment variable is set (or if prefixed with the exclamation mark — unset) in the service
|
||||
manager's environment block.
|
||||
|
||||
The argument may be a single word, to check if the variable with this name is defined in the
|
||||
environment block, or an assignment
|
||||
(<literal><replaceable>name</replaceable>=<replaceable>value</replaceable></literal>), to check if
|
||||
the variable with this exact value is defined. Note that the environment block of the service
|
||||
manager itself is checked, i.e. not any variables defined with <varname>Environment=</varname> or
|
||||
<varname>EnvironmentFile=</varname>, as described above. This is particularly useful when the
|
||||
service manager runs inside a containerized environment or as per-user service manager, in order to
|
||||
check for variables passed in by the enclosing container manager or PAM.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>ConditionSecurity=</varname></term>
|
||||
|
||||
@ -1364,18 +1346,6 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>ConditionPathIsEncrypted=</varname></term>
|
||||
|
||||
<listitem><para><varname>ConditionPathIsEncrypted=</varname> is similar to
|
||||
<varname>ConditionPathExists=</varname> but verifies that the underlying file system's backing
|
||||
block device is encrypted using dm-crypt/LUKS. Note that this check does not cover ext4
|
||||
per-directory encryption, and only detects block level encryption. Moreover, if the specified path
|
||||
resides on a file system on top of a loopback block device, only encryption above the loopback device is
|
||||
detected. It is not detected whether the file system backing the loopback block device is encrypted.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>ConditionDirectoryNotEmpty=</varname></term>
|
||||
|
||||
|
@ -21,7 +21,6 @@ static const condition_definition condition_definitions[] = {
|
||||
{ "ConditionPathIsSymbolicLink", config_parse_unit_condition_path, CONDITION_PATH_IS_SYMBOLIC_LINK },
|
||||
{ "ConditionPathIsMountPoint", config_parse_unit_condition_path, CONDITION_PATH_IS_MOUNT_POINT },
|
||||
{ "ConditionPathIsReadWrite", config_parse_unit_condition_path, CONDITION_PATH_IS_READ_WRITE },
|
||||
{ "ConditionPathIsEncrypted", config_parse_unit_condition_path, CONDITION_PATH_IS_ENCRYPTED },
|
||||
{ "ConditionDirectoryNotEmpty", config_parse_unit_condition_path, CONDITION_DIRECTORY_NOT_EMPTY },
|
||||
{ "ConditionFileNotEmpty", config_parse_unit_condition_path, CONDITION_FILE_NOT_EMPTY },
|
||||
{ "ConditionFileIsExecutable", config_parse_unit_condition_path, CONDITION_FILE_IS_EXECUTABLE },
|
||||
@ -45,7 +44,6 @@ static const condition_definition condition_definitions[] = {
|
||||
{ "AssertPathIsSymbolicLink", config_parse_unit_condition_path, CONDITION_PATH_IS_SYMBOLIC_LINK },
|
||||
{ "AssertPathIsMountPoint", config_parse_unit_condition_path, CONDITION_PATH_IS_MOUNT_POINT },
|
||||
{ "AssertPathIsReadWrite", config_parse_unit_condition_path, CONDITION_PATH_IS_READ_WRITE },
|
||||
{ "AssertPathIsEncrypted", config_parse_unit_condition_path, CONDITION_PATH_IS_ENCRYPTED },
|
||||
{ "AssertDirectoryNotEmpty", config_parse_unit_condition_path, CONDITION_DIRECTORY_NOT_EMPTY },
|
||||
{ "AssertFileNotEmpty", config_parse_unit_condition_path, CONDITION_FILE_NOT_EMPTY },
|
||||
{ "AssertFileIsExecutable", config_parse_unit_condition_path, CONDITION_FILE_IS_EXECUTABLE },
|
||||
@ -145,11 +143,11 @@ int verify_conditions(char **lines, UnitFileScope scope) {
|
||||
return r;
|
||||
}
|
||||
|
||||
r = condition_test_list(u->asserts, environ, assert_type_to_string, log_helper, u);
|
||||
r = condition_test_list(u->asserts, assert_type_to_string, log_helper, u);
|
||||
if (u->asserts)
|
||||
log_notice("Asserts %s.", r > 0 ? "succeeded" : "failed");
|
||||
|
||||
q = condition_test_list(u->conditions, environ, condition_type_to_string, log_helper, u);
|
||||
q = condition_test_list(u->conditions, condition_type_to_string, log_helper, u);
|
||||
if (u->conditions)
|
||||
log_notice("Conditions %s.", q > 0 ? "succeeded" : "failed");
|
||||
|
||||
|
@ -41,11 +41,6 @@ uint64_t physical_memory(void) {
|
||||
}
|
||||
if (r > 0) {
|
||||
r = cg_get_attribute("memory", root, "memory.max", &value);
|
||||
if (r == -ENOENT) /* Field does not exist on the system's top-level cgroup, hence don't
|
||||
* complain. (Note that it might exist on our own root though, if we live
|
||||
* in a cgroup namespace, hence check anyway instead of not even
|
||||
* trying.) */
|
||||
return mem;
|
||||
if (r < 0) {
|
||||
log_debug_errno(r, "Failed to read memory.max cgroup attribute, ignoring cgroup memory limit: %m");
|
||||
return mem;
|
||||
|
@ -1705,50 +1705,24 @@ static int log_unit_internal(void *userdata, int level, int error, const char *f
|
||||
}
|
||||
|
||||
static bool unit_test_condition(Unit *u) {
|
||||
_cleanup_strv_free_ char **env = NULL;
|
||||
int r;
|
||||
|
||||
assert(u);
|
||||
|
||||
dual_timestamp_get(&u->condition_timestamp);
|
||||
|
||||
r = manager_get_effective_environment(u->manager, &env);
|
||||
if (r < 0) {
|
||||
log_unit_error_errno(u, r, "Failed to determine effective environment: %m");
|
||||
u->condition_result = CONDITION_ERROR;
|
||||
} else
|
||||
u->condition_result = condition_test_list(
|
||||
u->conditions,
|
||||
env,
|
||||
condition_type_to_string,
|
||||
log_unit_internal,
|
||||
u);
|
||||
u->condition_result = condition_test_list(u->conditions, condition_type_to_string, log_unit_internal, u);
|
||||
|
||||
unit_add_to_dbus_queue(u);
|
||||
|
||||
return u->condition_result;
|
||||
}
|
||||
|
||||
static bool unit_test_assert(Unit *u) {
|
||||
_cleanup_strv_free_ char **env = NULL;
|
||||
int r;
|
||||
|
||||
assert(u);
|
||||
|
||||
dual_timestamp_get(&u->assert_timestamp);
|
||||
|
||||
r = manager_get_effective_environment(u->manager, &env);
|
||||
if (r < 0) {
|
||||
log_unit_error_errno(u, r, "Failed to determine effective environment: %m");
|
||||
u->assert_result = CONDITION_ERROR;
|
||||
} else
|
||||
u->assert_result = condition_test_list(
|
||||
u->asserts,
|
||||
env,
|
||||
assert_type_to_string,
|
||||
log_unit_internal,
|
||||
u);
|
||||
u->assert_result = condition_test_list(u->asserts, assert_type_to_string, log_unit_internal, u);
|
||||
|
||||
unit_add_to_dbus_queue(u);
|
||||
|
||||
return u->assert_result;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "bond.h"
|
||||
@ -694,7 +693,7 @@ int netdev_load_one(Manager *manager, const char *filename) {
|
||||
return r;
|
||||
|
||||
/* skip out early if configuration does not match the environment */
|
||||
if (!condition_test_list(netdev_raw->conditions, environ, NULL, NULL, NULL)) {
|
||||
if (!condition_test_list(netdev_raw->conditions, NULL, NULL, NULL)) {
|
||||
log_debug("%s: Conditions in the file do not match the system environment, skipping.", filename);
|
||||
return 0;
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "conf-files.h"
|
||||
@ -173,7 +172,7 @@ int network_verify(Network *network) {
|
||||
network->filename);
|
||||
|
||||
/* skip out early if configuration does not match the environment */
|
||||
if (!condition_test_list(network->conditions, environ, NULL, NULL, NULL))
|
||||
if (!condition_test_list(network->conditions, NULL, NULL, NULL))
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"%s: Conditions in the file do not match the system environment, skipping.",
|
||||
network->filename);
|
||||
|
@ -107,7 +107,7 @@ int kernel_route_expiration_supported(void) {
|
||||
.type = CONDITION_KERNEL_VERSION,
|
||||
.parameter = (char *) ">= 4.5"
|
||||
};
|
||||
r = condition_test(&c, NULL);
|
||||
r = condition_test(&c);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "extract-word.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fs-util.h"
|
||||
#include "glob-util.h"
|
||||
#include "hostname-util.h"
|
||||
#include "ima-util.h"
|
||||
@ -73,11 +72,11 @@ Condition* condition_new(ConditionType type, const char *parameter, bool trigger
|
||||
return c;
|
||||
}
|
||||
|
||||
Condition* condition_free(Condition *c) {
|
||||
void condition_free(Condition *c) {
|
||||
assert(c);
|
||||
|
||||
free(c->parameter);
|
||||
return mfree(c);
|
||||
free(c);
|
||||
}
|
||||
|
||||
Condition* condition_free_list_type(Condition *head, ConditionType type) {
|
||||
@ -93,7 +92,7 @@ Condition* condition_free_list_type(Condition *head, ConditionType type) {
|
||||
return head;
|
||||
}
|
||||
|
||||
static int condition_test_kernel_command_line(Condition *c, char **env) {
|
||||
static int condition_test_kernel_command_line(Condition *c) {
|
||||
_cleanup_free_ char *line = NULL;
|
||||
const char *p;
|
||||
bool equal;
|
||||
@ -202,7 +201,7 @@ static bool test_order(int k, OrderOperator p) {
|
||||
}
|
||||
}
|
||||
|
||||
static int condition_test_kernel_version(Condition *c, char **env) {
|
||||
static int condition_test_kernel_version(Condition *c) {
|
||||
OrderOperator order;
|
||||
struct utsname u;
|
||||
const char *p;
|
||||
@ -260,7 +259,7 @@ static int condition_test_kernel_version(Condition *c, char **env) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static int condition_test_memory(Condition *c, char **env) {
|
||||
static int condition_test_memory(Condition *c) {
|
||||
OrderOperator order;
|
||||
uint64_t m, k;
|
||||
const char *p;
|
||||
@ -284,7 +283,7 @@ static int condition_test_memory(Condition *c, char **env) {
|
||||
return test_order(CMP(m, k), order);
|
||||
}
|
||||
|
||||
static int condition_test_cpus(Condition *c, char **env) {
|
||||
static int condition_test_cpus(Condition *c) {
|
||||
OrderOperator order;
|
||||
const char *p;
|
||||
unsigned k;
|
||||
@ -310,7 +309,7 @@ static int condition_test_cpus(Condition *c, char **env) {
|
||||
return test_order(CMP((unsigned) n, k), order);
|
||||
}
|
||||
|
||||
static int condition_test_user(Condition *c, char **env) {
|
||||
static int condition_test_user(Condition *c) {
|
||||
uid_t id;
|
||||
int r;
|
||||
_cleanup_free_ char *username = NULL;
|
||||
@ -345,7 +344,7 @@ static int condition_test_user(Condition *c, char **env) {
|
||||
return id == getuid() || id == geteuid();
|
||||
}
|
||||
|
||||
static int condition_test_control_group_controller(Condition *c, char **env) {
|
||||
static int condition_test_control_group_controller(Condition *c) {
|
||||
int r;
|
||||
CGroupMask system_mask, wanted_mask = 0;
|
||||
|
||||
@ -369,7 +368,7 @@ static int condition_test_control_group_controller(Condition *c, char **env) {
|
||||
return FLAGS_SET(system_mask, wanted_mask);
|
||||
}
|
||||
|
||||
static int condition_test_group(Condition *c, char **env) {
|
||||
static int condition_test_group(Condition *c) {
|
||||
gid_t id;
|
||||
int r;
|
||||
|
||||
@ -388,7 +387,7 @@ static int condition_test_group(Condition *c, char **env) {
|
||||
return in_group(c->parameter) > 0;
|
||||
}
|
||||
|
||||
static int condition_test_virtualization(Condition *c, char **env) {
|
||||
static int condition_test_virtualization(Condition *c) {
|
||||
int b, v;
|
||||
|
||||
assert(c);
|
||||
@ -418,7 +417,7 @@ static int condition_test_virtualization(Condition *c, char **env) {
|
||||
return v != VIRTUALIZATION_NONE && streq(c->parameter, virtualization_to_string(v));
|
||||
}
|
||||
|
||||
static int condition_test_architecture(Condition *c, char **env) {
|
||||
static int condition_test_architecture(Condition *c) {
|
||||
int a, b;
|
||||
|
||||
assert(c);
|
||||
@ -440,7 +439,7 @@ static int condition_test_architecture(Condition *c, char **env) {
|
||||
return a == b;
|
||||
}
|
||||
|
||||
static int condition_test_host(Condition *c, char **env) {
|
||||
static int condition_test_host(Condition *c) {
|
||||
_cleanup_free_ char *h = NULL;
|
||||
sd_id128_t x, y;
|
||||
int r;
|
||||
@ -465,7 +464,7 @@ static int condition_test_host(Condition *c, char **env) {
|
||||
return fnmatch(c->parameter, h, FNM_CASEFOLD) == 0;
|
||||
}
|
||||
|
||||
static int condition_test_ac_power(Condition *c, char **env) {
|
||||
static int condition_test_ac_power(Condition *c) {
|
||||
int r;
|
||||
|
||||
assert(c);
|
||||
@ -479,7 +478,7 @@ static int condition_test_ac_power(Condition *c, char **env) {
|
||||
return (on_ac_power() != 0) == !!r;
|
||||
}
|
||||
|
||||
static int condition_test_security(Condition *c, char **env) {
|
||||
static int condition_test_security(Condition *c) {
|
||||
assert(c);
|
||||
assert(c->parameter);
|
||||
assert(c->type == CONDITION_SECURITY);
|
||||
@ -502,7 +501,7 @@ static int condition_test_security(Condition *c, char **env) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static int condition_test_capability(Condition *c, char **env) {
|
||||
static int condition_test_capability(Condition *c) {
|
||||
unsigned long long capabilities = (unsigned long long) -1;
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
int value, r;
|
||||
@ -545,7 +544,7 @@ static int condition_test_capability(Condition *c, char **env) {
|
||||
return !!(capabilities & (1ULL << value));
|
||||
}
|
||||
|
||||
static int condition_test_needs_update(Condition *c, char **env) {
|
||||
static int condition_test_needs_update(Condition *c) {
|
||||
const char *p;
|
||||
struct stat usr, other;
|
||||
|
||||
@ -611,7 +610,7 @@ static int condition_test_needs_update(Condition *c, char **env) {
|
||||
return usr.st_mtim.tv_nsec > other.st_mtim.tv_nsec;
|
||||
}
|
||||
|
||||
static int condition_test_first_boot(Condition *c, char **env) {
|
||||
static int condition_test_first_boot(Condition *c) {
|
||||
int r;
|
||||
|
||||
assert(c);
|
||||
@ -625,36 +624,7 @@ static int condition_test_first_boot(Condition *c, char **env) {
|
||||
return (access("/run/systemd/first-boot", F_OK) >= 0) == !!r;
|
||||
}
|
||||
|
||||
static int condition_test_environment(Condition *c, char **env) {
|
||||
bool equal;
|
||||
char **i;
|
||||
|
||||
assert(c);
|
||||
assert(c->parameter);
|
||||
assert(c->type == CONDITION_ENVIRONMENT);
|
||||
|
||||
equal = strchr(c->parameter, '=');
|
||||
|
||||
STRV_FOREACH(i, env) {
|
||||
bool found;
|
||||
|
||||
if (equal)
|
||||
found = streq(c->parameter, *i);
|
||||
else {
|
||||
const char *f;
|
||||
|
||||
f = startswith(*i, c->parameter);
|
||||
found = f && IN_SET(*f, 0, '=');
|
||||
}
|
||||
|
||||
if (found)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int condition_test_path_exists(Condition *c, char **env) {
|
||||
static int condition_test_path_exists(Condition *c) {
|
||||
assert(c);
|
||||
assert(c->parameter);
|
||||
assert(c->type == CONDITION_PATH_EXISTS);
|
||||
@ -662,7 +632,7 @@ static int condition_test_path_exists(Condition *c, char **env) {
|
||||
return access(c->parameter, F_OK) >= 0;
|
||||
}
|
||||
|
||||
static int condition_test_path_exists_glob(Condition *c, char **env) {
|
||||
static int condition_test_path_exists_glob(Condition *c) {
|
||||
assert(c);
|
||||
assert(c->parameter);
|
||||
assert(c->type == CONDITION_PATH_EXISTS_GLOB);
|
||||
@ -670,7 +640,7 @@ static int condition_test_path_exists_glob(Condition *c, char **env) {
|
||||
return glob_exists(c->parameter) > 0;
|
||||
}
|
||||
|
||||
static int condition_test_path_is_directory(Condition *c, char **env) {
|
||||
static int condition_test_path_is_directory(Condition *c) {
|
||||
assert(c);
|
||||
assert(c->parameter);
|
||||
assert(c->type == CONDITION_PATH_IS_DIRECTORY);
|
||||
@ -678,7 +648,7 @@ static int condition_test_path_is_directory(Condition *c, char **env) {
|
||||
return is_dir(c->parameter, true) > 0;
|
||||
}
|
||||
|
||||
static int condition_test_path_is_symbolic_link(Condition *c, char **env) {
|
||||
static int condition_test_path_is_symbolic_link(Condition *c) {
|
||||
assert(c);
|
||||
assert(c->parameter);
|
||||
assert(c->type == CONDITION_PATH_IS_SYMBOLIC_LINK);
|
||||
@ -686,7 +656,7 @@ static int condition_test_path_is_symbolic_link(Condition *c, char **env) {
|
||||
return is_symlink(c->parameter) > 0;
|
||||
}
|
||||
|
||||
static int condition_test_path_is_mount_point(Condition *c, char **env) {
|
||||
static int condition_test_path_is_mount_point(Condition *c) {
|
||||
assert(c);
|
||||
assert(c->parameter);
|
||||
assert(c->type == CONDITION_PATH_IS_MOUNT_POINT);
|
||||
@ -694,7 +664,7 @@ static int condition_test_path_is_mount_point(Condition *c, char **env) {
|
||||
return path_is_mount_point(c->parameter, NULL, AT_SYMLINK_FOLLOW) > 0;
|
||||
}
|
||||
|
||||
static int condition_test_path_is_read_write(Condition *c, char **env) {
|
||||
static int condition_test_path_is_read_write(Condition *c) {
|
||||
assert(c);
|
||||
assert(c->parameter);
|
||||
assert(c->type == CONDITION_PATH_IS_READ_WRITE);
|
||||
@ -702,21 +672,7 @@ static int condition_test_path_is_read_write(Condition *c, char **env) {
|
||||
return path_is_read_only_fs(c->parameter) <= 0;
|
||||
}
|
||||
|
||||
static int condition_test_path_is_encrypted(Condition *c, char **env) {
|
||||
int r;
|
||||
|
||||
assert(c);
|
||||
assert(c->parameter);
|
||||
assert(c->type == CONDITION_PATH_IS_ENCRYPTED);
|
||||
|
||||
r = path_is_encrypted(c->parameter);
|
||||
if (r < 0 && r != -ENOENT)
|
||||
log_debug_errno(r, "Failed to determine if '%s' is encrypted: %m", c->parameter);
|
||||
|
||||
return r > 0;
|
||||
}
|
||||
|
||||
static int condition_test_directory_not_empty(Condition *c, char **env) {
|
||||
static int condition_test_directory_not_empty(Condition *c) {
|
||||
int r;
|
||||
|
||||
assert(c);
|
||||
@ -727,7 +683,7 @@ static int condition_test_directory_not_empty(Condition *c, char **env) {
|
||||
return r <= 0 && r != -ENOENT;
|
||||
}
|
||||
|
||||
static int condition_test_file_not_empty(Condition *c, char **env) {
|
||||
static int condition_test_file_not_empty(Condition *c) {
|
||||
struct stat st;
|
||||
|
||||
assert(c);
|
||||
@ -739,7 +695,7 @@ static int condition_test_file_not_empty(Condition *c, char **env) {
|
||||
st.st_size > 0);
|
||||
}
|
||||
|
||||
static int condition_test_file_is_executable(Condition *c, char **env) {
|
||||
static int condition_test_file_is_executable(Condition *c) {
|
||||
struct stat st;
|
||||
|
||||
assert(c);
|
||||
@ -751,7 +707,7 @@ static int condition_test_file_is_executable(Condition *c, char **env) {
|
||||
(st.st_mode & 0111));
|
||||
}
|
||||
|
||||
static int condition_test_null(Condition *c, char **env) {
|
||||
static int condition_test_null(Condition *c) {
|
||||
assert(c);
|
||||
assert(c->type == CONDITION_NULL);
|
||||
|
||||
@ -760,16 +716,15 @@ static int condition_test_null(Condition *c, char **env) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int condition_test(Condition *c, char **env) {
|
||||
int condition_test(Condition *c) {
|
||||
|
||||
static int (*const condition_tests[_CONDITION_TYPE_MAX])(Condition *c, char **env) = {
|
||||
static int (*const condition_tests[_CONDITION_TYPE_MAX])(Condition *c) = {
|
||||
[CONDITION_PATH_EXISTS] = condition_test_path_exists,
|
||||
[CONDITION_PATH_EXISTS_GLOB] = condition_test_path_exists_glob,
|
||||
[CONDITION_PATH_IS_DIRECTORY] = condition_test_path_is_directory,
|
||||
[CONDITION_PATH_IS_SYMBOLIC_LINK] = condition_test_path_is_symbolic_link,
|
||||
[CONDITION_PATH_IS_MOUNT_POINT] = condition_test_path_is_mount_point,
|
||||
[CONDITION_PATH_IS_READ_WRITE] = condition_test_path_is_read_write,
|
||||
[CONDITION_PATH_IS_ENCRYPTED] = condition_test_path_is_encrypted,
|
||||
[CONDITION_DIRECTORY_NOT_EMPTY] = condition_test_directory_not_empty,
|
||||
[CONDITION_FILE_NOT_EMPTY] = condition_test_file_not_empty,
|
||||
[CONDITION_FILE_IS_EXECUTABLE] = condition_test_file_is_executable,
|
||||
@ -789,7 +744,6 @@ int condition_test(Condition *c, char **env) {
|
||||
[CONDITION_NULL] = condition_test_null,
|
||||
[CONDITION_CPUS] = condition_test_cpus,
|
||||
[CONDITION_MEMORY] = condition_test_memory,
|
||||
[CONDITION_ENVIRONMENT] = condition_test_environment,
|
||||
};
|
||||
|
||||
int r, b;
|
||||
@ -798,7 +752,7 @@ int condition_test(Condition *c, char **env) {
|
||||
assert(c->type >= 0);
|
||||
assert(c->type < _CONDITION_TYPE_MAX);
|
||||
|
||||
r = condition_tests[c->type](c, env);
|
||||
r = condition_tests[c->type](c);
|
||||
if (r < 0) {
|
||||
c->result = CONDITION_ERROR;
|
||||
return r;
|
||||
@ -809,13 +763,7 @@ int condition_test(Condition *c, char **env) {
|
||||
return b;
|
||||
}
|
||||
|
||||
bool condition_test_list(
|
||||
Condition *first,
|
||||
char **env,
|
||||
condition_to_string_t to_string,
|
||||
condition_test_logger_t logger,
|
||||
void *userdata) {
|
||||
|
||||
bool condition_test_list(Condition *first, const char *(*to_string)(ConditionType t), condition_test_logger_t logger, void *userdata) {
|
||||
Condition *c;
|
||||
int triggered = -1;
|
||||
|
||||
@ -831,7 +779,7 @@ bool condition_test_list(
|
||||
LIST_FOREACH(conditions, c, first) {
|
||||
int r;
|
||||
|
||||
r = condition_test(c, env);
|
||||
r = condition_test(c);
|
||||
|
||||
if (logger) {
|
||||
const char *p = c->type == CONDITION_NULL ? "true" : c->parameter;
|
||||
@ -864,10 +812,9 @@ bool condition_test_list(
|
||||
return triggered != 0;
|
||||
}
|
||||
|
||||
void condition_dump(Condition *c, FILE *f, const char *prefix, condition_to_string_t to_string) {
|
||||
void condition_dump(Condition *c, FILE *f, const char *prefix, const char *(*to_string)(ConditionType t)) {
|
||||
assert(c);
|
||||
assert(f);
|
||||
assert(to_string);
|
||||
|
||||
prefix = strempty(prefix);
|
||||
|
||||
@ -881,7 +828,7 @@ void condition_dump(Condition *c, FILE *f, const char *prefix, condition_to_stri
|
||||
condition_result_to_string(c->result));
|
||||
}
|
||||
|
||||
void condition_dump_list(Condition *first, FILE *f, const char *prefix, condition_to_string_t to_string) {
|
||||
void condition_dump_list(Condition *first, FILE *f, const char *prefix, const char *(*to_string)(ConditionType t)) {
|
||||
Condition *c;
|
||||
|
||||
LIST_FOREACH(conditions, c, first)
|
||||
@ -905,7 +852,6 @@ static const char* const condition_type_table[_CONDITION_TYPE_MAX] = {
|
||||
[CONDITION_PATH_IS_SYMBOLIC_LINK] = "ConditionPathIsSymbolicLink",
|
||||
[CONDITION_PATH_IS_MOUNT_POINT] = "ConditionPathIsMountPoint",
|
||||
[CONDITION_PATH_IS_READ_WRITE] = "ConditionPathIsReadWrite",
|
||||
[CONDITION_PATH_IS_ENCRYPTED] = "ConditionPathIsEncrypted",
|
||||
[CONDITION_DIRECTORY_NOT_EMPTY] = "ConditionDirectoryNotEmpty",
|
||||
[CONDITION_FILE_NOT_EMPTY] = "ConditionFileNotEmpty",
|
||||
[CONDITION_FILE_IS_EXECUTABLE] = "ConditionFileIsExecutable",
|
||||
@ -915,7 +861,6 @@ static const char* const condition_type_table[_CONDITION_TYPE_MAX] = {
|
||||
[CONDITION_NULL] = "ConditionNull",
|
||||
[CONDITION_CPUS] = "ConditionCPUs",
|
||||
[CONDITION_MEMORY] = "ConditionMemory",
|
||||
[CONDITION_ENVIRONMENT] = "ConditionEnvironment",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(condition_type, ConditionType);
|
||||
@ -937,7 +882,6 @@ static const char* const assert_type_table[_CONDITION_TYPE_MAX] = {
|
||||
[CONDITION_PATH_IS_SYMBOLIC_LINK] = "AssertPathIsSymbolicLink",
|
||||
[CONDITION_PATH_IS_MOUNT_POINT] = "AssertPathIsMountPoint",
|
||||
[CONDITION_PATH_IS_READ_WRITE] = "AssertPathIsReadWrite",
|
||||
[CONDITION_PATH_IS_ENCRYPTED] = "AssertPathIsEncrypted",
|
||||
[CONDITION_DIRECTORY_NOT_EMPTY] = "AssertDirectoryNotEmpty",
|
||||
[CONDITION_FILE_NOT_EMPTY] = "AssertFileNotEmpty",
|
||||
[CONDITION_FILE_IS_EXECUTABLE] = "AssertFileIsExecutable",
|
||||
@ -947,7 +891,6 @@ static const char* const assert_type_table[_CONDITION_TYPE_MAX] = {
|
||||
[CONDITION_NULL] = "AssertNull",
|
||||
[CONDITION_CPUS] = "AssertCPUs",
|
||||
[CONDITION_MEMORY] = "AssertMemory",
|
||||
[CONDITION_ENVIRONMENT] = "AssertEnvironment",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(assert_type, ConditionType);
|
||||
|
@ -18,7 +18,6 @@ typedef enum ConditionType {
|
||||
CONDITION_AC_POWER,
|
||||
CONDITION_MEMORY,
|
||||
CONDITION_CPUS,
|
||||
CONDITION_ENVIRONMENT,
|
||||
|
||||
CONDITION_NEEDS_UPDATE,
|
||||
CONDITION_FIRST_BOOT,
|
||||
@ -29,7 +28,6 @@ typedef enum ConditionType {
|
||||
CONDITION_PATH_IS_SYMBOLIC_LINK,
|
||||
CONDITION_PATH_IS_MOUNT_POINT,
|
||||
CONDITION_PATH_IS_READ_WRITE,
|
||||
CONDITION_PATH_IS_ENCRYPTED,
|
||||
CONDITION_DIRECTORY_NOT_EMPTY,
|
||||
CONDITION_FILE_NOT_EMPTY,
|
||||
CONDITION_FILE_IS_EXECUTABLE,
|
||||
@ -68,20 +66,18 @@ typedef struct Condition {
|
||||
} Condition;
|
||||
|
||||
Condition* condition_new(ConditionType type, const char *parameter, bool trigger, bool negate);
|
||||
Condition* condition_free(Condition *c);
|
||||
void condition_free(Condition *c);
|
||||
Condition* condition_free_list_type(Condition *first, ConditionType type);
|
||||
static inline Condition* condition_free_list(Condition *first) {
|
||||
return condition_free_list_type(first, _CONDITION_TYPE_INVALID);
|
||||
}
|
||||
|
||||
int condition_test(Condition *c, char **env);
|
||||
|
||||
int condition_test(Condition *c);
|
||||
typedef int (*condition_test_logger_t)(void *userdata, int level, int error, const char *file, int line, const char *func, const char *format, ...) _printf_(7, 8);
|
||||
typedef const char* (*condition_to_string_t)(ConditionType t) _const_;
|
||||
bool condition_test_list(Condition *first, char **env, condition_to_string_t to_string, condition_test_logger_t logger, void *userdata);
|
||||
bool condition_test_list(Condition *first, const char *(*to_string)(ConditionType t), condition_test_logger_t logger, void *userdata);
|
||||
|
||||
void condition_dump(Condition *c, FILE *f, const char *prefix, condition_to_string_t to_string);
|
||||
void condition_dump_list(Condition *c, FILE *f, const char *prefix, condition_to_string_t to_string);
|
||||
void condition_dump(Condition *c, FILE *f, const char *prefix, const char *(*to_string)(ConditionType t));
|
||||
void condition_dump_list(Condition *c, FILE *f, const char *prefix, const char *(*to_string)(ConditionType t));
|
||||
|
||||
const char* condition_type_to_string(ConditionType t) _const_;
|
||||
ConditionType condition_type_from_string(const char *s) _pure_;
|
||||
@ -100,7 +96,6 @@ static inline bool condition_takes_path(ConditionType t) {
|
||||
CONDITION_PATH_IS_SYMBOLIC_LINK,
|
||||
CONDITION_PATH_IS_MOUNT_POINT,
|
||||
CONDITION_PATH_IS_READ_WRITE,
|
||||
CONDITION_PATH_IS_ENCRYPTED,
|
||||
CONDITION_DIRECTORY_NOT_EMPTY,
|
||||
CONDITION_FILE_NOT_EMPTY,
|
||||
CONDITION_FILE_IS_EXECUTABLE,
|
||||
|
@ -13,15 +13,12 @@
|
||||
#define TMPFS_LIMITS_EMPTY_OR_ALMOST ",size=4m,nr_inodes=1k"
|
||||
#define TMPFS_LIMITS_SYS TMPFS_LIMITS_EMPTY_OR_ALMOST
|
||||
#define TMPFS_LIMITS_SYS_FS_CGROUP TMPFS_LIMITS_EMPTY_OR_ALMOST
|
||||
/* On an extremely small device with only 256MB of RAM, 20% of RAM for /run should be enough for re-exec of
|
||||
PID1 because 16MB of free space is required. */
|
||||
#define TMPFS_LIMITS_RUN ",size=20%,nr_inodes=800k"
|
||||
/* 10% of RAM (using 16GB of RAM as a baseline) translates to 400k inodes (assuming 4k each) and 25%
|
||||
translates to 1M inodes */
|
||||
#define TMPFS_LIMITS_TMP ",size=10%,nr_inodes=400k"
|
||||
#define TMPFS_LIMITS_DEV_SHM TMPFS_LIMITS_TMP
|
||||
#define TMPFS_LIMITS_RUN TMPFS_LIMITS_TMP
|
||||
#define TMPFS_LIMITS_TEMPORARY_FS TMPFS_LIMITS_TMP
|
||||
/* More space for volatile root and /var */
|
||||
#define TMPFS_LIMITS_VAR ",size=25%,nr_inodes=1m"
|
||||
#define TMPFS_LIMITS_ROOTFS TMPFS_LIMITS_VAR
|
||||
#define TMPFS_LIMITS_VOLATILE_STATE TMPFS_LIMITS_VAR
|
||||
|
@ -39,87 +39,82 @@ static void test_condition_test_path(void) {
|
||||
|
||||
condition = condition_new(CONDITION_PATH_EXISTS, "/bin/sh", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ));
|
||||
assert_se(condition_test(condition));
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_PATH_EXISTS, "/bin/s?", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_PATH_EXISTS_GLOB, "/bin/s?", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_PATH_EXISTS_GLOB, "/bin/s?", false, true);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_PATH_EXISTS, "/thiscertainlywontexist", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_PATH_EXISTS, "/thiscertainlywontexist", false, true);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_PATH_IS_DIRECTORY, "/bin", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_DIRECTORY_NOT_EMPTY, "/bin", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_FILE_NOT_EMPTY, "/bin/sh", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_FILE_IS_EXECUTABLE, "/bin/sh", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_FILE_IS_EXECUTABLE, "/etc/passwd", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_PATH_IS_MOUNT_POINT, "/proc", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_PATH_IS_MOUNT_POINT, "/", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_PATH_IS_MOUNT_POINT, "/bin", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_PATH_IS_READ_WRITE, "/tmp", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_PATH_IS_ENCRYPTED, "/sys", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_PATH_IS_SYMBOLIC_LINK, "/dev/stdout", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
}
|
||||
|
||||
@ -139,12 +134,12 @@ static void test_condition_test_control_group_controller(void) {
|
||||
/* Invalid controllers are ignored */
|
||||
condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, "thisisnotarealcontroller", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, "thisisnotarealcontroller", false, true);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
assert_se(cg_mask_supported(&system_mask) >= 0);
|
||||
@ -157,23 +152,23 @@ static void test_condition_test_control_group_controller(void) {
|
||||
log_info("this controller is available");
|
||||
condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, local_controller_name, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, local_controller_name, false, true);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
} else {
|
||||
log_info("this controller is unavailable");
|
||||
condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, local_controller_name, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, local_controller_name, false, true);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
}
|
||||
}
|
||||
@ -183,12 +178,12 @@ static void test_condition_test_control_group_controller(void) {
|
||||
|
||||
condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, strempty(controller_name), false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, strempty(controller_name), false, true);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
}
|
||||
|
||||
@ -197,17 +192,17 @@ static void test_condition_test_ac_power(void) {
|
||||
|
||||
condition = condition_new(CONDITION_AC_POWER, "true", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == on_ac_power());
|
||||
assert_se(condition_test(condition) == on_ac_power());
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_AC_POWER, "false", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) != on_ac_power());
|
||||
assert_se(condition_test(condition) != on_ac_power());
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_AC_POWER, "false", false, true);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == on_ac_power());
|
||||
assert_se(condition_test(condition) == on_ac_power());
|
||||
condition_free(condition);
|
||||
}
|
||||
|
||||
@ -224,17 +219,17 @@ static void test_condition_test_host(void) {
|
||||
|
||||
condition = condition_new(CONDITION_HOST, sid, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_HOST, "garbage value jjjjjjjjjjjjjj", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_HOST, sid, false, true);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
hostname = gethostname_malloc();
|
||||
@ -246,7 +241,7 @@ static void test_condition_test_host(void) {
|
||||
else {
|
||||
condition = condition_new(CONDITION_HOST, hostname, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
}
|
||||
}
|
||||
@ -264,17 +259,17 @@ static void test_condition_test_architecture(void) {
|
||||
|
||||
condition = condition_new(CONDITION_ARCHITECTURE, sa, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_ARCHITECTURE, "garbage value", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_ARCHITECTURE, sa, false, true);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
}
|
||||
|
||||
@ -284,7 +279,7 @@ static void test_condition_test_kernel_command_line(void) {
|
||||
|
||||
condition = condition_new(CONDITION_KERNEL_COMMAND_LINE, "thisreallyshouldntbeonthekernelcommandline", false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
if (ERRNO_IS_PRIVILEGE(r))
|
||||
return;
|
||||
assert_se(r == 0);
|
||||
@ -292,7 +287,7 @@ static void test_condition_test_kernel_command_line(void) {
|
||||
|
||||
condition = condition_new(CONDITION_KERNEL_COMMAND_LINE, "andthis=neither", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
}
|
||||
|
||||
@ -303,26 +298,26 @@ static void test_condition_test_kernel_version(void) {
|
||||
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, "*thisreallyshouldntbeinthekernelversion*", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, "*", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
/* An artificially empty condition. It evaluates to true, but normally
|
||||
* such condition cannot be created, because the condition list is reset instead. */
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, "", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
assert_se(uname(&u) >= 0);
|
||||
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, u.release, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
strshorten(u.release, 4);
|
||||
@ -330,79 +325,79 @@ static void test_condition_test_kernel_version(void) {
|
||||
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, u.release, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
/* 0.1.2 would be a very very very old kernel */
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, "> 0.1.2", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, ">0.1.2", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, "'>0.1.2' '<9.0.0'", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, "> 0.1.2 < 9.0.0", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == -EINVAL);
|
||||
assert_se(condition_test(condition) == -EINVAL);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, ">", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == -EINVAL);
|
||||
assert_se(condition_test(condition) == -EINVAL);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, ">= 0.1.2", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, "< 0.1.2", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, "<= 0.1.2", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, "= 0.1.2", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
/* 4711.8.15 is a very very very future kernel */
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, "< 4711.8.15", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, "<= 4711.8.15", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, "= 4711.8.15", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, "> 4711.8.15", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, ">= 4711.8.15", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
assert_se(uname(&u) >= 0);
|
||||
@ -410,31 +405,31 @@ static void test_condition_test_kernel_version(void) {
|
||||
v = strjoina(">=", u.release);
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, v, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
v = strjoina("= ", u.release);
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, v, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
v = strjoina("<=", u.release);
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, v, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
v = strjoina("> ", u.release);
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, v, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
v = strjoina("< ", u.release);
|
||||
condition = condition_new(CONDITION_KERNEL_VERSION, v, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
}
|
||||
|
||||
@ -443,12 +438,12 @@ static void test_condition_test_null(void) {
|
||||
|
||||
condition = condition_new(CONDITION_NULL, NULL, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
assert_se(condition_test(condition) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_NULL, NULL, false, true);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
}
|
||||
|
||||
@ -457,42 +452,42 @@ static void test_condition_test_security(void) {
|
||||
|
||||
condition = condition_new(CONDITION_SECURITY, "garbage oifdsjfoidsjoj", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
assert_se(condition_test(condition) == 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_SECURITY, "selinux", false, true);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) != mac_selinux_use());
|
||||
assert_se(condition_test(condition) != mac_selinux_use());
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_SECURITY, "apparmor", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == mac_apparmor_use());
|
||||
assert_se(condition_test(condition) == mac_apparmor_use());
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_SECURITY, "tomoyo", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == mac_tomoyo_use());
|
||||
assert_se(condition_test(condition) == mac_tomoyo_use());
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_SECURITY, "ima", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == use_ima());
|
||||
assert_se(condition_test(condition) == use_ima());
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_SECURITY, "smack", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == mac_smack_use());
|
||||
assert_se(condition_test(condition) == mac_smack_use());
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_SECURITY, "audit", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == use_audit());
|
||||
assert_se(condition_test(condition) == use_audit());
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_SECURITY, "uefi-secureboot", false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == is_efi_secure_boot());
|
||||
assert_se(condition_test(condition) == is_efi_secure_boot());
|
||||
condition_free(condition);
|
||||
}
|
||||
|
||||
@ -515,7 +510,7 @@ static void test_condition_test_virtualization(void) {
|
||||
|
||||
condition = condition_new(CONDITION_VIRTUALIZATION, "garbage oifdsjfoidsjoj", false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
if (ERRNO_IS_PRIVILEGE(r))
|
||||
return;
|
||||
log_info("ConditionVirtualization=garbage → %i", r);
|
||||
@ -524,21 +519,21 @@ static void test_condition_test_virtualization(void) {
|
||||
|
||||
condition = condition_new(CONDITION_VIRTUALIZATION, "container", false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
log_info("ConditionVirtualization=container → %i", r);
|
||||
assert_se(r == !!detect_container());
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_VIRTUALIZATION, "vm", false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
log_info("ConditionVirtualization=vm → %i", r);
|
||||
assert_se(r == (detect_vm() && !detect_container()));
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_VIRTUALIZATION, "private-users", false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
log_info("ConditionVirtualization=private-users → %i", r);
|
||||
assert_se(r == !!running_in_userns());
|
||||
condition_free(condition);
|
||||
@ -559,7 +554,7 @@ static void test_condition_test_virtualization(void) {
|
||||
|
||||
condition = condition_new(CONDITION_VIRTUALIZATION, virt, false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
log_info("ConditionVirtualization=%s → %i", virt, r);
|
||||
assert_se(r >= 0);
|
||||
condition_free(condition);
|
||||
@ -574,7 +569,7 @@ static void test_condition_test_user(void) {
|
||||
|
||||
condition = condition_new(CONDITION_USER, "garbage oifdsjfoidsjoj", false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
log_info("ConditionUser=garbage → %i", r);
|
||||
assert_se(r == 0);
|
||||
condition_free(condition);
|
||||
@ -582,7 +577,7 @@ static void test_condition_test_user(void) {
|
||||
assert_se(asprintf(&uid, "%"PRIu32, UINT32_C(0xFFFF)) > 0);
|
||||
condition = condition_new(CONDITION_USER, uid, false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
log_info("ConditionUser=%s → %i", uid, r);
|
||||
assert_se(r == 0);
|
||||
condition_free(condition);
|
||||
@ -591,7 +586,7 @@ static void test_condition_test_user(void) {
|
||||
assert_se(asprintf(&uid, "%u", (unsigned)getuid()) > 0);
|
||||
condition = condition_new(CONDITION_USER, uid, false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
log_info("ConditionUser=%s → %i", uid, r);
|
||||
assert_se(r > 0);
|
||||
condition_free(condition);
|
||||
@ -600,7 +595,7 @@ static void test_condition_test_user(void) {
|
||||
assert_se(asprintf(&uid, "%u", (unsigned)getuid()+1) > 0);
|
||||
condition = condition_new(CONDITION_USER, uid, false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
log_info("ConditionUser=%s → %i", uid, r);
|
||||
assert_se(r == 0);
|
||||
condition_free(condition);
|
||||
@ -610,7 +605,7 @@ static void test_condition_test_user(void) {
|
||||
assert_se(username);
|
||||
condition = condition_new(CONDITION_USER, username, false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
log_info("ConditionUser=%s → %i", username, r);
|
||||
assert_se(r > 0);
|
||||
condition_free(condition);
|
||||
@ -619,14 +614,14 @@ static void test_condition_test_user(void) {
|
||||
username = (char*)(geteuid() == 0 ? NOBODY_USER_NAME : "root");
|
||||
condition = condition_new(CONDITION_USER, username, false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
log_info("ConditionUser=%s → %i", username, r);
|
||||
assert_se(r == 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_USER, "@system", false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
log_info("ConditionUser=@system → %i", r);
|
||||
if (uid_is_system(getuid()) || uid_is_system(geteuid()))
|
||||
assert_se(r > 0);
|
||||
@ -645,7 +640,7 @@ static void test_condition_test_group(void) {
|
||||
assert_se(0 < asprintf(&gid, "%u", UINT32_C(0xFFFF)));
|
||||
condition = condition_new(CONDITION_GROUP, gid, false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
log_info("ConditionGroup=%s → %i", gid, r);
|
||||
assert_se(r == 0);
|
||||
condition_free(condition);
|
||||
@ -654,7 +649,7 @@ static void test_condition_test_group(void) {
|
||||
assert_se(0 < asprintf(&gid, "%u", getgid()));
|
||||
condition = condition_new(CONDITION_GROUP, gid, false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
log_info("ConditionGroup=%s → %i", gid, r);
|
||||
assert_se(r > 0);
|
||||
condition_free(condition);
|
||||
@ -673,7 +668,7 @@ static void test_condition_test_group(void) {
|
||||
assert_se(0 < asprintf(&gid, "%u", gids[i]));
|
||||
condition = condition_new(CONDITION_GROUP, gid, false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
log_info("ConditionGroup=%s → %i", gid, r);
|
||||
assert_se(r > 0);
|
||||
condition_free(condition);
|
||||
@ -684,7 +679,7 @@ static void test_condition_test_group(void) {
|
||||
assert_se(groupname);
|
||||
condition = condition_new(CONDITION_GROUP, groupname, false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
log_info("ConditionGroup=%s → %i", groupname, r);
|
||||
assert_se(r > 0);
|
||||
condition_free(condition);
|
||||
@ -695,7 +690,7 @@ static void test_condition_test_group(void) {
|
||||
assert_se(0 < asprintf(&gid, "%u", max_gid+1));
|
||||
condition = condition_new(CONDITION_GROUP, gid, false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
log_info("ConditionGroup=%s → %i", gid, r);
|
||||
assert_se(r == 0);
|
||||
condition_free(condition);
|
||||
@ -704,7 +699,7 @@ static void test_condition_test_group(void) {
|
||||
groupname = (char*)(getegid() == 0 ? NOBODY_GROUP_NAME : "root");
|
||||
condition = condition_new(CONDITION_GROUP, groupname, false, false);
|
||||
assert_se(condition);
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
log_info("ConditionGroup=%s → %i", groupname, r);
|
||||
assert_se(r == 0);
|
||||
condition_free(condition);
|
||||
@ -719,7 +714,7 @@ static void test_condition_test_cpus_one(const char *s, bool result) {
|
||||
condition = condition_new(CONDITION_CPUS, s, false, false);
|
||||
assert_se(condition);
|
||||
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
assert_se(r >= 0);
|
||||
assert_se(r == result);
|
||||
condition_free(condition);
|
||||
@ -780,7 +775,7 @@ static void test_condition_test_memory_one(const char *s, bool result) {
|
||||
condition = condition_new(CONDITION_MEMORY, s, false, false);
|
||||
assert_se(condition);
|
||||
|
||||
r = condition_test(condition, environ);
|
||||
r = condition_test(condition);
|
||||
assert_se(r >= 0);
|
||||
assert_se(r == result);
|
||||
condition_free(condition);
|
||||
@ -831,34 +826,6 @@ static void test_condition_test_memory(void) {
|
||||
t = mfree(t);
|
||||
}
|
||||
|
||||
static void test_condition_test_environment_one(const char *s, bool result) {
|
||||
Condition *condition;
|
||||
int r;
|
||||
|
||||
log_debug("%s=%s", condition_type_to_string(CONDITION_ENVIRONMENT), s);
|
||||
|
||||
condition = condition_new(CONDITION_ENVIRONMENT, s, false, false);
|
||||
assert_se(condition);
|
||||
|
||||
r = condition_test(condition, environ);
|
||||
assert_se(r >= 0);
|
||||
assert_se(r == result);
|
||||
condition_free(condition);
|
||||
}
|
||||
|
||||
static void test_condition_test_environment(void) {
|
||||
assert_se(setenv("EXISTINGENVVAR", "foo", false) >= 0);
|
||||
|
||||
test_condition_test_environment_one("MISSINGENVVAR", false);
|
||||
test_condition_test_environment_one("MISSINGENVVAR=foo", false);
|
||||
test_condition_test_environment_one("MISSINGENVVAR=", false);
|
||||
|
||||
test_condition_test_environment_one("EXISTINGENVVAR", true);
|
||||
test_condition_test_environment_one("EXISTINGENVVAR=foo", true);
|
||||
test_condition_test_environment_one("EXISTINGENVVAR=bar", false);
|
||||
test_condition_test_environment_one("EXISTINGENVVAR=", false);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
test_setup_logging(LOG_DEBUG);
|
||||
|
||||
@ -877,7 +844,6 @@ int main(int argc, char *argv[]) {
|
||||
test_condition_test_control_group_controller();
|
||||
test_condition_test_cpus();
|
||||
test_condition_test_memory();
|
||||
test_condition_test_environment();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
#include <netinet/ether.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "sd-device.h"
|
||||
#include "sd-netlink.h"
|
||||
@ -174,7 +173,7 @@ int link_load_one(link_config_ctx *ctx, const char *filename) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!condition_test_list(link->conditions, environ, NULL, NULL, NULL)) {
|
||||
if (!condition_test_list(link->conditions, NULL, NULL, NULL)) {
|
||||
log_debug("%s: Conditions do not match the system environment, skipping.", filename);
|
||||
return 0;
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ tmpfiles = [['home.conf', ''],
|
||||
['systemd-nspawn.conf', 'ENABLE_MACHINED'],
|
||||
['systemd-tmp.conf', ''],
|
||||
['portables.conf', 'ENABLE_PORTABLED'],
|
||||
['systemd-pstore.conf', 'ENABLE_PSTORE'],
|
||||
['tmp.conf', ''],
|
||||
['x11.conf', ''],
|
||||
['legacy.conf', 'HAVE_SYSV_COMPAT'],
|
||||
|
@ -1,29 +0,0 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1+
|
||||
#
|
||||
# The systemd-pstore.service(1) archives the contents of /sys/fs/pstore
|
||||
# upon boot so that there is room for a subsequent dump. This service
|
||||
# is enabled with:
|
||||
# systemctl enable systemd-pstore
|
||||
#
|
||||
# With the service enabled, the kernel still needs to be configured
|
||||
# to write data into the pstore. The kernel has two parameters,
|
||||
# crash_kexec_post_notifiers and printk.always_kmsg_dump, that
|
||||
# control writes into pstore.
|
||||
#
|
||||
# The crash_kexec_post_notifiers parameter enables the kernel to write
|
||||
# dmesg (including stack trace) into pstore upon a panic, and
|
||||
# printk.always_kmsg_dump parameter enables the kernel to write dmesg
|
||||
# upon a normal shutdown (shutdown, reboot, halt).
|
||||
#
|
||||
# To configure the kernel parameters, uncomment the appropriate
|
||||
# line(s) below. The value written is either 'Y' to enable the
|
||||
# kernel parameter, or 'N' to disable the kernel parameter.
|
||||
#
|
||||
# After making a change to this file, do:
|
||||
# systemd-tmpfiles --create path/to/tmpfiles.d/systemd-pstore.conf
|
||||
#
|
||||
# These changes are automatically applied on future re-boots.
|
||||
|
||||
d /var/lib/systemd/pstore 0755 root root 14d
|
||||
#w /sys/module/printk/parameters/always_kmsg_dump - - - - Y
|
||||
w /sys/module/kernel/parameters/crash_kexec_post_notifiers - - - - Y
|
Loading…
x
Reference in New Issue
Block a user