[gs]etsockopt(2) points out that SO_TYPE, SO_DOMAIN, SO_PROTOCOL and SO_ERROR are read-only but does not include SO_PEERCRED in that list. Also in the initial big list at the top of the page, SO_PEERCRED is not singled out as get only.
This patch shuffles the lines around to put SO_PEERCRED with its peers. Matthew Index: lib/libc/sys/getsockopt.2 =================================================================== RCS file: /src/datum/openbsd/cvs/src/lib/libc/sys/getsockopt.2,v retrieving revision 1.57 diff -u -p -r1.57 getsockopt.2 --- lib/libc/sys/getsockopt.2 4 Feb 2021 18:51:01 -0000 1.57 +++ lib/libc/sys/getsockopt.2 7 Oct 2021 09:00:21 -0000 @@ -162,8 +162,6 @@ set timeout value for output set timeout value for input .It Dv SO_TIMESTAMP enables reception of a timestamp with datagrams -.It Dv SO_PEERCRED -get the credentials from other side of connection .It Dv SO_RTABLE set the routing table used for route lookups .It Dv SO_SPLICE @@ -178,6 +176,8 @@ get and clear error on the socket (get o get the domain of the socket (get only) .It Dv SO_PROTOCOL get the protocol of the socket (get only) +.It Dv SO_PEERCRED +get the credentials from other side of connection (get only) .El .Pp .Dv SO_DEBUG @@ -349,20 +349,6 @@ cmsg_level = SOL_SOCKET cmsg_type = SCM_TIMESTAMP .Ed .Pp -.Dv SO_PEERCRED -fetches the -.Va struct sockpeercred -credentials from the other side of the connection -(currently only possible on -.Dv AF_UNIX -sockets). -These credentials are from the time that -.Xr bind 2 , -.Xr connect 2 -or -.Xr socketpair 2 -were called. -.Pp The .Dv SO_RTABLE option gets or sets the routing table which will be used by the socket @@ -459,9 +445,10 @@ is set, overwrite kernel memory after se Finally, .Dv SO_TYPE , .Dv SO_DOMAIN , -.Dv SO_PROTOCOL -and +.Dv SO_PROTOCOL , .Dv SO_ERROR +and +.Dv SO_PEERCRED are options used only with .Fn getsockopt . .Dv SO_TYPE @@ -478,6 +465,19 @@ returns the protocol of the socket such returns any pending error on the socket and clears the error status. It may be used to check for asynchronous errors on connected datagram sockets or for other asynchronous errors. +.Dv SO_PEERCRED +fetches the +.Va struct sockpeercred +credentials from the other side of the connection +(currently only possible on +.Dv AF_UNIX +sockets). +These credentials are from the time that +.Xr bind 2 , +.Xr connect 2 +or +.Xr socketpair 2 +were called. .Sh RETURN VALUES .Rv -std .Sh ERRORS