From nobody Tue May 07 08:59:32 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VYXK03MDcz5KPHW; Tue, 07 May 2024 08:59:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VYXK02gmNz4Ztb; Tue, 7 May 2024 08:59:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715072372; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WvBcAo3Bipb06nXhOpzJ5w3ccB5HZhCaOLAmyM+Ps+E=; b=MVgOUF2246ZB+MkNUs1VY15jT9OXf7exnH0HpjJr5mIZakuRBUCCZ55uXeiX96si0Sb/xb a28eupodCSNF+cDZuk/vmYiD+f0umywf64jvPreIaz4hC0jo+8qdh3ixiA+AfqH0kxlr/W htcqsm0f4ZRp3Ut7Liu2AuKdI1O7CTGy8aQuU2ImqZq8lPyqGluFttjsRZpQAr9bOZeh5d Lu0K4z208VMN4AH9Le1hc44gR4Cv+jut3nBXQKZ/MKCDk5xndGqzNgW+z2Mk58uTbFPZ9V HYlURtVfdIfKI8fSU00dW6JtJZp/9vnVd1qSna2W+CaLMloI8u/1W2q2s2tx6g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715072372; a=rsa-sha256; cv=none; b=KlyTH4XZaeAvZegqNzLl/4p+okRz9yARs/XbtFkog+JXVMgEXa3ZBljTfQpr0tn13zcTrw Vt2ozWZo1KBaCN9Y8tEvWe0RaohxqInzdR/wGvWqSw/nucMyqw3ovaG9VZMCiKy9brFcmQ B6/kqYtMYIqeF5o7EEmtR/BI/k1nWWjjQqnWQtIYE+x/DtLlBUsW5R/LjEXhoL1Y9YR6Cb KM4V+KQOflbtVBHgZotKYhvmPp9Clua0peyuZVsabX+ixSAav7h1XaaP63XGwYgrKbhVF6 piPT0EzGSwfhvG+YYclrfAIvEI+ugraq+wVqJ45Sr/rLinNu1S2P4glMHN9Qug== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715072372; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WvBcAo3Bipb06nXhOpzJ5w3ccB5HZhCaOLAmyM+Ps+E=; b=ke2tMbCxG+vb+Tcu+gIyqw5cEsi5ru5qJFqapBwhwGsDJTk1y5N7hd34rOVio4ecoVr8P9 yG2dnuKfpC2esx7DoiVyhBcc3gVm0ahny2R/mK7jvfEyy8/5rj4/5tlEmKFtvTCSIkMcnz 3wngxk33pcXoZdqVJUUeelJqQ0AksUb+imlZBmo/8X/xeC35pcuD7GbEOMb2GrmAt/sDcV Z9+HC1ZU5XK2ZxbZXddWAf8QksJqFBfUrDvqhfiDAGN1P/EKX37989U5S34nalrVOGWRlc zxVn7aIENOvvDlgFCEZO78vyQLy5grNlCyAw42mBWsc4cxNqRorE1jCRB5heew== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VYXK02HDszb8V; Tue, 7 May 2024 08:59:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 4478xWSr021502; Tue, 7 May 2024 08:59:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4478xWcQ021499; Tue, 7 May 2024 08:59:32 GMT (envelope-from git) Date: Tue, 7 May 2024 08:59:32 GMT Message-Id: <202405070859.4478xWcQ021499@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 10484ee13a36 - stable/13 - rtld: add direct-exec option -o List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 10484ee13a36e3b0523e8de441c4d528148fd1a3 Auto-Submitted: auto-generated The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=10484ee13a36e3b0523e8de441c4d528148fd1a3 commit 10484ee13a36e3b0523e8de441c4d528148fd1a3 Author: Konstantin Belousov AuthorDate: 2024-04-28 03:19:39 +0000 Commit: Konstantin Belousov CommitDate: 2024-05-07 08:59:07 +0000 rtld: add direct-exec option -o (cherry picked from commit d1cd0cc32b53c09e72e33116b94a5b0b9781a183) --- libexec/rtld-elf/rtld.1 | 20 +++++++++++++++++++- libexec/rtld-elf/rtld.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/libexec/rtld-elf/rtld.1 b/libexec/rtld-elf/rtld.1 index a152dd444bd7..0f1e8f68b10a 100644 --- a/libexec/rtld-elf/rtld.1 +++ b/libexec/rtld-elf/rtld.1 @@ -26,7 +26,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd October 29, 2023 +.Dd April 28, 2024 .Dt RTLD 1 .Os .Sh NAME @@ -352,6 +352,7 @@ The syntax of the direct invocation is .Op Fl b Ar exe .Op Fl d .Op Fl f Ar fd +.Op Fl o Ar OPT=NAME .Op Fl p .Op Fl u .Op Fl v @@ -387,6 +388,23 @@ If this option is specified, is only used to provide the .Va argv[0] value to the program. +.It Fl o Ar OPT=VALUE +Set the +.Ar OPT +configuration variable to the value +.Ar VALUE . +The possible variable names are listed above as +.Ev LD_ +prefixed environment variables, but here are referenced without the +.Ev LD_ +prefix. +A configuration variable set this way does not leak into +the activated image's environment. +.Pp +The option can be repeated as many times as needed to set +all configuration parameters. +The parameters set using this option have priority over +the same parameters assigned via environment. .It Fl p If the .Pa image_path diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 1078ddd0551a..071a7cf8dde8 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -6201,6 +6201,35 @@ parse_args(char* argv[], int argc, bool *use_pathp, int *fdp, *fdp = fd; seen_f = true; break; + } else if (opt == 'o') { + struct ld_env_var_desc *l; + char *n, *v; + u_int ll; + + if (j != arglen - 1) { + _rtld_error("Invalid options: %s", arg); + rtld_die(); + } + i++; + n = argv[i]; + v = strchr(n, '='); + if (v == NULL) { + _rtld_error("No '=' in -o parameter"); + rtld_die(); + } + for (ll = 0; ll < nitems(ld_env_vars); ll++) { + l = &ld_env_vars[ll]; + if (v - n == (ptrdiff_t)strlen(l->n) && + strncmp(n, l->n, v - n) == 0) { + l->val = v + 1; + break; + } + } + if (ll == nitems(ld_env_vars)) { + _rtld_error("Unknown LD_ option %s", + n); + rtld_die(); + } } else if (opt == 'p') { *use_pathp = true; } else if (opt == 'u') { @@ -6284,6 +6313,7 @@ print_usage(const char *argv0) " -b Execute instead of , arg0 is \n" " -d Ignore lack of exec permissions for the binary\n" " -f Execute instead of searching for \n" + " -o = Set LD_ to , without polluting env\n" " -p Search in PATH for named binary\n" " -u Ignore LD_ environment variables\n" " -v Display identification information\n"