sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget+/translations/zh_CN/admin-guide/binfmt-miscmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget+/translations/zh_TW/admin-guide/binfmt-miscmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget+/translations/it_IT/admin-guide/binfmt-miscmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget+/translations/ja_JP/admin-guide/binfmt-miscmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget+/translations/ko_KR/admin-guide/binfmt-miscmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget+/translations/sp_SP/admin-guide/binfmt-miscmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(h=Kernel Support for miscellaneous Binary Formats (binfmt_misc)h]h=Kernel Support for miscellaneous Binary Formats (binfmt_misc)}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhE/var/lib/git/docbuild/linux/Documentation/admin-guide/binfmt-misc.rsthKubh paragraph)}(hThis Kernel feature allows you to invoke almost (for restrictions see below) every program by simply typing its name in the shell. This includes for example compiled Java(TM), Python or Emacs programs.h]hThis Kernel feature allows you to invoke almost (for restrictions see below) every program by simply typing its name in the shell. This includes for example compiled Java(TM), Python or Emacs programs.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hXTTo achieve this you must tell binfmt_misc which interpreter has to be invoked with which binary. Binfmt_misc recognises the binary-type by matching some bytes at the beginning of the file with a magic byte sequence (masking out specified bits) you have supplied. Binfmt_misc can also recognise a filename extension aka ``.com`` or ``.exe``.h](hX?To achieve this you must tell binfmt_misc which interpreter has to be invoked with which binary. Binfmt_misc recognises the binary-type by matching some bytes at the beginning of the file with a magic byte sequence (masking out specified bits) you have supplied. Binfmt_misc can also recognise a filename extension aka }(hhhhhNhNubhliteral)}(h``.com``h]h.com}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhubh or }(hhhhhNhNubh)}(h``.exe``h]h.exe}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhubh.}(hhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(h"First you must mount binfmt_misc::h]h!First you must mount binfmt_misc:}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh literal_block)}(h9mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misch]h9mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc}hj sbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1j hhhKhhhhubh)}(hTo actually register a new binary type, you have to set up a string looking like ``:name:type:offset:magic:mask:interpreter:flags`` (where you can choose the ``:`` upon your needs) and echo it to ``/proc/sys/fs/binfmt_misc/register``.h](hQTo actually register a new binary type, you have to set up a string looking like }(hjhhhNhNubh)}(h2``:name:type:offset:magic:mask:interpreter:flags``h]h.:name:type:offset:magic:mask:interpreter:flags}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh (where you can choose the }(hjhhhNhNubh)}(h``:``h]h:}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh! upon your needs) and echo it to }(hjhhhNhNubh)}(h%``/proc/sys/fs/binfmt_misc/register``h]h!/proc/sys/fs/binfmt_misc/register}(hjGhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hHere is what the fields mean:h]hHere is what the fields mean:}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh bullet_list)}(hhh](h list_item)}(h``name`` is an identifier string. A new /proc file will be created with this name below ``/proc/sys/fs/binfmt_misc``; cannot contain slashes ``/`` for obvious reasons.h]hdefinition_list)}(hhh]hdefinition_list_item)}(h``name`` is an identifier string. A new /proc file will be created with this name below ``/proc/sys/fs/binfmt_misc``; cannot contain slashes ``/`` for obvious reasons.h](hterm)}(h``name``h]h)}(hjh]hname}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1jhhhKhjubh definition)}(hhh]h)}(his an identifier string. A new /proc file will be created with this name below ``/proc/sys/fs/binfmt_misc``; cannot contain slashes ``/`` for obvious reasons.h](hOis an identifier string. A new /proc file will be created with this name below }(hjhhhNhNubh)}(h``/proc/sys/fs/binfmt_misc``h]h/proc/sys/fs/binfmt_misc}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh; cannot contain slashes }(hjhhhNhNubh)}(h``/``h]h/}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh for obvious reasons.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j}hhhKhjzubah}(h]h ]h"]h$]h&]uh1jxhjtubah}(h]h ]h"]h$]h&]uh1jrhjohhhNhNubjs)}(hS``type`` is the type of recognition. Give ``M`` for magic and ``E`` for extension.h]jy)}(hhh]j~)}(hR``type`` is the type of recognition. Give ``M`` for magic and ``E`` for extension.h](j)}(h``type``h]h)}(hjh]htype}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1jhhhKhjubj)}(hhh]h)}(hIis the type of recognition. Give ``M`` for magic and ``E`` for extension.h](h!is the type of recognition. Give }(hjhhhNhNubh)}(h``M``h]hM}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh for magic and }(hjhhhNhNubh)}(h``E``h]hE}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh for extension.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j}hhhKhjubah}(h]h ]h"]h$]h&]uh1jxhjubah}(h]h ]h"]h$]h&]uh1jrhjohhhNhNubjs)}(h``offset`` is the offset of the magic/mask in the file, counted in bytes. This defaults to 0 if you omit it (i.e. you write ``:name:type::magic...``). Ignored when using filename extension matching.h]jy)}(hhh]j~)}(h``offset`` is the offset of the magic/mask in the file, counted in bytes. This defaults to 0 if you omit it (i.e. you write ``:name:type::magic...``). Ignored when using filename extension matching.h](j)}(h ``offset``h]h)}(hjgh]hoffset}(hjihhhNhNubah}(h]h ]h"]h$]h&]uh1hhjeubah}(h]h ]h"]h$]h&]uh1jhhhK hjaubj)}(hhh]h)}(his the offset of the magic/mask in the file, counted in bytes. This defaults to 0 if you omit it (i.e. you write ``:name:type::magic...``). Ignored when using filename extension matching.h](hqis the offset of the magic/mask in the file, counted in bytes. This defaults to 0 if you omit it (i.e. you write }(hjhhhNhNubh)}(h``:name:type::magic...``h]h:name:type::magic...}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh2). Ignored when using filename extension matching.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj|ubah}(h]h ]h"]h$]h&]uh1jhjaubeh}(h]h ]h"]h$]h&]uh1j}hhhK hj^ubah}(h]h ]h"]h$]h&]uh1jxhjZubah}(h]h ]h"]h$]h&]uh1jrhjohhhNhNubjs)}(hX``magic`` is the byte sequence binfmt_misc is matching for. The magic string may contain hex-encoded characters like ``\x0a`` or ``\xA4``. Note that you must escape any NUL bytes; parsing halts at the first one. In a shell environment you might have to write ``\\x0a`` to prevent the shell from eating your ``\``. If you chose filename extension matching, this is the extension to be recognised (without the ``.``, the ``\x0a`` specials are not allowed). Extension matching is case sensitive, and slashes ``/`` are not allowed!h]jy)}(hhh]j~)}(hX``magic`` is the byte sequence binfmt_misc is matching for. The magic string may contain hex-encoded characters like ``\x0a`` or ``\xA4``. Note that you must escape any NUL bytes; parsing halts at the first one. In a shell environment you might have to write ``\\x0a`` to prevent the shell from eating your ``\``. If you chose filename extension matching, this is the extension to be recognised (without the ``.``, the ``\x0a`` specials are not allowed). Extension matching is case sensitive, and slashes ``/`` are not allowed!h](j)}(h ``magic``h]h)}(hjh]hmagic}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1jhhhK)hjubj)}(hhh]h)}(hXis the byte sequence binfmt_misc is matching for. The magic string may contain hex-encoded characters like ``\x0a`` or ``\xA4``. Note that you must escape any NUL bytes; parsing halts at the first one. In a shell environment you might have to write ``\\x0a`` to prevent the shell from eating your ``\``. If you chose filename extension matching, this is the extension to be recognised (without the ``.``, the ``\x0a`` specials are not allowed). Extension matching is case sensitive, and slashes ``/`` are not allowed!h](hkis the byte sequence binfmt_misc is matching for. The magic string may contain hex-encoded characters like }(hjhhhNhNubh)}(h``\x0a``h]h\x0a}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh or }(hjhhhNhNubh)}(h``\xA4``h]h\xA4}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubhz. Note that you must escape any NUL bytes; parsing halts at the first one. In a shell environment you might have to write }(hjhhhNhNubh)}(h ``\\x0a``h]h\\x0a}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh' to prevent the shell from eating your }(hjhhhNhNubh)}(h``\``h]h\}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh`. If you chose filename extension matching, this is the extension to be recognised (without the }(hjhhhNhNubh)}(h``.``h]h.}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh, the }(hjhhhNhNubh)}(h``\x0a``h]h\x0a}(hj>hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubhQ specials are not allowed). Extension matching is case sensitive, and slashes }(hjhhhNhNubh)}(h``/``h]h/}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh are not allowed!}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK#hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j}hhhK)hjubah}(h]h ]h"]h$]h&]uh1jxhjubah}(h]h ]h"]h$]h&]uh1jrhjohhhNhNubjs)}(hXI``mask`` is an (optional, defaults to all 0xff) mask. You can mask out some bits from matching by supplying a string like magic and as long as magic. The mask is anded with the byte sequence of the file. Note that you must escape any NUL bytes; parsing halts at the first one. Ignored when using filename extension matching.h]jy)}(hhh]j~)}(hXD``mask`` is an (optional, defaults to all 0xff) mask. You can mask out some bits from matching by supplying a string like magic and as long as magic. The mask is anded with the byte sequence of the file. Note that you must escape any NUL bytes; parsing halts at the first one. Ignored when using filename extension matching.h](j)}(h``mask``h]h)}(hjh]hmask}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1jhhhK/hjubj)}(hhh]h)}(hX;is an (optional, defaults to all 0xff) mask. You can mask out some bits from matching by supplying a string like magic and as long as magic. The mask is anded with the byte sequence of the file. Note that you must escape any NUL bytes; parsing halts at the first one. Ignored when using filename extension matching.h]hX;is an (optional, defaults to all 0xff) mask. You can mask out some bits from matching by supplying a string like magic and as long as magic. The mask is anded with the byte sequence of the file. Note that you must escape any NUL bytes; parsing halts at the first one. Ignored when using filename extension matching.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK,hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j}hhhK/hjubah}(h]h ]h"]h$]h&]uh1jxhjubah}(h]h ]h"]h$]h&]uh1jrhjohhhNhNubjs)}(hq``interpreter`` is the program that should be invoked with the binary as first argument (specify the full path)h]jy)}(hhh]j~)}(ho``interpreter`` is the program that should be invoked with the binary as first argument (specify the full path)h](j)}(h``interpreter``h]h)}(hjh]h interpreter}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1jhhhK2hjubj)}(hhh]h)}(h_is the program that should be invoked with the binary as first argument (specify the full path)h]h_is the program that should be invoked with the binary as first argument (specify the full path)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK2hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j}hhhK2hjubah}(h]h ]h"]h$]h&]uh1jxhjubah}(h]h ]h"]h$]h&]uh1jrhjohhhNhNubjs)}(hXr ``flags`` is an optional field that controls several aspects of the invocation of the interpreter. It is a string of capital letters, each controls a certain aspect. The following flags are supported: ``P`` - preserve-argv[0] Legacy behavior of binfmt_misc is to overwrite the original argv[0] with the full path to the binary. When this flag is included, binfmt_misc will add an argument to the argument vector for this purpose, thus preserving the original ``argv[0]``. e.g. If your interp is set to ``/bin/foo`` and you run ``blah`` (which is in ``/usr/local/bin``), then the kernel will execute ``/bin/foo`` with ``argv[]`` set to ``["/bin/foo", "/usr/local/bin/blah", "blah"]``. The interp has to be aware of this so it can execute ``/usr/local/bin/blah`` with ``argv[]`` set to ``["blah"]``. ``O`` - open-binary Legacy behavior of binfmt_misc is to pass the full path of the binary to the interpreter as an argument. When this flag is included, binfmt_misc will open the file for reading and pass its descriptor as an argument, instead of the full path, thus allowing the interpreter to execute non-readable binaries. This feature should be used with care - the interpreter has to be trusted not to emit the contents of the non-readable binary. ``C`` - credentials Currently, the behavior of binfmt_misc is to calculate the credentials and security token of the new process according to the interpreter. When this flag is included, these attributes are calculated according to the binary. It also implies the ``O`` flag. This feature should be used with care as the interpreter will run with root permissions when a setuid binary owned by root is run with binfmt_misc. ``F`` - fix binary The usual behaviour of binfmt_misc is to spawn the binary lazily when the misc format file is invoked. However, this doesn't work very well in the face of mount namespaces and changeroots, so the ``F`` mode opens the binary as soon as the emulation is installed and uses the opened image to spawn the emulator, meaning it is always available once installed, regardless of how the environment changes. h]jy)}(hhh]j~)}(hXM ``flags`` is an optional field that controls several aspects of the invocation of the interpreter. It is a string of capital letters, each controls a certain aspect. The following flags are supported: ``P`` - preserve-argv[0] Legacy behavior of binfmt_misc is to overwrite the original argv[0] with the full path to the binary. When this flag is included, binfmt_misc will add an argument to the argument vector for this purpose, thus preserving the original ``argv[0]``. e.g. If your interp is set to ``/bin/foo`` and you run ``blah`` (which is in ``/usr/local/bin``), then the kernel will execute ``/bin/foo`` with ``argv[]`` set to ``["/bin/foo", "/usr/local/bin/blah", "blah"]``. The interp has to be aware of this so it can execute ``/usr/local/bin/blah`` with ``argv[]`` set to ``["blah"]``. ``O`` - open-binary Legacy behavior of binfmt_misc is to pass the full path of the binary to the interpreter as an argument. When this flag is included, binfmt_misc will open the file for reading and pass its descriptor as an argument, instead of the full path, thus allowing the interpreter to execute non-readable binaries. This feature should be used with care - the interpreter has to be trusted not to emit the contents of the non-readable binary. ``C`` - credentials Currently, the behavior of binfmt_misc is to calculate the credentials and security token of the new process according to the interpreter. When this flag is included, these attributes are calculated according to the binary. It also implies the ``O`` flag. This feature should be used with care as the interpreter will run with root permissions when a setuid binary owned by root is run with binfmt_misc. ``F`` - fix binary The usual behaviour of binfmt_misc is to spawn the binary lazily when the misc format file is invoked. However, this doesn't work very well in the face of mount namespaces and changeroots, so the ``F`` mode opens the binary as soon as the emulation is installed and uses the opened image to spawn the emulator, meaning it is always available once installed, regardless of how the environment changes. h](j)}(h ``flags``h]h)}(hj#h]hflags}(hj%hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj!ubah}(h]h ]h"]h$]h&]uh1jhhhK[hjubj)}(hhh](h)}(his an optional field that controls several aspects of the invocation of the interpreter. It is a string of capital letters, each controls a certain aspect. The following flags are supported:h]his an optional field that controls several aspects of the invocation of the interpreter. It is a string of capital letters, each controls a certain aspect. The following flags are supported:}(hj;hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK5hj8ubh block_quote)}(hX``P`` - preserve-argv[0] Legacy behavior of binfmt_misc is to overwrite the original argv[0] with the full path to the binary. When this flag is included, binfmt_misc will add an argument to the argument vector for this purpose, thus preserving the original ``argv[0]``. e.g. If your interp is set to ``/bin/foo`` and you run ``blah`` (which is in ``/usr/local/bin``), then the kernel will execute ``/bin/foo`` with ``argv[]`` set to ``["/bin/foo", "/usr/local/bin/blah", "blah"]``. The interp has to be aware of this so it can execute ``/usr/local/bin/blah`` with ``argv[]`` set to ``["blah"]``. ``O`` - open-binary Legacy behavior of binfmt_misc is to pass the full path of the binary to the interpreter as an argument. When this flag is included, binfmt_misc will open the file for reading and pass its descriptor as an argument, instead of the full path, thus allowing the interpreter to execute non-readable binaries. This feature should be used with care - the interpreter has to be trusted not to emit the contents of the non-readable binary. ``C`` - credentials Currently, the behavior of binfmt_misc is to calculate the credentials and security token of the new process according to the interpreter. When this flag is included, these attributes are calculated according to the binary. It also implies the ``O`` flag. This feature should be used with care as the interpreter will run with root permissions when a setuid binary owned by root is run with binfmt_misc. ``F`` - fix binary The usual behaviour of binfmt_misc is to spawn the binary lazily when the misc format file is invoked. However, this doesn't work very well in the face of mount namespaces and changeroots, so the ``F`` mode opens the binary as soon as the emulation is installed and uses the opened image to spawn the emulator, meaning it is always available once installed, regardless of how the environment changes. h]jy)}(hhh](j~)}(hXU``P`` - preserve-argv[0] Legacy behavior of binfmt_misc is to overwrite the original argv[0] with the full path to the binary. When this flag is included, binfmt_misc will add an argument to the argument vector for this purpose, thus preserving the original ``argv[0]``. e.g. If your interp is set to ``/bin/foo`` and you run ``blah`` (which is in ``/usr/local/bin``), then the kernel will execute ``/bin/foo`` with ``argv[]`` set to ``["/bin/foo", "/usr/local/bin/blah", "blah"]``. The interp has to be aware of this so it can execute ``/usr/local/bin/blah`` with ``argv[]`` set to ``["blah"]``.h](j)}(h``P`` - preserve-argv[0]h](h)}(h``P``h]hP}(hjZhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjVubh - preserve-argv[0]}(hjVhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhKAhjRubj)}(hhh]h)}(hX<Legacy behavior of binfmt_misc is to overwrite the original argv[0] with the full path to the binary. When this flag is included, binfmt_misc will add an argument to the argument vector for this purpose, thus preserving the original ``argv[0]``. e.g. If your interp is set to ``/bin/foo`` and you run ``blah`` (which is in ``/usr/local/bin``), then the kernel will execute ``/bin/foo`` with ``argv[]`` set to ``["/bin/foo", "/usr/local/bin/blah", "blah"]``. The interp has to be aware of this so it can execute ``/usr/local/bin/blah`` with ``argv[]`` set to ``["blah"]``.h](hLegacy behavior of binfmt_misc is to overwrite the original argv[0] with the full path to the binary. When this flag is included, binfmt_misc will add an argument to the argument vector for this purpose, thus preserving the original }(hjuhhhNhNubh)}(h ``argv[0]``h]hargv[0]}(hj}hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjuubh . e.g. If your interp is set to }(hjuhhhNhNubh)}(h ``/bin/foo``h]h/bin/foo}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjuubh and you run }(hjuhhhNhNubh)}(h``blah``h]hblah}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjuubh (which is in }(hjuhhhNhNubh)}(h``/usr/local/bin``h]h/usr/local/bin}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjuubh ), then the kernel will execute }(hjuhhhNhNubh)}(h ``/bin/foo``h]h/bin/foo}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjuubh with }(hjuhhhNhNubh)}(h ``argv[]``h]hargv[]}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjuubh set to }(hjuhhhNhNubh)}(h/``["/bin/foo", "/usr/local/bin/blah", "blah"]``h]h+["/bin/foo", "/usr/local/bin/blah", "blah"]}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjuubh8. The interp has to be aware of this so it can execute }(hjuhhhNhNubh)}(h``/usr/local/bin/blah``h]h/usr/local/bin/blah}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjuubh with }(hjuhhhNhNubh)}(h ``argv[]``h]hargv[]}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjuubh set to }hjusbh)}(h ``["blah"]``h]h["blah"]}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjuubh.}(hjuhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK:hjrubah}(h]h ]h"]h$]h&]uh1jhjRubeh}(h]h ]h"]h$]h&]uh1j}hhhKAhjOubj~)}(hX``O`` - open-binary Legacy behavior of binfmt_misc is to pass the full path of the binary to the interpreter as an argument. When this flag is included, binfmt_misc will open the file for reading and pass its descriptor as an argument, instead of the full path, thus allowing the interpreter to execute non-readable binaries. This feature should be used with care - the interpreter has to be trusted not to emit the contents of the non-readable binary.h](j)}(h``O`` - open-binaryh](h)}(h``O``h]hO}(hjKhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjGubh - open-binary}(hjGhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhKIhjCubj)}(hhh]h)}(hXLegacy behavior of binfmt_misc is to pass the full path of the binary to the interpreter as an argument. When this flag is included, binfmt_misc will open the file for reading and pass its descriptor as an argument, instead of the full path, thus allowing the interpreter to execute non-readable binaries. This feature should be used with care - the interpreter has to be trusted not to emit the contents of the non-readable binary.h]hXLegacy behavior of binfmt_misc is to pass the full path of the binary to the interpreter as an argument. When this flag is included, binfmt_misc will open the file for reading and pass its descriptor as an argument, instead of the full path, thus allowing the interpreter to execute non-readable binaries. This feature should be used with care - the interpreter has to be trusted not to emit the contents of the non-readable binary.}(hjfhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKDhjcubah}(h]h ]h"]h$]h&]uh1jhjCubeh}(h]h ]h"]h$]h&]uh1j}hhhKIhjOubj~)}(hX``C`` - credentials Currently, the behavior of binfmt_misc is to calculate the credentials and security token of the new process according to the interpreter. When this flag is included, these attributes are calculated according to the binary. It also implies the ``O`` flag. This feature should be used with care as the interpreter will run with root permissions when a setuid binary owned by root is run with binfmt_misc.h](j)}(h``C`` - credentialsh](h)}(h``C``h]hC}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh - credentials}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhKQhjubj)}(hhh]h)}(hXCurrently, the behavior of binfmt_misc is to calculate the credentials and security token of the new process according to the interpreter. When this flag is included, these attributes are calculated according to the binary. It also implies the ``O`` flag. This feature should be used with care as the interpreter will run with root permissions when a setuid binary owned by root is run with binfmt_misc.h](hCurrently, the behavior of binfmt_misc is to calculate the credentials and security token of the new process according to the interpreter. When this flag is included, these attributes are calculated according to the binary. It also implies the }(hjhhhNhNubh)}(h``O``h]hO}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh flag. This feature should be used with care as the interpreter will run with root permissions when a setuid binary owned by root is run with binfmt_misc.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKLhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j}hhhKQhjOubj~)}(hX``F`` - fix binary The usual behaviour of binfmt_misc is to spawn the binary lazily when the misc format file is invoked. However, this doesn't work very well in the face of mount namespaces and changeroots, so the ``F`` mode opens the binary as soon as the emulation is installed and uses the opened image to spawn the emulator, meaning it is always available once installed, regardless of how the environment changes. h](j)}(h``F`` - fix binaryh](h)}(h``F``h]hF}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh - fix binary}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhK[hjubj)}(hhh]h)}(hXThe usual behaviour of binfmt_misc is to spawn the binary lazily when the misc format file is invoked. However, this doesn't work very well in the face of mount namespaces and changeroots, so the ``F`` mode opens the binary as soon as the emulation is installed and uses the opened image to spawn the emulator, meaning it is always available once installed, regardless of how the environment changes.h](hThe usual behaviour of binfmt_misc is to spawn the binary lazily when the misc format file is invoked. However, this doesn’t work very well in the face of mount namespaces and changeroots, so the }(hjhhhNhNubh)}(h``F``h]hF}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh mode opens the binary as soon as the emulation is installed and uses the opened image to spawn the emulator, meaning it is always available once installed, regardless of how the environment changes.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKThjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j}hhhK[hjOubeh}(h]h ]h"]h$]h&]uh1jxhjKubah}(h]h ]h"]h$]h&]uh1jIhhhK9hj8ubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j}hhhK[hjubah}(h]h ]h"]h$]h&]uh1jxhjubah}(h]h ]h"]h$]h&]uh1jrhjohhhNhNubeh}(h]h ]h"]h$]h&]bullet-uh1jmhhhKhhhhubh)}(hThere are some restrictions:h]hThere are some restrictions:}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK]hhhhubjJ)}(h- the whole register string may not exceed 1920 characters - the magic must reside in the first 128 bytes of the file, i.e. offset+size(magic) has to be less than 128 - the interpreter string may not exceed 127 characters h]jn)}(hhh](js)}(h8the whole register string may not exceed 1920 charactersh]h)}(hjah]h8the whole register string may not exceed 1920 characters}(hjchhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK_hj_ubah}(h]h ]h"]h$]h&]uh1jrhj\ubjs)}(hithe magic must reside in the first 128 bytes of the file, i.e. offset+size(magic) has to be less than 128h]h)}(hithe magic must reside in the first 128 bytes of the file, i.e. offset+size(magic) has to be less than 128h]hithe magic must reside in the first 128 bytes of the file, i.e. offset+size(magic) has to be less than 128}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK`hjvubah}(h]h ]h"]h$]h&]uh1jrhj\ubjs)}(h5the interpreter string may not exceed 127 characters h]h)}(h4the interpreter string may not exceed 127 charactersh]h4the interpreter string may not exceed 127 characters}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKbhjubah}(h]h ]h"]h$]h&]uh1jrhj\ubeh}(h]h ]h"]h$]h&]jHjIuh1jmhhhK_hjXubah}(h]h ]h"]h$]h&]uh1jIhhhK_hhhhubh)}(hXTo use binfmt_misc you have to mount it first. You can mount it with ``mount -t binfmt_misc none /proc/sys/fs/binfmt_misc`` command, or you can add a line ``none /proc/sys/fs/binfmt_misc binfmt_misc defaults 0 0`` to your ``/etc/fstab`` so it auto mounts on boot.h](hETo use binfmt_misc you have to mount it first. You can mount it with }(hjhhhNhNubh)}(h6``mount -t binfmt_misc none /proc/sys/fs/binfmt_misc``h]h2mount -t binfmt_misc none /proc/sys/fs/binfmt_misc}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh command, or you can add a line }(hjhhhNhNubh)}(h;``none /proc/sys/fs/binfmt_misc binfmt_misc defaults 0 0``h]h7none /proc/sys/fs/binfmt_misc binfmt_misc defaults 0 0}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh to your }(hjhhhNhNubh)}(h``/etc/fstab``h]h /etc/fstab}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh so it auto mounts on boot.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKdhhhhubh)}(hYou may want to add the binary formats in one of your ``/etc/rc`` scripts during boot-up. Read the manual of your init program to figure out how to do this right.h](h6You may want to add the binary formats in one of your }(hjhhhNhNubh)}(h ``/etc/rc``h]h/etc/rc}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubha scripts during boot-up. Read the manual of your init program to figure out how to do this right.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKihhhhubh)}(hOThink about the order of adding entries! Later added entries are matched first!h]hOThink about the order of adding entries! Later added entries are matched first!}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKmhhhhubh)}(hAA few examples (assumed you are in ``/proc/sys/fs/binfmt_misc``):h](h#A few examples (assumed you are in }(hj$hhhNhNubh)}(h``/proc/sys/fs/binfmt_misc``h]h/proc/sys/fs/binfmt_misc}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj$ubh):}(hj$hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKphhhhubjn)}(hhh](js)}(hXenable support for em86 (like binfmt_em86, for Alpha AXP only):: echo ':i386:M::\x7fELF\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfb\xff\xff:/bin/em86:' > register echo ':i486:M::\x7fELF\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfb\xff\xff:/bin/em86:' > register h](h)}(h@enable support for em86 (like binfmt_em86, for Alpha AXP only)::h]h?enable support for em86 (like binfmt_em86, for Alpha AXP only):}(hjKhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKrhjGubj )}(hXmecho ':i386:M::\x7fELF\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfb\xff\xff:/bin/em86:' > register echo ':i486:M::\x7fELF\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfb\xff\xff:/bin/em86:' > registerh]hXmecho ':i386:M::\x7fELF\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfb\xff\xff:/bin/em86:' > register echo ':i486:M::\x7fELF\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfb\xff\xff:/bin/em86:' > register}hjYsbah}(h]h ]h"]h$]h&]jjuh1j hhhKthjGubeh}(h]h ]h"]h$]h&]uh1jrhjDhhhhhNubjs)}(henable support for packed DOS applications (pre-configured dosemu hdimages):: echo ':DEXE:M::\x0eDEX::/usr/bin/dosexec:' > register h](h)}(hMenable support for packed DOS applications (pre-configured dosemu hdimages)::h]hLenable support for packed DOS applications (pre-configured dosemu hdimages):}(hjqhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKwhjmubj )}(h5echo ':DEXE:M::\x0eDEX::/usr/bin/dosexec:' > registerh]h5echo ':DEXE:M::\x0eDEX::/usr/bin/dosexec:' > register}hjsbah}(h]h ]h"]h$]h&]jjuh1j hhhKyhjmubeh}(h]h ]h"]h$]h&]uh1jrhjDhhhhhNubjs)}(hmenable support for Windows executables using wine:: echo ':DOSWin:M::MZ::/usr/local/bin/wine:' > register h](h)}(h3enable support for Windows executables using wine::h]h2enable support for Windows executables using wine:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK{hjubj )}(h5echo ':DOSWin:M::MZ::/usr/local/bin/wine:' > registerh]h5echo ':DOSWin:M::MZ::/usr/local/bin/wine:' > register}hjsbah}(h]h ]h"]h$]h&]jjuh1j hhhK}hjubeh}(h]h ]h"]h$]h&]uh1jrhjDhhhhhNubeh}(h]h ]h"]h$]h&]jHjIuh1jmhhhKrhhhhubh)}(h7For java support see Documentation/admin-guide/java.rsth]h7For java support see Documentation/admin-guide/java.rst}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hYou can enable/disable binfmt_misc or one binary type by echoing 0 (to disable) or 1 (to enable) to ``/proc/sys/fs/binfmt_misc/status`` or ``/proc/.../the_name``. Catting the file tells you the current status of ``binfmt_misc/the_entry``.h](hdYou can enable/disable binfmt_misc or one binary type by echoing 0 (to disable) or 1 (to enable) to }(hjhhhNhNubh)}(h#``/proc/sys/fs/binfmt_misc/status``h]h/proc/sys/fs/binfmt_misc/status}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh or }(hjhhhNhNubh)}(h``/proc/.../the_name``h]h/proc/.../the_name}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh3. Catting the file tells you the current status of }(hjhhhNhNubh)}(h``binfmt_misc/the_entry``h]hbinfmt_misc/the_entry}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hwYou can remove one entry or all entries by echoing -1 to ``/proc/.../the_name`` or ``/proc/sys/fs/binfmt_misc/status``.h](h9You can remove one entry or all entries by echoing -1 to }(hjhhhNhNubh)}(h``/proc/.../the_name``h]h/proc/.../the_name}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh or }(hjhhhNhNubh)}(h#``/proc/sys/fs/binfmt_misc/status``h]h/proc/sys/fs/binfmt_misc/status}(hj+hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(hHintsh]hHints}(hjFhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjChhhhhKubh)}(hIf you want to pass special arguments to your interpreter, you can write a wrapper script for it. See :doc:`Documentation/admin-guide/java.rst <./java>` for an example.h](hfIf you want to pass special arguments to your interpreter, you can write a wrapper script for it. See }(hjThhhNhNubh)}(h2:doc:`Documentation/admin-guide/java.rst <./java>`h]hinline)}(hj^h]h"Documentation/admin-guide/java.rst}(hjbhhhNhNubah}(h]h ](xrefstdstd-doceh"]h$]h&]uh1j`hj\ubah}(h]h ]h"]h$]h&]refdocadmin-guide/binfmt-misc refdomainjmreftypedoc refexplicitrefwarn reftarget./javauh1hhhhKhjTubh for an example.}(hjThhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjChhubh)}(hYour interpreter should NOT look in the PATH for the filename; the kernel passes it the full filename (or the file descriptor) to use. Using ``$PATH`` can cause unexpected behaviour and can be a security hazard.h](hYour interpreter should NOT look in the PATH for the filename; the kernel passes it the full filename (or the file descriptor) to use. Using }(hjhhhNhNubh)}(h ``$PATH``h]h$PATH}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh= can cause unexpected behaviour and can be a security hazard.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjChhubh)}(h6Richard Günther h](hRichard Günther <}(hjhhhNhNubh reference)}(h#rguenth@tat.physik.uni-tuebingen.deh]h#rguenth@tat.physik.uni-tuebingen.de}(hjhhhNhNubah}(h]h ]h"]h$]h&]refuri*mailto:rguenth@tat.physik.uni-tuebingen.deuh1jhjubh>}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjChhubeh}(h]hintsah ]h"]hintsah$]h&]uh1hhhhhhhhKubeh}(h];kernel-support-for-miscellaneous-binary-formats-binfmt-miscah ]h"]=kernel support for miscellaneous binary formats (binfmt_misc)ah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerj error_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(jjjju nametypes}(jjuh}(jhjjCu footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.