]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #15538 from poettering/nspawn-no-netns
authorLennart Poettering <lennart@poettering.net>
Thu, 23 Apr 2020 09:11:11 +0000 (11:11 +0200)
committerGitHub <noreply@github.com>
Thu, 23 Apr 2020 09:11:11 +0000 (11:11 +0200)
nspawn: politely refuse --image= when run inside non-host netns

.mkosi/mkosi.fedora
.mkosi/mkosi.opensuse [new file with mode: 0644]
mkosi.build
src/run/run.c
test/test-execute/exec-specifier.service
test/test-execute/exec-specifier@.service

index 01bfd2338bbcfb5ad1350786dd6df881bbe5b588..9769b0544741410bc6f21639d0a595fdd767d050 100644 (file)
@@ -31,7 +31,6 @@ BuildPackages=
         gnu-efi-devel
         gnutls-devel
         gperf
-        hostname
         iptables-devel
         kmod-devel
         libacl-devel
diff --git a/.mkosi/mkosi.opensuse b/.mkosi/mkosi.opensuse
new file mode 100644 (file)
index 0000000..1faf9cc
--- /dev/null
@@ -0,0 +1,60 @@
+# SPDX-License-Identifier: LGPL-2.1+
+
+# This is a settings file for OS image generation using mkosi (https://github.com/systemd/mkosi).
+# Simply invoke "mkosi" in the project directory to build an OS image.
+
+[Distribution]
+Distribution=opensuse
+Release=tumbleweed
+
+[Output]
+Format=raw_btrfs
+Bootable=yes
+
+[Partitions]
+RootSize=3G
+
+[Packages]
+# Uncomment to share system RPM cache (works only with Tumbleweed)
+#Cache=/var/cache/zypp/packages
+BuildDirectory=mkosi.builddir
+BuildPackages=
+        docbook-xsl-stylesheets
+        fdupes
+        gcc
+        gnu-efi
+        gperf
+        intltool
+        libacl-devel
+        libapparmor-devel
+        libblkid-devel
+        libbz2-devel
+        libcap-devel
+        libcryptsetup-devel
+        libcurl-devel
+        libgcrypt-devel
+        libkmod-devel
+        liblz4-devel
+        libmicrohttpd-devel
+        libmount-devel
+        libseccomp-devel
+        libselinux-devel
+        libxslt-tools
+        m4
+        meson
+        pam-devel
+        pciutils-devel
+        pcre-devel
+        python3
+        python3-lxml
+        qrencode-devel
+        zlib-devel
+# to satisfy tests
+        acl
+        glibc-locale
+        system-group-obsolete
+        timezone
+
+Packages=
+        # brought in via meson->python3
+        libp11-kit0
index 16ac2e9d0d6952949b1be240962d94167666df77..4a13f1075eb47987528b85997653dc7151a0e5b5 100755 (executable)
@@ -42,6 +42,14 @@ fi
 if [ ! -f "$BUILDDIR"/build.ninja ] ; then
         sysvinit_path=`realpath /etc/init.d`
 
+        init_path=`realpath /sbin/init 2>/dev/null`
+        if [ -z "$init_path" ] ; then
+            rootprefix=""
+        else
+            rootprefix=${init_path%/lib/systemd/systemd}
+            rootprefix=/${rootprefix#/}
+        fi
+
         nobody_user=`id -u -n 65534 2> /dev/null`
         if [ "$nobody_user" != "" ] ; then
                 # Validate that we can translate forth and back
@@ -76,11 +84,17 @@ if [ ! -f "$BUILDDIR"/build.ninja ] ; then
                 fi
         fi
 
-        meson "$BUILDDIR" -D "sysvinit-path=$sysvinit_path" -D default-hierarchy=unified -D man=false -D "nobody-user=$nobody_user" -D "nobody-group=$nobody_group"
+        meson "$BUILDDIR" -D "sysvinit-path=$sysvinit_path" -D "rootprefix=$rootprefix" -D default-hierarchy=unified -D man=false -D "nobody-user=$nobody_user" -D "nobody-group=$nobody_group"
 fi
 
 ninja -C "$BUILDDIR" all
-[ "$WITH_TESTS" = 0 ] || ninja -C "$BUILDDIR" test
+if [ "$WITH_TESTS" = 1 ] ; then
+        for id in 1 2 3; do
+                groupadd -g $id testgroup$id || :
+        done
+
+        ninja -C "$BUILDDIR" test
+fi
 ninja -C "$BUILDDIR" install
 
 mkdir -p "$DESTDIR"/etc
index 6076eabe92e2db614ae525b539876e3da6d6b3f9..ea49d5dab558720ac07438ba3ec14b56f8ee5f29 100644 (file)
@@ -1144,7 +1144,11 @@ static int start_transient_service(
                         assert_not_reached("Can't allocate tty via ssh");
         }
 
-        if (!arg_no_block) {
+        /* Optionally, wait for the start job to complete. If we are supposed to read the service's stdin
+         * lets skip this however, because we should start that already when the start job is running, and
+         * there's little point in waiting for the start job to complete in that case anyway, as we'll wait
+         * for EOF anyway, which is going to be much later. */
+        if (!arg_no_block && arg_stdio == ARG_STDIO_NONE) {
                 r = bus_wait_for_jobs_new(bus, &w);
                 if (r < 0)
                         return log_error_errno(r, "Could not watch jobs: %m");
index 7c3f81f2b53fec4bc2294c86708e98c10846260f..a58abc68dd6057e355eb25f63b3648194de7c781 100644 (file)
@@ -27,5 +27,5 @@ ExecStart=test %h = /root
 ExecStart=sh -c 'test %s = /bin/sh'
 ExecStart=sh -c 'test %m = $$(cat /etc/machine-id)'
 ExecStart=sh -c 'test %b = $$(cat /proc/sys/kernel/random/boot_id | sed -e 's/-//g')'
-ExecStart=sh -c 'test %H = $$(hostname)'
+ExecStart=sh -c 'test %H = $$(uname -n)'
 ExecStart=sh -c 'test %v = $$(uname -r)'
index a388926846a18b8a4cc5f1209d02757c5066ab93..faecbf37bc5965a89caabe47fce13acfb634ec0a 100644 (file)
@@ -25,5 +25,5 @@ ExecStart=test %h = /root
 ExecStart=sh -c 'test %s = /bin/sh'
 ExecStart=sh -c 'test %m = $$(cat /etc/machine-id)'
 ExecStart=sh -c 'test %b = $$(cat /proc/sys/kernel/random/boot_id | sed -e 's/-//g')'
-ExecStart=sh -c 'test %H = $$(hostname)'
+ExecStart=sh -c 'test %H = $$(uname -n)'
 ExecStart=sh -c 'test %v = $$(uname -r)'