blob: ce43d5077ae929c15c81eb1586aecb65de74440b (
plain) (
blame)
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
|
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="en" />
<title>s6: the s6-ipcserver-socketbinder program</title>
<meta name="Description" content="s6: the s6-ipcserver-socketbinder program" />
<meta name="Keywords" content="s6 s6-ipcserver-socketbinder ipcserver ucspi socket bind listen" />
<!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> -->
</head>
<body>
<p>
<a href="index.html">s6</a><br />
<a href="//skarnet.org/software/">Software</a><br />
<a href="//skarnet.org/">skarnet.org</a>
</p>
<h1> The <tt>s6-ipcserver-socketbinder</tt> program </h1>
<p>
<tt>s6-ipcserver-socketbinder</tt> binds a Unix domain
socket, then executes a program.
</p>
<h2> Interface </h2>
<pre>
s6-ipcserver-socketbinder [ -d | -D ] [ -b <em>backlog</em> ] [ -M | -m ] [ -a <em>perms</em> ] <em>path</em> <em>prog...</em>
</pre>
<ul>
<li> s6-ipcserver-socketbinder creates a Unix domain socket
and binds it to <em>path</em>. It prepares the socket to accept
connections by calling
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html">listen()</a>. </li>
<li> It then execs into <em>prog...</em> with the open socket
as its standard input. </li>
</ul>
<h2> Options </h2>
<ul>
<li> <tt>-d</tt> : allow instant rebinding to the same path
even if it has been used not long ago - this is the SO_REUSEADDR flag to
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html">setsockopt()</a>
and is generally used with server programs. This is the default. Note that
<em>path</em> will be deleted if it already exists at program start time. </li>
<li> <tt>-D</tt> : disallow instant rebinding to the same path. </li>
<li> <tt>-b <em>backlog</em></tt> : set a maximum of
<em>backlog</em> backlog connections on the socket - extra
connection attempts will rejected by the kernel. The default is SOMAXCONN,
i.e. the maximum number allowed by the system. If <em>backlog</em>
is 0, then the socket will be created, but it <strong>will not be
listening</strong>. </li>
<li> <tt>-M</tt> : the type of the socket will be SOCK_STREAM. This is
the default. </li>
<li> <tt>-m</tt> : the type of the socket will be SOCK_DGRAM. Note
that by default SOCK_DGRAM sockets are not connection-mode, and <tt>listen()</tt>
will fail - so you should always give the <tt>-b0</tt> option to
s6-ipcserver-socketbinder along with <tt>-m</tt>. </li>
<li> <tt>-a <em>perms</em></tt> : create the socket with
permissions <em>perms</em>, which is an octal number from 0000 to 0777.
Default is 0777, meaning everyone can connect to it. 0700 means only processes having the
same uid as the s6-ipcserver-socketbinder process can connect to it. </li>
</ul>
<h2> Notes </h2>
<ul>
<li> The socket is provided <strong>non-blocking</strong>. </li>
<li> s6-ipcserver-socketbinder is part of a set of basic blocks used to
build a flexible Unix super-server. It normally should be given a
command line crafted to make it execute into
<a href="s6-ipcserverd.html">s6-ipcserverd</a> to accept connections
from clients, or into a program such as
<a href="s6-applyuidgid.html">s6-applyuidgid</a>
to drop privileges before doing so. </li>
<li> The <a href="s6-ipcserver.html">s6-ipcserver</a> program does
exactly this. It implements
a full Unix super-server by building a command line starting with
s6-ipcserver-socketbinder and ending with s6-ipcserverd followed by the
application program, and executing into it. </li>
</ul>
</body>
</html>
|