seccomp: allow turning off of seccomp filtering via env var

Fixes: #17504

(While we are it, also move $SYSTEMD_SECCOMP_LOG= env var description
into the right document section)

Also suggested in: https://github.com/systemd/systemd/issues/17245#issuecomment-704773603
This commit is contained in:
Lennart Poettering
2020-11-05 20:22:19 +01:00
committed by Zbigniew Jędrzejewski-Szmek
parent d72ff2df1c
commit ce8f6d478e
3 changed files with 22 additions and 9 deletions
+14 -4
View File
@@ -259,10 +259,20 @@ static bool is_seccomp_filter_available(void) {
bool is_seccomp_available(void) {
static int cached_enabled = -1;
if (cached_enabled < 0)
cached_enabled =
is_basic_seccomp_available() &&
is_seccomp_filter_available();
if (cached_enabled < 0) {
int b;
b = getenv_bool_secure("SYSTEMD_SECCOMP");
if (b != 0) {
if (b < 0 && b != -ENXIO) /* ENXIO: env var unset */
log_debug_errno(b, "Failed to parse $SYSTEMD_SECCOMP value, ignoring.");
cached_enabled =
is_basic_seccomp_available() &&
is_seccomp_filter_available();
} else
cached_enabled = false;
}
return cached_enabled;
}