From f203669d25d74e8f52666da67a73e2765ee01167 Mon Sep 17 00:00:00 2001 From: Robert Swiecki Date: Mon, 12 Jun 2017 02:14:18 +0200 Subject: [PATCH] config: give ability to override argv[0] --- config.c | 6 +++++- config.proto | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index 0fed705..ef2c0f8 100644 --- a/config.c +++ b/config.c @@ -230,7 +230,11 @@ static bool configParseInternal(struct nsjconf_t *nsjconf, Nsjail__NsJailConfig if (njc->exec_bin) { char **argv = utilCalloc(sizeof(const char *) * (njc->exec_bin->n_arg + 2)); - argv[0] = utilStrDup(njc->exec_bin->path); + if (njc->exec_bin->arg0) { + argv[0] = utilStrDup(njc->exec_bin->arg0); + } else { + argv[0] = utilStrDup(njc->exec_bin->path); + } for (size_t i = 0; i < njc->exec_bin->n_arg; i++) { argv[i + 1] = utilStrDup(njc->exec_bin->arg[i]); } diff --git a/config.proto b/config.proto index a73c47b..d5d9d6b 100644 --- a/config.proto +++ b/config.proto @@ -58,6 +58,8 @@ message Exe required string path = 1; /* This will be argv[1] and so on.. */ repeated string arg = 2; + /* Override argv[0] */ + optional string arg0 = 3; } message NsJailConfig { -- 2.34.1