.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "VMOD_UNIX" 3 "" "" .SH NAME vmod_unix \- Utilities for Unix domain sockets .\" . .\" NB: This file is machine generated, DO NOT EDIT! . .\" . .\" Edit ./vmod_unix.vcc and run make instead . .\" . .SH SYNOPSIS .INDENT 0.0 .INDENT 3.5 .sp .EX import unix [as name] [from \(dqpath\(dq] STRING user() STRING group() INT uid() INT gid() .EE .UNINDENT .UNINDENT .SH DESCRIPTION .sp This VMOD provides information about the credentials of the peer process (user and group of the process owner) that is connected to a Varnish listener via a Unix domain socket, if the platform supports it. .sp Examples: .INDENT 0.0 .INDENT 3.5 .sp .EX import unix; sub vcl_recv { # Return \(dq403 Forbidden\(dq if the connected peer is # not running as the user \(dqtrusteduser\(dq. if (unix.user() != \(dqtrusteduser\(dq) { return( synth(403) ); } # Require the connected peer to run in the group # \(dqtrustedgroup\(dq. if (unix.group() != \(dqtrustedgroup\(dq) { return( synth(403) ); } # Require the connected peer to run under a specific numeric # user id. if (unix.uid() != 4711) { return( synth(403) ); } # Require the connected peer to run under a numeric group id. if (unix.gid() != 815) { return( synth(403) ); } } .EE .UNINDENT .UNINDENT .sp Obtaining the peer credentials is possible on a platform that supports one of the following: .INDENT 0.0 .IP \(bu 2 \fIgetpeereid(3)\fP (such as FreeBSD and other BSD\-derived systems) .IP \(bu 2 the socket option \fBSO_PEERCRED\fP for \fIgetsockopt(2)\fP (Linux) .IP \(bu 2 \fIgetpeerucred(3C)\fP (SunOS and descendants) .UNINDENT .sp On SunOS and friends, the \fBPRIV_PROC_INFO\fP privilege set is added to the Varnish child process while the VMOD is loaded, see \fIsetppriv(2)\fP\&. .sp On most platforms, the value returned is the effective user or group that was valid when the peer process initiated the connection. .SS STRING user() .sp Return the user name of the peer process owner. .SS STRING group() .sp Return the group name of the peer process owner. .SS INT uid() .sp Return the numeric user id of the peer process owner. .SS INT gid() .sp Return the numeric group id of the peer process owner. .SH ERRORS .sp All functions in this VMOD are subject to the following constraints: .INDENT 0.0 .IP \(bu 2 None of them may be called in \fBvcl_init{}\fP or \fBvcl_fini{}\fP\&. If one of them is called in \fBvcl_init{}\fP, then the VCL program will fail to load, with an error message from the VMOD. .IP \(bu 2 If called on a platform that is not supported, then VCL failure is invoked. An error message is written to the log (with the \fBVCL_Error\fP tag), and for all VCL subroutines except for \fBvcl_synth{}\fP, control is directed immediately to \fBvcl_synth{}\fP, with the response status set to 503 and the reason string set to \(dqVCL failed\(dq. .sp If the failure occurs during \fBvcl_synth{}\fP, then \fBvcl_synth{}\fP is aborted, and the the response line \(dq503 VCL failed\(dq is sent. .IP \(bu 2 If the current listener is not a Unix domain socket, or if the attempt to read credentials fails, then a \fBVCL_Error\fP message is written to the log. The STRING functions (\fI\%unix.user()\fP and \fI\%unix.group()\fP) return \fBNULL\fP, while the INT functions (\fI\%unix.uid()\fP and \fI\%unix.gid()\fP) return \-1. .UNINDENT .SH SEE ALSO .INDENT 0.0 .IP \(bu 2 \fIvarnishd(1)\fP .IP \(bu 2 \fIvcl(7)\fP .IP \(bu 2 \fIgetpeereid(3)\fP .IP \(bu 2 \fIgetsockopt(2)\fP .IP \(bu 2 \fIgetpeerucred(3C)\fP .IP \(bu 2 \fIsetppriv(2)\fP .UNINDENT .SH COPYRIGHT .INDENT 0.0 .INDENT 3.5 .sp .EX This document is licensed under the same conditions as Varnish itself. See LICENSE for details. SPDX\-License\-Identifier: BSD\-2\-Clause Authors: Geoffrey Simmons .EE .UNINDENT .UNINDENT .\" Generated by docutils manpage writer. .