From nobody Fri Jan 27 19:28:06 2023 X-Original-To: dev-commits-src-branches@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 4P3SKM27t0z3brWP; Fri, 27 Jan 2023 19:28:07 +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 4P3SKM1X83z45YJ; Fri, 27 Jan 2023 19:28:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674847687; 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=YsaIQcbqHliLgRnvlXugy5pp+mz8YQ8dXu9JwU/TXOM=; b=QsJKzWLjnk1HyG6VhmkB48zMC25sm0hKY+n9hk1cH1cA8khidj9kBFdMoa02CsO5I54nEd Nri/bN7LR+KHOdLliG0xbMem1h/lVpIHqDU1PnkGjjjI3yOdRMi0RAnYlcU7ykn6AVAyCF HXqggLGkNJA2FPvQtBbRMXinebiQbImW4DK3Ni2pf8s5JH0NO7CVxVQOkLvHXKu61FJyqp rKy++Qsd0Pk6GgUOYlA2kf5woEh33fz9ufRR4BcjJX/UuS6nU76g3u/H6ye2pg1GPkeB/0 PyfnCEFSYBIvr9DtfNYjchfJhNinoCMxbXUi/sX9xN6hpCtxYi2MEeZdN1YbiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674847687; 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=YsaIQcbqHliLgRnvlXugy5pp+mz8YQ8dXu9JwU/TXOM=; b=ST+yUfeZVloZawbbG/bGyI0RD4lYiKMNO0WmqBD947nCufswOsFRdQJZ104YfhzngubEGz zMGvkZLEy9Bb/8pwQwx/cliD/eUv3aJUXg7XID3ydcIaTGLOjd6ta2nrU59S2xVQ3CfYhH CMgpOx1msjmvPu0eX7d3gZ25rZVfEvbST5N4Pfqh7zVX1Iy2XGJul7PI6gHzaXbeMB1QEL oNH6nR5r6RjhMfQITsTE//zJi72C7ir3slbjnkQz6/e4jxyDYwTpFUK7H0cPMDU2GHWlus WEWYOYhI6mxSeGj9oOjuARtgt6Nog4aJCDJfJtK26WywT7GVzWcTMWOLPPyuEg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674847687; a=rsa-sha256; cv=none; b=gRey91VwFGrkcjCBp7SwwBmGjFhLHTM69cKrm0e6pSlsKVReyv6CBu472FyeUoCNlUTVyv 5Ut9MGjjB798ZMby7Kzp0f8qtbyRNRdQFNRUspUYJCUfhIome3OOXRFUnHxN1jCaXjbjT8 QVGbnceku/5YEQV+ku5Y1cE6iMZtD6S4LufY+cyeX8FFkUAodL77MpT1TW5ioafip31o2h eCjkr0poIS9HHdzWn5QHqKOmCBF07hITrIOGTOhl0sHaKAfT7w1NKfbXdyFe6yymd1BFz7 tRCU3Y+YwqzRtXe2wQlG4GZsogbWxKhmBxAQO5SuwDQNu9qc7B9ub61xPL4SeA== 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 4P3SKM0bKlzLd3; Fri, 27 Jan 2023 19:28:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30RJS6Xr029105; Fri, 27 Jan 2023 19:28:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30RJS6G3029104; Fri, 27 Jan 2023 19:28:06 GMT (envelope-from git) Date: Fri, 27 Jan 2023 19:28:06 GMT Message-Id: <202301271928.30RJS6G3029104@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 6d28cb5486b8 - stable/13 - improvements to cap_sysctl.3 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6d28cb5486b83f16f0925c4fbb620ee96e9cb7db Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=6d28cb5486b83f16f0925c4fbb620ee96e9cb7db commit 6d28cb5486b83f16f0925c4fbb620ee96e9cb7db Author: Alan Somers AuthorDate: 2022-12-01 16:49:57 +0000 Commit: Alan Somers CommitDate: 2023-01-27 19:27:47 +0000 improvements to cap_sysctl.3 * Correct some function prototypes which were documented with the wrong pointer type. * Clarify return values and requirements for freeing the limit handle. [skip ci] Sponsored by: Axcient Reviewed by: oshogbo Differential Revision: https://reviews.freebsd.org/D37586 (cherry picked from commit 6c93a2d0bc37f0c912e402f3f94c3c01350dca26) --- lib/libcasper/services/cap_sysctl/cap_sysctl.3 | 42 +++++++++++++++++++++----- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/lib/libcasper/services/cap_sysctl/cap_sysctl.3 b/lib/libcasper/services/cap_sysctl/cap_sysctl.3 index 0a7d009e1c3c..381315fcbdd7 100644 --- a/lib/libcasper/services/cap_sysctl/cap_sysctl.3 +++ b/lib/libcasper/services/cap_sysctl/cap_sysctl.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 5, 2020 +.Dd December 1, 2022 .Dt CAP_SYSCTL 3 .Os .Sh NAME @@ -41,14 +41,14 @@ .Fn cap_sysctlbyname "cap_channel_t *chan" "const char *name" "void *oldp" "size_t *oldlenp" "const void *newp" "size_t newlen" .Ft int .Fn cap_sysctlnametomib "cap_channel_t *chan" "const char *name" "int *mibp" "size_t *sizep" -.Ft void * +.Ft cap_sysctl_limit_t * .Fn cap_sysctl_limit_init "cap_channel_t *chan" -.Ft void * -.Fn cap_sysctl_limit_name "void *limit" "const char *name" "int flags" -.Ft void * -.Fn cap_sysctl_limit_mib "void *limit" "const int *mibp" "u_int miblen" "int flags" +.Ft cap_sysctl_limit_t * +.Fn cap_sysctl_limit_name "cap_sysctl_limit_t *limit" "const char *name" "int flags" +.Ft cap_sysctl_limit_t * +.Fn cap_sysctl_limit_mib "cap_sysctl_limit_t *limit" "const int *mibp" "u_int miblen" "int flags" .Ft int -.Fn cap_sysctl_limit "void *limit" +.Fn cap_sysctl_limit "cap_sysctl_limit_t *limit" .Sh DESCRIPTION The .Fn cap_sysctl , @@ -109,6 +109,8 @@ must be specified. .Fn cap_sysctl_limit applies a set of sysctl limits to the capability, denying access to sysctl variables not belonging to the set. +It consumes the limit handle. +After either success or failure, the user must not access the handle again. .Pp Once a set of limits is applied, subsequent calls to .Fn cap_sysctl_limit @@ -168,6 +170,32 @@ printf("The value of %s is %d.\\n", name, value); cap_close(capsysctl); .Ed +.Sh RETURN VALUES +.Fn cap_sysctl_limit_init +will return a new limit handle on success or +.Dv NULL +on failure, and set +.Va errno . +.Fn cap_sysctl_limit_mib +and +.Fn cap_sysctl_limit_name +will return the modified limit handle on success or +.Dv NULL +on failure and set +.Va errno . +After failure, the caller must not access the limit handle again. +.Fn cap_sysctl_limit +will return +.Dv -1 +on failure and set +.Va errno . +.Fn cap_sysctl , +.Fn cap_sysctlbyname , +and +.Fn cap_sysctlnametomib +have the same return values as their non-capability-mode equivalents as +documented in +.Xr sysctl 3 . .Sh SEE ALSO .Xr cap_enter 2 , .Xr err 3 ,