UPDATE-BINFMTS(8) | System Manager's Manual | UPDATE-BINFMTS(8) |
update-binfmts
—
maintain registry of executable binary formats
update-binfmts |
[options] --install
name path spec
|
update-binfmts |
[options] --remove
name path
|
update-binfmts |
[options] --import
[name]
|
update-binfmts |
[options] --unimport
[name]
|
update-binfmts |
[options] --display
[name]
|
update-binfmts |
[options] --enable
[name]
|
update-binfmts |
[options] --disable
[name]
|
update-binfmts |
[options] --find
[path] |
Versions 2.1.43 and later of the Linux kernel have contained the
binfmt_misc module. This enables a system administrator to register
interpreters for various binary formats based on a magic number or their
file extension, and cause the appropriate interpreter to be invoked whenever
a matching file is executed. Think of it as a more flexible version of the
#! executable interpreter mechanism, or as something which can behave a
little like "associations" in certain other operating systems
(though in GNU/Linux the tendency is to keep this sort of thing somewhere
else, like your file manager). update-binfmts
manages a persistent database of these interpreters.
When each package providing a registered interpreter is installed,
changed, or removed, update-binfmts
is called to
update information about that interpreter.
update-binfmts
is usually called from the
postinst or prerm scripts in
Debian packages.
Exactly one action must be specified; this may be accompanied by any one of the common options.
--package
package-nameWhen installing new formats, the
--import
action should be used instead.
Similarly, when removing old formats, the
--unimport
action should be used instead.
--admindir
directory--importdir
directory--test
--help
--version
--install
name path spec--install
will attempt to enable this
binary format in the kernel as well as adding it to its own database;
see --enable
below.
You cannot install a format with any of the names ".", "..", "register", or "status", as these are used by the filesystem or the binfmt_misc module.
--remove
name path--disable
below.--import
[name]For packages, this is preferable to using the
--install
option, as a format file can be
installed without update-binfmts
needing to be
available.
--unimport
[name]For packages, this is preferable to using the
--remove
option, for symmetry with
--import
.
--display
[name]--enable
[name]--disable
[name]--find
[path]Note that if multiple formats match an executable, then the
order is in general not defined, and may not be preserved between
update-binfmts
operations, so you should
generally try to ensure that this option prints at most one line for any
given path. The exception to this is that any
format with a userspace detector will be run before any format without a
userspace detector.
--magic
byte-sequenceAlso see --offset
and
--mask
.
--offset
offset--magic
.--mask
byte-sequence--magic
. The default
is all 0xff, i.e. no effect. Only valid with
--magic
.--extension
extension--detector
path--fix-binary
yes
.--credentials
yes
, --credentials
no
--preserve
yes
, --preserve
no
argv[0]
when
running the interpreter, rather than overwriting it with the full path to
the binary.--fix-binary
yes
, --fix-binary
no
no
, meaning that the kernel should
open the interpreter binary lazily when needed. This option requires Linux
4.8 or newer. It cannot be used together with
--detector
, or with multiple binary formats that
share the same magic number, since the kernel will only open a single
interpreter binary which will then not be able to detect and execute the
real interpreter from inside a chroot or from a different mount
namespace.A format file is a sequence of options, one per line,
corresponding roughly to the options given to an
--install
command. Each option consists of a key,
followed by whitespace, followed by a value.
The package option should be set to the current package. The interpreter option should be set to the path to the interpreter that will handle this binary format. The magic, offset, mask, extension, detector, credentials, preserve, and fix-binary options correspond to the command-line options of the same names.
This format file can be used with an interpreter capable of handling Java .class files:
package javawrapper interpreter /usr/bin/javawrapper magic \xca\xfe\xba\xbe
This corresponds roughly to the following command:
update-binfmts --package javawrapper \ --install javawrapper /usr/bin/javawrapper \ --magic '\xca\xfe\xba\xbe'
If you're not careful, you can break your system with
update-binfmts
. An easy way to do this is to
register an ELF binary as a handler for ELF, which will almost certainly
cause your system to hang immediately; even if it doesn't, you won't be able
to run update-binfmts
to fix it. In the future
update-binfmts
may have some checks to prevent this
sort of thing happening accidentally, though of course you can still
manipulate the binfmt_misc kernel module directly.
update-binfmts
is copyright (C) 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
Colin Watson ⟨cjwatson@debian.org⟩.
See the GNU General Public License version 3 or later for copying
conditions.
You can find the GNU GPL v3 in /usr/share/common-licenses/GPL-3 on any modern Debian system.
Richard Guenther wrote the binfmt_misc kernel module.
Ian Jackson wrote update-alternatives
and
dpkg-divert
, from which this program borrows
heavily.
January 24, 2011 | Debian |