File: vmod_unix.3

package info (click to toggle)
varnish 6.5.1-1%2Bdeb11u3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 19,720 kB
  • sloc: ansic: 95,295; javascript: 9,411; sh: 4,673; python: 2,157; makefile: 1,353; awk: 114; ruby: 34
file content (190 lines) | stat: -rw-r--r-- 4,587 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
.\" Man page generated from reStructuredText.
.
.TH VMOD_UNIX 3 "" "" ""
.SH NAME
vmod_unix \- Utilities for Unix domain sockets
.
.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
..
.\" 
.
.\" 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
.nf
.ft C
import unix [as name] [from "path"]

STRING user()

STRING group()

INT uid()

INT gid()
.ft P
.fi
.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
.nf
.ft C
import unix;

sub vcl_recv {
      # Return "403 Forbidden" if the connected peer is
      # not running as the user "trusteduser".
      if (unix.user() != "trusteduser") {
              return( synth(403) );
      }

      # Require the connected peer to run in the group
      # "trustedgroup".
      if (unix.group() != "trustedgroup") {
              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) );
      }
}
.ft P
.fi
.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
"VCL failed".
.sp
If the failure occurs during \fBvcl_synth{}\fP, then \fBvcl_synth{}\fP
is aborted, and the the response line "503 VCL failed" 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
.nf
.ft C
This document is licensed under the same conditions as Varnish itself.
See LICENSE for details.

Authors: Geoffrey Simmons <geoffrey.simmons@uplex.de>
.ft P
.fi
.UNINDENT
.UNINDENT
.\" Generated by docutils manpage writer.
.