From nobody Thu Nov 07 05:20:37 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 4XkVlW1jjTz5cNLB; Thu, 07 Nov 2024 05:20:39 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XkVlT3zCZz55Jx; Thu, 7 Nov 2024 05:20:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730956837; 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=BkSbij8aJp11SmUDBL25mIDzTyjglqCd07LvhgOzgV0=; b=Eqd72vTtZMare1NN/4vxgbrJ0atOrxOc1x/J6iB/LmdUypRgDAHkXBlhjQAIpMgjBpv8mL EwHoRzB0fbVDyU8wioHEUoEQUNPIp/tEV6Gp14Hpq4HqxES3xqKG+gATk8f5vvWJd+Hr0c B2qm2lI0bNuHeeFd/EgN7Yw4bFumMgU1r4VRZo3i0tGApgIGo5JEX/9VFLgdPnWeUeCbA0 gQQeiBZXjhEFHXU0DhTmsWiQRL5xsOIePpbowzT1sltIxx2Bz249H6uGbG0DmKVHdwQDN0 BCiHv1tNpNhLeECpXzXVEuNp5HIHYBpqVqAdEIwPHzhgyKVYFq6kqiriHtQmGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730956837; 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=BkSbij8aJp11SmUDBL25mIDzTyjglqCd07LvhgOzgV0=; b=FZvpqLbOzK4GuNxSw7hpskPfwGidBk4rD/8iHN3QYgxYtFtfsCE6BMQqz4H17PHYTLYZXt comnIcABvvyStZB+T7aOzf4YtRE/jpLLRXTowWSG/KCtX7xwCZX5/SXNXz8ps7UArgXYi8 toOVsyi4PIaSd6wILQvEhyH24xzev3DL7zWLd5zyyjXiVZFE3qt6otKPNfmu0qWmohBCnt sxIZ7d+nROJPM8onUd5a/0HBRTZX3pxpfOjD6gSUuRoUN/v67vwhky0E/b917pPIcqIyr7 Dff3ChtfM++huHEi5DUT5s55ylfAAt8vPHNa+Pr1jK+Qd7oyrsqUrDdNbXW+XQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730956837; a=rsa-sha256; cv=none; b=hgX4hU/YUbZyK+P2imzmrzRNjNvBHqAe+DmQt8dRPoO3PMaN/jrcZVRWHdsC9vUkcO/x5J LvTefYJGGZn3Mx9Idqqx5GE1ZNTpKwYVDGr8GbrsOrkc9hcGM5N8cjrG/qd781tv79Kk07 GYWneqyf+9zX3ZQHNdLTlwcolNiQKtdJZoZHWct0RXfkBzCOrIqKg85qaCOaBP4yRgx4R+ 1zeURdtVovtvHOeYtaDjUDQvwSUYP1mwqoUalr7rxp+9B42LUtDBuGI1rnsxH14532gfHb lv3y/bZlBuzOEUi84WB6ZCERFJ0CJo1naHt18Tt4uvnDEWGABQnfHaGlHBtRkA== 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 4XkVlT23PTzXDQ; Thu, 7 Nov 2024 05:20:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4A75KbBI014653; Thu, 7 Nov 2024 05:20:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A75KbkS014650; Thu, 7 Nov 2024 05:20:37 GMT (envelope-from git) Date: Thu, 7 Nov 2024 05:20:37 GMT Message-Id: <202411070520.4A75KbkS014650@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 3820f784597c - main - Document rtld_get_var(3) 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/main X-Git-Reftype: branch X-Git-Commit: 3820f784597cf87deb42522f108c5ee477a1f282 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3820f784597cf87deb42522f108c5ee477a1f282 commit 3820f784597cf87deb42522f108c5ee477a1f282 Author: Konstantin Belousov AuthorDate: 2024-10-31 20:15:33 +0000 Commit: Konstantin Belousov CommitDate: 2024-11-07 05:15:30 +0000 Document rtld_get_var(3) Reviewed by: Alexander Ziaee Discussed with: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D47351 --- lib/libc/gen/Makefile.inc | 3 ++ lib/libc/gen/rtld_get_var.3 | 106 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index 8111b0d24345..42a359ccfb72 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -275,6 +275,7 @@ MAN+= alarm.3 \ raise.3 \ rand48.3 \ readpassphrase.3 \ + rtld_get_var.3 \ scandir.3 \ sem_destroy.3 \ sem_getvalue.3 \ @@ -481,6 +482,8 @@ MLINKS+=rand48.3 _rand48.3 \ rand48.3 nrand48.3 \ rand48.3 seed48.3 \ rand48.3 srand48.3 +MLINKS+=rtld_get_var.3 \ + rtld_set_var.3 MLINKS+=scandir.3 alphasort.3 \ scandir.3 scandirat.3 \ scandir.3 scandir_b.3 \ diff --git a/lib/libc/gen/rtld_get_var.3 b/lib/libc/gen/rtld_get_var.3 new file mode 100644 index 000000000000..06d2e8a41cbc --- /dev/null +++ b/lib/libc/gen/rtld_get_var.3 @@ -0,0 +1,106 @@ +.\" Copyright (c) 2024 The FreeBSD Foundation +.\" +.\" This documentation was written by +.\" Konstantin Belousov under sponsorship +.\" from the FreeBSD Foundation. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (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 31, 2024 +.Dt RTLD_GET_VAR 3 +.Os +.Sh NAME +.Nm rtld_get_var , +.Nm rtld_set_var +.Nd query or change run-time linker parameters after image activation +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/errno.h +.In link.h +.Ft const char * +.Fn rtld_get_var "const char *name" +.Ft int +.Fn rtld_set_var "const char *name" "const char *value" +.Sh DESCRIPTION +The dynamic linker +.Xr rtld 1 +can be configured be setting some environment variables for the process, +before image activation. +Sometimes it is desirable to query the current effective settings or +change them afterward. +.Pp +Since the process environment variables are maintained by higher-level +libraries, the run-time linker cannot access them after the image +activation. +The described functions make it possible to operate on rtld settings. +.Pp +The +.Fn rtld_get_var +function returns the current value of the named parameter. +.Pp +The +.Fn rtld_set_var +functions changes the value of the parameter to the new +.Fa value +value, if possible. +The +.Fa name +argument to both functions is the name of the parameter, which +is same as the corresponding environment variable +.Pq see Xr rtld 1 +but without the +.Ev LD_ +(or +.Ev LD_32_ +or any other ABI-specific) prefix. +.Sh RETURN VALUES +The +.Fn rtld_get_var +returns the current value of the named parameter, or +.Dv NULL +if the name is invalid. +.Pp +The +.Fn rtld_set_var +returns 0 on success, or an integer indicating the error condition +which prevented the operation. +.Sh ERRORS +Possible errors returned from +.Fn rtld_set_var : +.Bl -tag -width Er +.It Bq Er EPERM +The requested change cannot be made at runtime, either because the +runtime linker can only take this parameter at initialization time, +or because the current process is executing with elevated privileges. +.It Bq ENOENT +The supplied parameter +.Fa name +is unknown. +.El +.Sh SEE ALSO +.Xr rtld 1 +.Sh HISTORY +The +.Nm +function first appeared in +.Fx 15.0 .