diff options
Diffstat (limited to 'src')
23 files changed, 65 insertions, 12 deletions
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index d97bafd1fb..2677a3fb32 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -209,7 +209,8 @@ static int write_mount_timeout(FILE *f, const char *where, const char *opts) { "x-systemd.mount-timeout\0", "TimeoutSec"); } -static int write_requires_after(FILE *f, const char *opts) { +static int write_dependency(FILE *f, const char *opts, + const char *filter, const char *format) { _cleanup_strv_free_ char **names = NULL, **units = NULL; _cleanup_free_ char *res = NULL; char **s; @@ -218,7 +219,7 @@ static int write_requires_after(FILE *f, const char *opts) { assert(f); assert(opts); - r = fstab_extract_values(opts, "x-systemd.requires", &names); + r = fstab_extract_values(opts, filter, &names); if (r < 0) return log_warning_errno(r, "Failed to parse options: %m"); if (r == 0) @@ -239,12 +240,29 @@ static int write_requires_after(FILE *f, const char *opts) { res = strv_join(units, " "); if (!res) return log_oom(); - fprintf(f, "After=%1$s\nRequires=%1$s\n", res); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" + fprintf(f, format, res); +#pragma GCC diagnostic pop } return 0; } +static int write_after(FILE *f, const char *opts) { + return write_dependency(f, opts, "x-systemd.after", "After=%1$s\n"); +} + +static int write_requires_after(FILE *f, const char *opts) { + return write_dependency(f, opts, + "x-systemd.requires", "After=%1$s\nRequires=%1$s\n"); +} + +static int write_before(FILE *f, const char *opts) { + return write_dependency(f, opts, + "x-systemd.before", "Before=%1$s\n"); +} + static int write_requires_mounts_for(FILE *f, const char *opts) { _cleanup_strv_free_ char **paths = NULL; _cleanup_free_ char *res = NULL; @@ -344,9 +362,15 @@ static int add_mount( fprintf(f, "Before=%s\n", post); if (!automount && opts) { + r = write_after(f, opts); + if (r < 0) + return r; r = write_requires_after(f, opts); if (r < 0) return r; + r = write_before(f, opts); + if (r < 0) + return r; r = write_requires_mounts_for(f, opts); if (r < 0) return r; @@ -421,9 +445,15 @@ static int add_mount( fprintf(f, "Before=%s\n", post); if (opts) { + r = write_after(f, opts); + if (r < 0) + return r; r = write_requires_after(f, opts); if (r < 0) return r; + r = write_before(f, opts); + if (r < 0) + return r; r = write_requires_mounts_for(f, opts); if (r < 0) return r; diff --git a/src/resolve/test-data/_443._tcp.fedoraproject.org.pkts b/src/resolve/test-data/_443._tcp.fedoraproject.org.pkts Binary files differdeleted file mode 100644 index a383c6286d..0000000000 --- a/src/resolve/test-data/_443._tcp.fedoraproject.org.pkts +++ /dev/null diff --git a/src/resolve/test-data/_openpgpkey.fedoraproject.org.pkts b/src/resolve/test-data/_openpgpkey.fedoraproject.org.pkts Binary files differdeleted file mode 100644 index 15de02e997..0000000000 --- a/src/resolve/test-data/_openpgpkey.fedoraproject.org.pkts +++ /dev/null diff --git a/src/resolve/test-data/fake-caa.pkts b/src/resolve/test-data/fake-caa.pkts Binary files differdeleted file mode 100644 index 1c3ecc5491..0000000000 --- a/src/resolve/test-data/fake-caa.pkts +++ /dev/null diff --git a/src/resolve/test-data/fedoraproject.org.pkts b/src/resolve/test-data/fedoraproject.org.pkts Binary files differdeleted file mode 100644 index 17874844d9..0000000000 --- a/src/resolve/test-data/fedoraproject.org.pkts +++ /dev/null diff --git a/src/resolve/test-data/gandi.net.pkts b/src/resolve/test-data/gandi.net.pkts Binary files differdeleted file mode 100644 index 5ef51e0c8e..0000000000 --- a/src/resolve/test-data/gandi.net.pkts +++ /dev/null diff --git a/src/resolve/test-data/google.com.pkts b/src/resolve/test-data/google.com.pkts Binary files differdeleted file mode 100644 index f98c4cd855..0000000000 --- a/src/resolve/test-data/google.com.pkts +++ /dev/null diff --git a/src/resolve/test-data/kyhwana.org.pkts b/src/resolve/test-data/kyhwana.org.pkts Binary files differdeleted file mode 100644 index e28a725c9a..0000000000 --- a/src/resolve/test-data/kyhwana.org.pkts +++ /dev/null diff --git a/src/resolve/test-data/root.pkts b/src/resolve/test-data/root.pkts Binary files differdeleted file mode 100644 index 54ba668c75..0000000000 --- a/src/resolve/test-data/root.pkts +++ /dev/null diff --git a/src/resolve/test-data/sw1a1aa-sw1a2aa-sw1a2ab-sw1a2ac.find.me.uk.pkts b/src/resolve/test-data/sw1a1aa-sw1a2aa-sw1a2ab-sw1a2ac.find.me.uk.pkts Binary files differdeleted file mode 100644 index a854249532..0000000000 --- a/src/resolve/test-data/sw1a1aa-sw1a2aa-sw1a2ab-sw1a2ac.find.me.uk.pkts +++ /dev/null diff --git a/src/resolve/test-data/teamits.com.pkts b/src/resolve/test-data/teamits.com.pkts Binary files differdeleted file mode 100644 index 11deb39677..0000000000 --- a/src/resolve/test-data/teamits.com.pkts +++ /dev/null diff --git a/src/resolve/test-data/zbyszek@fedoraproject.org.pkts b/src/resolve/test-data/zbyszek@fedoraproject.org.pkts Binary files differdeleted file mode 100644 index f0a6f982df..0000000000 --- a/src/resolve/test-data/zbyszek@fedoraproject.org.pkts +++ /dev/null diff --git a/src/resolve/test-dns-packet.c b/src/resolve/test-dns-packet.c index 956b155872..3ca7e78495 100644 --- a/src/resolve/test-dns-packet.c +++ b/src/resolve/test-dns-packet.c @@ -31,6 +31,8 @@ #include "strv.h" #include "unaligned.h" +#include "test-helper.h" + #define HASH_KEY SD_ID128_MAKE(d3,1e,48,90,4b,fa,4c,fe,af,9d,d5,a1,d7,2e,8a,b1) static void verify_rr_copy(DnsResourceRecord *rr) { @@ -115,7 +117,7 @@ int main(int argc, char **argv) { N = argc - 1; fnames = argv + 1; } else { - assert_se(glob(RESOLVE_TEST_DIR "/*.pkts", GLOB_NOSORT, NULL, &g) == 0); + assert_se(glob(TEST_DATA_DIR("/test-resolve/*.pkts"), GLOB_NOSORT, NULL, &g) == 0); N = g.gl_pathc; fnames = g.gl_pathv; } diff --git a/src/shared/seccomp-util.c b/src/shared/seccomp-util.c index 84964f750f..2631856563 100644 --- a/src/shared/seccomp-util.c +++ b/src/shared/seccomp-util.c @@ -802,6 +802,8 @@ int seccomp_restrict_namespaces(unsigned long retain) { case SCMP_ARCH_X86_64: case SCMP_ARCH_X86: case SCMP_ARCH_X32: + case SCMP_ARCH_PPC64: + case SCMP_ARCH_PPC64LE: clone_reversed_order = 0; break; @@ -813,8 +815,8 @@ int seccomp_restrict_namespaces(unsigned long retain) { /* Please add more definitions here, if you port systemd to other architectures! */ -#if !defined(__i386__) && !defined(__x86_64__) && !defined(__s390__) && !defined(__s390x__) -#warning "Consider adding the right clone() syscall definitions here!" +#if SECCOMP_RESTRICT_NAMESPACES_BROKEN +# warning "Consider adding the right clone() syscall definitions here!" #endif } diff --git a/src/shared/seccomp-util.h b/src/shared/seccomp-util.h index 61f94de638..b56ac3f763 100644 --- a/src/shared/seccomp-util.h +++ b/src/shared/seccomp-util.h @@ -92,7 +92,7 @@ int seccomp_memory_deny_write_execute(void); #endif /* we don't know the right order of the clone() parameters except for these archs, for now */ -#if defined(__x86_64__) || defined(__i386__) || defined(__s390x__) || defined(__s390__) +#if defined(__x86_64__) || defined(__i386__) || defined(__s390x__) || defined(__s390__) || defined(__powerpc64__) #define SECCOMP_RESTRICT_NAMESPACES_BROKEN 0 #else #define SECCOMP_RESTRICT_NAMESPACES_BROKEN 1 diff --git a/src/shared/tests.c b/src/shared/tests.c index 409116290d..7034687725 100644 --- a/src/shared/tests.c +++ b/src/shared/tests.c @@ -17,6 +17,9 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ +#include <alloc-util.h> +#include <fs-util.h> +#include <libgen.h> #include <stdlib.h> #include <util.h> @@ -31,3 +34,13 @@ char* setup_fake_runtime_dir(void) { return p; } + +const char* get_exe_relative_testdata_dir(void) { + _cleanup_free_ char *exedir = NULL; + /* convenience: caller does not need to free result */ + static char testdir[PATH_MAX]; + + assert_se(readlink_and_make_absolute("/proc/self/exe", &exedir) >= 0); + assert_se(snprintf(testdir, sizeof(testdir), "%s/testdata", dirname(exedir)) > 0); + return testdir; +} diff --git a/src/shared/tests.h b/src/shared/tests.h index 93f09013a1..0100b48937 100644 --- a/src/shared/tests.h +++ b/src/shared/tests.h @@ -20,3 +20,4 @@ ***/ char* setup_fake_runtime_dir(void); +const char* get_exe_relative_testdata_dir(void); diff --git a/src/test/test-cgroup-mask.c b/src/test/test-cgroup-mask.c index a027eb0fd2..630587aaf1 100644 --- a/src/test/test-cgroup-mask.c +++ b/src/test/test-cgroup-mask.c @@ -34,7 +34,7 @@ static int test_cgroup_mask(void) { int r; /* Prepare the manager. */ - assert_se(set_unit_path(TEST_DIR) >= 0); + assert_se(set_unit_path(TEST_DATA_DIR("")) >= 0); r = manager_new(UNIT_FILE_USER, true, &m); if (r == -EPERM || r == -EACCES) { puts("manager_new: Permission denied. Skipping test."); diff --git a/src/test/test-engine.c b/src/test/test-engine.c index a651f6b683..3ec2dfe10e 100644 --- a/src/test/test-engine.c +++ b/src/test/test-engine.c @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) { assert_se(runtime_dir = setup_fake_runtime_dir()); /* prepare the test */ - assert_se(set_unit_path(TEST_DIR) >= 0); + assert_se(set_unit_path(TEST_DATA_DIR("")) >= 0); r = manager_new(UNIT_FILE_USER, true, &m); if (MANAGER_SKIP_TEST(r)) { log_notice_errno(r, "Skipping test: manager_new: %m"); diff --git a/src/test/test-execute.c b/src/test/test-execute.c index 3a3ab3eb94..145aa37a66 100644 --- a/src/test/test-execute.c +++ b/src/test/test-execute.c @@ -516,7 +516,7 @@ int main(int argc, char *argv[]) { } assert_se(setenv("XDG_RUNTIME_DIR", "/tmp/", 1) == 0); - assert_se(set_unit_path(TEST_DIR "/test-execute/") >= 0); + assert_se(set_unit_path(TEST_DATA_DIR("/test-execute/")) >= 0); /* Unset VAR1, VAR2 and VAR3 which are used in the PassEnvironment test * cases, otherwise (and if they are present in the environment), diff --git a/src/test/test-helper.h b/src/test/test-helper.h index ddb10f88fd..4e633ae6d8 100644 --- a/src/test/test-helper.h +++ b/src/test/test-helper.h @@ -20,6 +20,8 @@ ***/ #include "sd-daemon.h" +#include "string-util.h" +#include "tests.h" #include "macro.h" @@ -39,3 +41,6 @@ -ENOENT, \ -ENOMEDIUM /* cannot determine cgroup */ \ ) + +#define TEST_DATA_DIR(subdir) \ + strjoina(getenv("TEST_DIR") ?: get_exe_relative_testdata_dir(), subdir) diff --git a/src/test/test-path.c b/src/test/test-path.c index 5e99d478ee..d09df3e8a5 100644 --- a/src/test/test-path.c +++ b/src/test/test-path.c @@ -263,7 +263,7 @@ int main(int argc, char *argv[]) { log_open(); assert_se(runtime_dir = setup_fake_runtime_dir()); - assert_se(set_unit_path(TEST_DIR "/test-path/") >= 0); + assert_se(set_unit_path(TEST_DATA_DIR("/test-path/")) >= 0); for (test = tests; test && *test; test++) { int r; diff --git a/src/test/test-sched-prio.c b/src/test/test-sched-prio.c index 7b37910c33..dab64fea57 100644 --- a/src/test/test-sched-prio.c +++ b/src/test/test-sched-prio.c @@ -37,7 +37,7 @@ int main(int argc, char *argv[]) { assert_se(runtime_dir = setup_fake_runtime_dir()); /* prepare the test */ - assert_se(set_unit_path(TEST_DIR) >= 0); + assert_se(set_unit_path(TEST_DATA_DIR("")) >= 0); r = manager_new(UNIT_FILE_USER, true, &m); if (MANAGER_SKIP_TEST(r)) { log_notice_errno(r, "Skipping test: manager_new: %m"); |