From nobody Thu Nov 14 00:43:09 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 4XphG55kG7z5cny5; Thu, 14 Nov 2024 00:43:09 +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 4XphG52j3Cz4qtR; Thu, 14 Nov 2024 00:43:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731544989; 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=852AWupY1eGt/0DTWdxOk/KQ9Tf7w9GaHPs5khcnLmk=; b=PDVBT51nIdguRJdBAuV1TrhsiwmDCQJKPlvnegZrvhCcKtAs8vSrQ+nZ8oOlfjdRhNVkat YNr/P9Eyx6HFUOySEMXdNf01HILe5jyXhu8PDIEtcr1K8c3NP31ynNBIRfCt3eLuEduKbz CCtEHFjoxEWiCd3ulprY20PPKegiBmb30olyJ85cPBge72ghRQMdZJ8I/kI4bD1AXgatoJ t2aLy7WaSLDeX1APiROkVv7YIvj8MXD8EZnApaJKNw5qlzcMka9KCziInYXl+/ZE34JcxC vlI6k97K65Gwyow14lSwnMGqZJz45Z1qLhcPEflzZt8QXaApu51dPJpywXlXwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731544989; 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=852AWupY1eGt/0DTWdxOk/KQ9Tf7w9GaHPs5khcnLmk=; b=F05ZqHzoNemObWfpjCV//mE3djPOIkkHQVtxPAUe43tYf42fDQpilzI+ftP+vShgf+tiT8 Noc0ZjGnHxFA2p1B/kx6wzdcWOC09tLuFfNF4ncLB2B4z+x5Y+Zy7WuVM1nGlKigrq/9Zm nrnqZPtJiOYEFx3DjbNQB9XlHn2dwXCHS9Q07qAaICp9+2DM/lWUGBpLXZ/YLew9ujZU/P /KGKkZRjhp/NPcCXxM3CmIE15A2rMJDbCmkhBynfoWN8zRTh6RnJ6vPPlkdJ4hPJsxPBwd YUncil7CJ7avPItn8ilbSbrV8/4Zp31sF2zWPxdtwjQL07kq4Gq/XUl1VA4wnw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731544989; a=rsa-sha256; cv=none; b=mcGlZzANOzOIET4C4SomdFhjpcCDExN3Fz8NLQGtgW2b4B+ONhkvdB0/pH9SiNaMWm8/US +GdrR0CEaitq5qE8DN8kRJzmZkRWOKcMVoNjWr0+JbWLWfUQto6Q5aK9nCh3rTUxrW5QsC Osnsvtsl+NCvyZZ7Afy53F4Ksj1OQTXcGTA2rUmMpU/dY2MZNAUBeTuPxPsf50KC9xkn8V JOqZNVdZshhfCrxUPdKhcKMqChqt86WEaPIVgiv4QJ0N1kUe5UYGnAfW0sVqSgB/9denZ6 7NsErdaBPDfC7w8Va2x4MyyIpXctRY1z+mOIzaRhUyzs3KXbkkt9z3iMDwnGTA== 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 4XphG52K53zHFH; Thu, 14 Nov 2024 00:43:09 +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 4AE0h925024458; Thu, 14 Nov 2024 00:43:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AE0h92U024455; Thu, 14 Nov 2024 00:43:09 GMT (envelope-from git) Date: Thu, 14 Nov 2024 00:43:09 GMT Message-Id: <202411140043.4AE0h92U024455@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: cc3978cb74d6 - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: cc3978cb74d66eb30c809d834bacee80fc92172c Auto-Submitted: auto-generated The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=cc3978cb74d66eb30c809d834bacee80fc92172c commit cc3978cb74d66eb30c809d834bacee80fc92172c Author: Konstantin Belousov AuthorDate: 2024-10-31 20:15:33 +0000 Commit: Konstantin Belousov CommitDate: 2024-11-14 00:42:17 +0000 Document rtld_get_var(3) (cherry picked from commit 3820f784597cf87deb42522f108c5ee477a1f282) --- 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 408eb2ff1e28..332edfcd6695 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -292,6 +292,7 @@ MAN+= alarm.3 \ rand48.3 \ readpassphrase.3 \ rfork_thread.3 \ + rtld_get_var.3 \ scandir.3 \ sem_destroy.3 \ sem_getvalue.3 \ @@ -500,6 +501,8 @@ MLINKS+=rand48.3 _rand48.3 \ rand48.3 seed48.3 \ rand48.3 srand48.3 MLINKS+=recv.2 recvmmsg.2 +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 .