From nobody Thu Dec 08 19:46:01 2022 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 4NSl560mHBz4kGxN; Thu, 8 Dec 2022 19:46:02 +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 4NSl560Ckcz3DqB; Thu, 8 Dec 2022 19:46:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670528762; 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=x/+X/Jor9y0iu8WXYi3UQvG41NvakatU0RHfhA4Bdvw=; b=oa7WDlKFt+S5/P6aHAqk6AnCLO4e+7VEogzvh7n3mPUtrXW9l/p4xwJ4fuZT5ZZfZJ4nwL S4sl1hc2Yp3fmyUWl8zYbZBA/tAJbEg7K/cRNXHqjcm3xw7lHjJxzd4VK58mx/ETJN7BDg MGdzRowXYZ1QuRKn4+xQZsY35gLkeBzeaF3ej7ahTkcaejd1Qsa9dcJ+JBhVwnlnzZYwpW 4pmBQLJ4qlb25YPmAua0eAwc/X8mzmAkZoDx7OCfWPbvPUcTPSB6/JruJFbd++hQXjH001 qH7CY4BYAmW6eGoiOKkf/nwfyM1EA3Ekx+lBa8vQyBoAnk9H3SZADweXHPhv5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670528762; 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=x/+X/Jor9y0iu8WXYi3UQvG41NvakatU0RHfhA4Bdvw=; b=xlrqCLLlxR+5HOK5Z7JtAe+wuMEzempwZlJOYggMs+kWGvnOLKddq6yEEpI1ZIxsxjZUXv iIcPwKmxlPkrMq1AZZYDE+fm2h6l8X4E7CTpdp3g8H8El0y6+OnaplXbmOYoV1HlKoRLg8 dtQRfknKclgX1dIh2BhnQWEo5pGNYvUk9Gg2Fe3btzBgHdm0LvFM1xyUuvbmPNA8xy3nSu +M7YqXrY7NuxzKKb3J41flLo/sILQdTG/FknKSX8NSWtqBhAt/8RV1pv0rcjBS0IqwISu2 LDgDwXwn/BDi3ix2FFs1bjPmRejGw1nabQWoU4Jxzre3uEMDl4BfteAlPsO+Zg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1670528762; a=rsa-sha256; cv=none; b=xubEvUzgfdHmPfoCSJav0YxdP6i7yBnBqEYlOC8vr/vy98j+TKVMAWs0mMPkrkttZHt5o2 G4zstGPWuXYItblHXFmRco7PvgJtbfg9En0vpOUZ+rUFgy3jllVqkBr5SJOTpfocIO8QOO bb7FwtzZfRKQ+/kBgHULyUOSHoAZCKufcvlXu4/xPva13p5Soz2FL1Umd6FhLh1dpvPtaT dVOat1I8EvsJ9rYD5NWujczkvEMWi+/sVIRu7JRGZBm0tFjgqsieIoHecu2AKXPvx/w3EB ICtzbt5dYP/7mcfROiEyBcmAdT+vg0y6iVQI8p9OSwakbXm9ws+hU+3Ypj2kTA== 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 4NSl5566Dhz172S; Thu, 8 Dec 2022 19:46:01 +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 2B8Jk1Ut070943; Thu, 8 Dec 2022 19:46:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2B8Jk1e8070942; Thu, 8 Dec 2022 19:46:01 GMT (envelope-from git) Date: Thu, 8 Dec 2022 19:46:01 GMT Message-Id: <202212081946.2B8Jk1e8070942@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alan Somers Subject: git: 6c93a2d0bc37 - main - [skip ci] improvements to cap_sysctl.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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: 6c93a2d0bc37f0c912e402f3f94c3c01350dca26 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=6c93a2d0bc37f0c912e402f3f94c3c01350dca26 commit 6c93a2d0bc37f0c912e402f3f94c3c01350dca26 Author: Alan Somers AuthorDate: 2022-12-01 16:49:57 +0000 Commit: Alan Somers CommitDate: 2022-12-08 19:45:47 +0000 [skip ci] 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. MFC after: 1 week Sponsored by: Axcient Reviewed by: oshogbo Differential Revision: https://reviews.freebsd.org/D37586 --- 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 ,