|Summary:||emulators/qemu-user-static: Can't run shell scripts with chroot|
|Product:||Ports & Packages||Reporter:||dornergd <gerhard.dorner>|
|Component:||Individual Port(s)||Assignee:||freebsd-emulation (Nobody) <emulation>|
|Severity:||Affects Some People||CC:||emulation, mikael|
Description dornergd 2018-08-16 14:50:25 UTC
When I want to use qemu-user-static for aarch64 in combination with chroot there are a problem to run shell-scripts. For Example: # adduser /bin/sh: adduser: not found But, when i remove the first line in /usr/sbin/adduser (#!/bin/sh) the script runs perfectly. But i think, this is not the solution for this problem. I also write a test-script and this have the same behavior. The problem happens in Version 2.11.50.g20180622 on FreeBSD 11.2-RELEASE and on FreeBSD 12.0-CURRENT (r336134). On Freebsd 11.2-RELEASE with qemu-user-static version 2.6.90.g20160728_1 there are not this problem.
Comment 1 Mikael Urankar 2018-08-17 10:19:11 UTC
I have the same setup here and everything works as expected (on 12-current) How do you set up your chroot?
Comment 2 dornergd 2018-08-17 10:30:51 UTC
(In reply to mikael.urankar from comment #1) First I copied /usr/local/bin/qemu-aarch64-static to /tmp/qemu_static in the chroot-environment (world_dir) After this is run: chroot world_dir /tmp/qemu_static /bin/sh --- But I found a function "is_target_shell_script" in bsd-user/freebsd/os-proc.c, which only used in FreeBSD-versions smaller than 11: #if defined(__FreeBSD_version) && __FreeBSD_version < 1100000 After made a simple patch which deletes this lines around the function-declaration and function-calls the shell-scripts works correctly.
Comment 3 Mikael Urankar 2018-08-17 10:55:05 UTC
(In reply to dornergd from comment #2) I don't know why is_target_shell_script is needed on __FreeBSD_version < 1100000 Usually I do the following: cp /usr/local/bin/qemu-aarch64-static /data/jails/12aarch64/usr/local/bin service qemu_user_static start chroot /data/jails/12aarch64
Comment 4 Mark Linimon 2021-05-12 20:11:36 UTC
^Triage: assign to current maintainer.