#! /bin/sh # Copyright (C) 2010 Colin Watson. # # This file is part of binfmt-support. # # binfmt-support is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3 of the License, or (at your # option) any later version. # # binfmt-support is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with binfmt-support; if not, write to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Test update-binfmts --enable and --disable. : "${srcdir=.}" # shellcheck source-path=SCRIPTDIR . "$srcdir/testlib.sh" init fake_proc update_binfmts_proc --install test-magic /bin/sh --magic ABCD report 'magic: install' "$?" cat >"$tmpdir/1-admin.exp" <<'EOF' : magic 0 ABCD /bin/sh EOF expect_files_equal 'magic: admindir entry OK' \ "$tmpdir/var/lib/binfmts/test-magic" "$tmpdir/1-admin.exp" cat >"$tmpdir/1-proc.exp" <<'EOF' enabled interpreter /bin/sh flags: offset 0 magic 41424344 EOF expect_files_equal 'magic: procdir entry OK' \ "$tmpdir/proc/test-magic" "$tmpdir/1-proc.exp" update_binfmts_proc --install test-extension /bin/sh --extension ext report 'extension: install' "$?" cat >"$tmpdir/2-admin.exp" <<'EOF' : extension 0 ext /bin/sh EOF expect_files_equal 'extension: admindir entry OK' \ "$tmpdir/var/lib/binfmts/test-extension" "$tmpdir/2-admin.exp" cat >"$tmpdir/2-proc.exp" <<'EOF' enabled interpreter /bin/sh flags: extension .ext EOF expect_files_equal 'extension: procdir entry OK' \ "$tmpdir/proc/test-extension" "$tmpdir/2-proc.exp" update_binfmts_proc --disable test-magic report 'magic: disable' "$?" ! test -e "$tmpdir/proc/test-magic" report 'magic: procdir entry gone' "$?" expect_files_equal 'extension: still enabled' \ "$tmpdir/proc/test-extension" "$tmpdir/2-proc.exp" update_binfmts_proc --disable test-extension report 'extension: disable' "$?" ! test -e "$tmpdir/proc/test-extension" report 'extension: procdir entry gone' "$?" update_binfmts_proc --enable test-extension report 'extension: enable' "$?" expect_files_equal 'extension: procdir entry OK' \ "$tmpdir/proc/test-extension" "$tmpdir/2-proc.exp" ! test -e "$tmpdir/proc/test-magic" report 'magic: still disabled' "$?" update_binfmts_proc --enable report 'enable all' "$?" expect_files_equal 'magic: procdir entry OK' \ "$tmpdir/proc/test-magic" "$tmpdir/1-proc.exp" expect_files_equal 'extension: procdir entry OK' \ "$tmpdir/proc/test-extension" "$tmpdir/2-proc.exp" update_binfmts_proc --disable report 'disable all' "$?" ! test -e "$tmpdir/proc/test-magic" report 'magic: procdir entry gone' "$?" ! test -e "$tmpdir/proc/test-extension" report 'extension: procdir entry gone' "$?" ! test -e "$tmpdir/proc/register" report 'procdir unmounted' "$?" finish