Subject: Debian does not execute ksh93 compiled shell binaries Package: ksh Version: 93u+20120628-1
Debian does not execute ksh93 compiled shell binaries. On Solaris I can do this: echo "print hello_world" >plain.sh shcomp plain.sh compiled_script.sh ./compiled_script.sh hello_world On Debian this does not work because the kernel does not support the executable format used by ksh93's shcomp. It turns out there is a one-line solution for this (taken from [http://www.mail-archive.com/ast-users@research.att.com/msg01730.html]): Just execute this single line at system startup and shcomp compiled executables work: -- snip -- echo ':shbinexec:M::\x0b\x13\x08:\xff\xff\xff:/usr/bin/ksh93:O' > /proc/sys/fs/binfmt_misc/register -- snip -- More information can be found at http://www.mail-archive.com/ast-users@research.att.com/msg01730.html I forwarded that email at the end of this mail: ---------- Forwarded message ---------- From: Roland Mainz <roland.ma...@nrubsig.org> Date: 1 May 2012 19:50 Subject: Re: [ast-users] Binaries not working on Suse Linux but works on Solaris? To: ast-us...@research.att.com Cc: Dan Shelton <dan.f.shel...@googlemail.com>, ольга крыжановская <olga.kryzhanov...@gmail.com> On Mon, Apr 30, 2012 at 11:20 PM, ольга крыжановская <olga.kryzhanov...@gmail.com> wrote: > On Wed, Apr 25, 2012 at 12:26 PM, Dan Shelton > <dan.f.shel...@googlemail.com> wrote: >> Hello, I have problems with Suse and compiled shell scripts. If I try >> to execute a shell script compiled with shcomp on Solaris Express it >> works like a charm but on Suse the system refuses to execute the >> binary: >> lorddan@test:~> cat x.sh >> print "hello world" >> print --version >> lorddan@test:~> shcomp x.sh x >> lorddan@test:~> >> -bash: ./x: cannot execute binary file >> >> Does anyone have a tip why this fails? > Dan, have a look at > https://wiki.archlinux.org/index.php/Binfmt_misc_for_Java IMO the same > could be used to recognise compiled shell code and use /usr/bin/ksh as > interpreter. > We only have to figure out how to use binfmt. On Linux you can do this: -- snip -- echo ':shbinexec:M::\x0b\x13\x08:\xff\xff\xff:/usr/bin/ksh93:O' > /proc/sys/fs/binfmt_misc/register -- snip -- After this point all compiled shell scripts (even those with only the exec bit but not the read bit set) can be executed directly. For example: -- snip -- # as user "root": # echo ':shbinexec:M::\x0b\x13\x08:\xff\xff\xff:/usr/bin/ksh93:O' > /proc/sys/fs/binfmt_misc/register # as plain user: $ printf 'printf "argv=%%d\\n" $#\nprintf "argv=%%q\\n" "$@"\n' | shcomp /dev/stdin args.shbin $ args.shbin "hello world" "foo bar" argv=2 argv='hello world' argv='foo bar' -- snip -- AFAIK the only "missing step" is to teach systemd to do this at system startup... ---- Bye, Roland -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org