[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 5/6] Debian: preferred arch: Apply setarch to sshd



Many build systems (including Xen's, and autoconf) use uname to try to
discern the system's architecture.  When running i386 userland on an
amd64 kernel, this gives the wrong answer.  These build systems then
go off and try to do a sort of cross compile thing, and, generally,
fall over.

The uname -m value (which is what is at issue) is an inherited process
property.  Linux provides a utility `setarch' which changes this.  We
need to apply this to all builds; and it is not really convenient to
add an adverbial command to every build via the existing ssh build
shell rune mechanisms.

A fairly simple way to get the right behaviour is to wrap sshd
instead.  sshd doesn't mind what `personality' it sees.  Replacing
/usr/bin/sshd with a wrapper shell script might break
start-stop-daemon's attempts to shut down or restart sshd but we don't
care about that in osstest (certainly not on build installs, where
this feature is to be used).

Nothing uses this yet.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 Osstest/Debian.pm | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm
index addaaad2..8abd6aed 100644
--- a/Osstest/Debian.pm
+++ b/Osstest/Debian.pm
@@ -1337,6 +1337,7 @@ END
     my $kern_arch_info = $xopts{LinuxKernPreferredArchInfo};
     # LinuxKernPreferredArchInfo contains
     #    Kernel_Debian     the Debian arch for the kernel we would prefer
+    #    Userland_setarch  personality to restore using setarch
     my $kern_arch = $kern_arch_info->{Kernel_Debian};
     if ($kern_arch &&
        $ho->{Flags}{"arch-$r{arch}"} && !$ho->{Flags}{"arch-$kern_arch"}) {
@@ -1354,10 +1355,16 @@ END
        $kern_arch = undef;
     }
     if ($kern_arch) {
-       logm("Using $kern_arch kernel for $r{arch} userland");
+       my $setarch = "setarch $kern_arch_info->{Userland_setarch}";
+       logm("Using $kern_arch kernel for $r{arch} userland ($setarch)");
        preseed_hook_command($ho, 'late_command', $sfx, <<END);
 #!/bin/sh
 set -ex
+cat <<'ENDW' >/target/usr/sbin/sshd.osstest-wrap
+#!/bin/sh
+exec $setarch /usr/sbin/sshd.distrib "\$@"
+ENDW
+chmod a+x /target/usr/sbin/sshd.osstest-wrap
 in-target sh -xec '
     # the $r{arch} kernels end up being the default so shuffle them
     # where update-grub will not find them
@@ -1368,6 +1375,8 @@ in-target sh -xec '
     apt-get update
     apt-get install -f -y linux-image-$kern_arch
     update-grub
+    dpkg-divert --rename /usr/sbin/sshd
+    ln -s sshd.osstest-wrap /usr/sbin/sshd
 '
 END
     }
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.