Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ OBJECTS += \
execve/enter.o \
execve/exit.o \
execve/shebang.o \
execve/binfmt.o \
execve/elf.o \
execve/ldso.o \
execve/auxv.o \
Expand Down
6 changes: 6 additions & 0 deletions src/cli/proot.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* 02110-1301 USA.
*/

#include <stdlib.h>
#include <string.h> /* str*(3), */
#include <assert.h> /* assert(3), */
#include <stdio.h> /* printf(3), fflush(3), */
Expand Down Expand Up @@ -335,6 +336,11 @@ static int handle_option_p(Tracee *tracee, const Cli *cli UNUSED, const char *va
return 0;
}

static int handle_option_binfmt_rules(Tracee *tracee UNUSED, const struct Cli *cli UNUSED, const char *value) {
atexit(clear_binfmt_rule_list);
return read_binfmt_rules_from_file(value);
}

/**
* Initialize @tracee->qemu.
*/
Expand Down
18 changes: 18 additions & 0 deletions src/cli/proot.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define PROOT_CLI_H

#include "cli/cli.h"
#include "execve/binfmt.h"

#ifndef VERSION
#define VERSION "5.1.0"
Expand Down Expand Up @@ -67,6 +68,7 @@ static int handle_option_kill_on_exit(Tracee *tracee, const Cli *cli, const char
static int handle_option_L(Tracee *tracee, const Cli *cli, const char *value);
static int handle_option_H(Tracee *tracee, const Cli *cli, const char *value);
static int handle_option_p(Tracee *tracee, const Cli *cli, const char *value);
static int handle_option_binfmt_rules(Tracee *tracee, const struct Cli *cli, const char *value);

static int pre_initialize_bindings(Tracee *, const Cli *, size_t, char *const *, size_t);
static int post_initialize_exe(Tracee *, const Cli *, size_t, char *const *, size_t);
Expand Down Expand Up @@ -284,6 +286,22 @@ Copyright (C) 2015 STMicroelectronics, licensed under GPL v2 or later.",
.description = "Correct the size returned from lstat for symbolic links.",
.detail = "",
},
{
.class = "Extension options",
.arguments = {
{ .name = "--binfmt-rules", .separator = ' ', .value = "path" },
{ .name = NULL, .separator = '\0', .value = NULL }
},
.handler = handle_option_binfmt_rules,
.description = "Load binfmt_misc rules from the specified file.",
.detail = "\tThis option allows loading binfmt_misc rules from a file.\n\
\tEach rule in the file should follow this format:\n\
\n\
\t:name:type:offset:magic:mask:interpreter:\n\
\n\
\tThis is useful for adding support for executing foreign\n\
\tbinary formats within the proot environment.",
},
{ .class = "Alias options",
.arguments = {
{ .name = "-R", .separator = ' ', .value = "path" },
Expand Down
Loading