.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Podwrapper::Man 1.49.3 (Pod::Simple 3.48) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Required to disable full justification in groff 1.23.0. .if n .ds AD l .\" ======================================================================== .\" .IX Title "nbdkit_peer_name 3" .TH nbdkit_peer_name 3 2026-09-01 nbdkit-1.49.3 NBDKIT .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME nbdkit_peer_name, nbdkit_peer_pid, nbdkit_peer_uid, nbdkit_peer_gid, nbdkit_peer_security_context \- get client address and information for nbdkit .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int nbdkit_peer_name (struct sockaddr *addr, socklen_t *addrlen); \& int64_t nbdkit_peer_pid (void); \& int64_t nbdkit_peer_uid (void); \& int64_t nbdkit_peer_gid (void); \& char *nbdkit_peer_security_context (void); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" .SS nbdkit_peer_name .IX Subsection "nbdkit_peer_name" Return the peer (client) address, if available. The \f(CW\*(C`addr\*(C'\fR and \&\f(CW\*(C`addrlen\*(C'\fR parameters behave like \fBgetpeername\fR\|(2). In particular you must initialize \f(CW\*(C`addrlen\*(C'\fR with the size of the buffer pointed to by \f(CW\*(C`addr\*(C'\fR, and if \f(CW\*(C`addr\*(C'\fR is not large enough then the address will be truncated. .PP In some cases this is not available or the address returned will be meaningless (eg. if there is a proxy between the client and nbdkit). This call uses thread\-local magic so no parameter is required to specify the current connection. .SS nbdkit_peer_pid .IX Subsection "nbdkit_peer_pid" (nbdkit ≥ 1.24, Linux only) .PP Return the peer process ID. This is only available when the client connected over a Unix domain socket. .SS nbdkit_peer_uid .IX Subsection "nbdkit_peer_uid" (nbdkit ≥ 1.24) .PP Return the peer user ID. This is only available when the client connected over a Unix domain socket. .SS nbdkit_peer_gid .IX Subsection "nbdkit_peer_gid" (nbdkit ≥ 1.24) .PP Return the peer group ID. This is only available when the client connected over a Unix domain socket. .SS nbdkit_peer_security_context .IX Subsection "nbdkit_peer_security_context" (nbdkit ≥ 1.36, not Windows) .PP Return the peer security context (usually the SELinux label, IPSEC label or NetLabel). See the description of \f(CW\*(C`SO_PEERSEC\*(C'\fR in \&\fBunix\fR\|(7) and \fBip\fR\|(7). .SH "RETURN VALUE" .IX Header "RETURN VALUE" All functions except \f(CW\*(C`nbdkit_peer_security_context\*(C'\fR return \f(CW0\fR on success. If there is an error they call \fBnbdkit_error\fR\|(3) and return \&\f(CW\-1\fR. .PP \&\f(CW\*(C`nbdkit_peer_security_context\*(C'\fR returns a security context as a string on success. The caller must free this string. On error (which can include missing label or unsupported protocol), \fBnbdkit_error\fR\|(3) is called and this call returns \f(CW\*(C`NULL\*(C'\fR. .SH "LANGUAGE BINDINGS" .IX Header "LANGUAGE BINDINGS" In \fBnbdkit\-ocaml\-plugin\fR\|(3): .PP .Vb 5 \& NBDKit.peer_name : unit \-> Unix.sockaddr \& NBDKit.peer_pid : unit \-> int64 \& NBDKit.peer_uid : unit \-> int64 \& NBDKit.peer_gid : unit \-> int64 \& NBDKit.peer_security_context : unit \-> string .Ve .PP In \fBnbdkit\-python\-plugin\fR\|(3): .PP .Vb 5 \& import nbdkit \& pid = nbdkit.peer_pid() \& uid = nbdkit.peer_uid() \& gid = nbdkit.peer_gid() \& security_context = nbdkit.peer_security_context() .Ve .PP In \fBnbdkit\-rust\-plugin\fR\|(3): .PP .Vb 3 \& use nbdkit::*; \& pub fn peername() \-> \& std::result::Result> .Ve .SH HISTORY .IX Header "HISTORY" \&\f(CW\*(C`nbdkit_peer_name\*(C'\fR was added in nbdkit 1.16. .PP \&\f(CW\*(C`nbdkit_peer_pid\*(C'\fR, \f(CW\*(C`nbdkit_peer_uid\*(C'\fR and \f(CW\*(C`nbdkit_peer_gid\*(C'\fR were added in nbdkit 1.24. .PP \&\f(CW\*(C`nbdkit_peer_security_context\*(C'\fR was added in nbdkit 1.36. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBnbdkit\fR\|(1), \&\fBnbdkit\-plugin\fR\|(3), \&\fBnbdkit\-filter\fR\|(3), \&\fBnbdkit\-ip\-filter\fR\|(1), \&\fBgetpeername\fR\|(2), \&\fBunix\fR\|(7), \&\fBip\fR\|(7). .SH AUTHORS .IX Header "AUTHORS" Richard W.M. Jones .SH COPYRIGHT .IX Header "COPYRIGHT" Copyright Red Hat .SH LICENSE .IX Header "LICENSE" Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: .IP \(bu 4 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. .IP \(bu 4 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. .IP \(bu 4 Neither the name of Red Hat nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. .PP THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS \*(Aq\*(AqAS IS\*(Aq\*(Aq 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 RED HAT 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.