blob: 3f18770ff8fee1e678b43b06691ea39cbcb5ed8b [file] [log] [blame]
Willy Tarreau92fb9832007-10-16 17:34:28 +02001/*
2 * UNIX SOCK_STREAM protocol layer (uxst)
3 *
Willy Tarreaueb472682010-05-28 18:46:57 +02004 * Copyright 2000-2010 Willy Tarreau <w@1wt.eu>
Willy Tarreau92fb9832007-10-16 17:34:28 +02005 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 */
12
13#include <ctype.h>
14#include <errno.h>
15#include <fcntl.h>
Willy Tarreaud0a895d2012-09-18 17:40:35 +020016#include <pwd.h>
17#include <grp.h>
Willy Tarreau92fb9832007-10-16 17:34:28 +020018#include <stdio.h>
19#include <stdlib.h>
20#include <string.h>
21#include <syslog.h>
22#include <time.h>
23
Willy Tarreau92fb9832007-10-16 17:34:28 +020024#include <sys/socket.h>
25#include <sys/stat.h>
26#include <sys/types.h>
27#include <sys/un.h>
28
29#include <common/compat.h>
30#include <common/config.h>
31#include <common/debug.h>
Willy Tarreaud740bab2007-10-28 11:14:07 +010032#include <common/errors.h>
Willy Tarreau92fb9832007-10-16 17:34:28 +020033#include <common/mini-clist.h>
34#include <common/standard.h>
35#include <common/time.h>
36#include <common/version.h>
37
Willy Tarreau92fb9832007-10-16 17:34:28 +020038#include <types/global.h>
Willy Tarreau92fb9832007-10-16 17:34:28 +020039
Willy Tarreau92fb9832007-10-16 17:34:28 +020040#include <proto/fd.h>
Willy Tarreaud1d54542012-09-12 22:58:11 +020041#include <proto/listener.h>
Willy Tarreau92fb9832007-10-16 17:34:28 +020042#include <proto/log.h>
Willy Tarreaud1d54542012-09-12 22:58:11 +020043#include <proto/protocol.h>
Willy Tarreau92fb9832007-10-16 17:34:28 +020044#include <proto/proto_uxst.h>
Willy Tarreau92fb9832007-10-16 17:34:28 +020045#include <proto/task.h>
46
Emeric Bruncf20bf12010-10-22 16:06:11 +020047static int uxst_bind_listener(struct listener *listener, char *errmsg, int errlen);
48static int uxst_bind_listeners(struct protocol *proto, char *errmsg, int errlen);
Willy Tarreaudabf2e22007-10-28 21:59:24 +010049static int uxst_unbind_listeners(struct protocol *proto);
50
51/* Note: must not be declared <const> as its list will be overwritten */
52static struct protocol proto_unix = {
53 .name = "unix_stream",
54 .sock_domain = PF_UNIX,
55 .sock_type = SOCK_STREAM,
56 .sock_prot = 0,
57 .sock_family = AF_UNIX,
58 .sock_addrlen = sizeof(struct sockaddr_un),
59 .l3_addrlen = sizeof(((struct sockaddr_un*)0)->sun_path),/* path len */
Willy Tarreaubbebbbf2012-05-07 21:22:09 +020060 .accept = &listener_accept,
Emeric Bruncf20bf12010-10-22 16:06:11 +020061 .bind = uxst_bind_listener,
Willy Tarreaudabf2e22007-10-28 21:59:24 +010062 .bind_all = uxst_bind_listeners,
63 .unbind_all = uxst_unbind_listeners,
64 .enable_all = enable_all_listeners,
65 .disable_all = disable_all_listeners,
Willy Tarreau59b94792012-05-11 16:16:40 +020066 .get_src = uxst_get_src,
67 .get_dst = uxst_get_dst,
Willy Tarreaudabf2e22007-10-28 21:59:24 +010068 .listeners = LIST_HEAD_INIT(proto_unix.listeners),
69 .nb_listeners = 0,
70};
71
Willy Tarreaudabf2e22007-10-28 21:59:24 +010072/********************************
73 * 1) low-level socket functions
74 ********************************/
75
Willy Tarreau59b94792012-05-11 16:16:40 +020076/*
77 * Retrieves the source address for the socket <fd>, with <dir> indicating
78 * if we're a listener (=0) or an initiator (!=0). It returns 0 in case of
79 * success, -1 in case of error. The socket's source address is stored in
80 * <sa> for <salen> bytes.
81 */
82int uxst_get_src(int fd, struct sockaddr *sa, socklen_t salen, int dir)
83{
84 if (dir)
85 return getsockname(fd, sa, &salen);
86 else
87 return getpeername(fd, sa, &salen);
88}
89
90
91/*
92 * Retrieves the original destination address for the socket <fd>, with <dir>
93 * indicating if we're a listener (=0) or an initiator (!=0). It returns 0 in
94 * case of success, -1 in case of error. The socket's source address is stored
95 * in <sa> for <salen> bytes.
96 */
97int uxst_get_dst(int fd, struct sockaddr *sa, socklen_t salen, int dir)
98{
99 if (dir)
100 return getpeername(fd, sa, &salen);
101 else
102 return getsockname(fd, sa, &salen);
103}
104
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100105
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100106/* Tries to destroy the UNIX stream socket <path>. The socket must not be used
107 * anymore. It practises best effort, and no error is returned.
108 */
109static void destroy_uxst_socket(const char *path)
110{
111 struct sockaddr_un addr;
112 int sock, ret;
113
114 /* We might have been chrooted, so we may not be able to access the
115 * socket. In order to avoid bothering the other end, we connect with a
116 * wrong protocol, namely SOCK_DGRAM. The return code from connect()
117 * is enough to know if the socket is still live or not. If it's live
118 * in mode SOCK_STREAM, we get EPROTOTYPE or anything else but not
119 * ECONNREFUSED. In this case, we do not touch it because it's used
120 * by some other process.
121 */
122 sock = socket(PF_UNIX, SOCK_DGRAM, 0);
123 if (sock < 0)
124 return;
125
126 addr.sun_family = AF_UNIX;
127 strncpy(addr.sun_path, path, sizeof(addr.sun_path));
128 addr.sun_path[sizeof(addr.sun_path) - 1] = 0;
129 ret = connect(sock, (struct sockaddr *)&addr, sizeof(addr));
130 if (ret < 0 && errno == ECONNREFUSED) {
131 /* Connect failed: the socket still exists but is not used
132 * anymore. Let's remove this socket now.
133 */
134 unlink(path);
135 }
136 close(sock);
137}
138
139
140/********************************
141 * 2) listener-oriented functions
142 ********************************/
143
144
145/* This function creates a UNIX socket associated to the listener. It changes
146 * the state from ASSIGNED to LISTEN. The socket is NOT enabled for polling.
147 * The return value is composed from ERR_NONE, ERR_RETRYABLE and ERR_FATAL.
Willy Tarreau92fb9832007-10-16 17:34:28 +0200148 */
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100149static int uxst_bind_listener(struct listener *listener, char *errmsg, int errlen)
Willy Tarreau92fb9832007-10-16 17:34:28 +0200150{
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100151 int fd;
Willy Tarreau92fb9832007-10-16 17:34:28 +0200152 char tempname[MAXPATHLEN];
153 char backname[MAXPATHLEN];
154 struct sockaddr_un addr;
Willy Tarreaub40dc942010-11-07 12:10:51 +0100155 const char *msg = NULL;
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100156 const char *path;
157
158 int ret;
Willy Tarreau92fb9832007-10-16 17:34:28 +0200159
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100160 /* ensure we never return garbage */
161 if (errmsg && errlen)
162 *errmsg = 0;
163
164 if (listener->state != LI_ASSIGNED)
165 return ERR_NONE; /* already bound */
166
167 path = ((struct sockaddr_un *)&listener->addr)->sun_path;
Willy Tarreau92fb9832007-10-16 17:34:28 +0200168
169 /* 1. create socket names */
170 if (!path[0]) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100171 msg = "Invalid empty name for a UNIX socket";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200172 goto err_return;
173 }
174
175 ret = snprintf(tempname, MAXPATHLEN, "%s.%d.tmp", path, pid);
176 if (ret < 0 || ret >= MAXPATHLEN) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100177 msg = "name too long for UNIX socket";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200178 goto err_return;
179 }
180
181 ret = snprintf(backname, MAXPATHLEN, "%s.%d.bak", path, pid);
182 if (ret < 0 || ret >= MAXPATHLEN) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100183 msg = "name too long for UNIX socket";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200184 goto err_return;
185 }
186
187 /* 2. clean existing orphaned entries */
188 if (unlink(tempname) < 0 && errno != ENOENT) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100189 msg = "error when trying to unlink previous UNIX socket";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200190 goto err_return;
191 }
192
193 if (unlink(backname) < 0 && errno != ENOENT) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100194 msg = "error when trying to unlink previous UNIX socket";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200195 goto err_return;
196 }
197
198 /* 3. backup existing socket */
199 if (link(path, backname) < 0 && errno != ENOENT) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100200 msg = "error when trying to preserve previous UNIX socket";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200201 goto err_return;
202 }
203
204 /* 4. prepare new socket */
205 addr.sun_family = AF_UNIX;
206 strncpy(addr.sun_path, tempname, sizeof(addr.sun_path));
207 addr.sun_path[sizeof(addr.sun_path) - 1] = 0;
208
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100209 fd = socket(PF_UNIX, SOCK_STREAM, 0);
210 if (fd < 0) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100211 msg = "cannot create UNIX socket";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200212 goto err_unlink_back;
213 }
214
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100215 if (fd >= global.maxsock) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100216 msg = "socket(): not enough free sockets, raise -n argument";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200217 goto err_unlink_temp;
218 }
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100219
220 if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100221 msg = "cannot make UNIX socket non-blocking";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200222 goto err_unlink_temp;
223 }
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100224
225 if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
Willy Tarreau92fb9832007-10-16 17:34:28 +0200226 /* note that bind() creates the socket <tempname> on the file system */
Willy Tarreaub40dc942010-11-07 12:10:51 +0100227 msg = "cannot bind UNIX socket";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200228 goto err_unlink_temp;
229 }
230
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100231 /* <uid> and <gid> different of -1 will be used to change the socket owner.
232 * If <mode> is not 0, it will be used to restrict access to the socket.
233 * While it is known not to be portable on every OS, it's still useful
234 * where it works.
235 */
Willy Tarreau290e63a2012-09-20 18:07:14 +0200236 if (((listener->bind_conf->ux.uid != -1 || listener->bind_conf->ux.gid != -1) &&
237 (chown(tempname, listener->bind_conf->ux.uid, listener->bind_conf->ux.gid) == -1)) ||
238 (listener->bind_conf->ux.mode != 0 && chmod(tempname, listener->bind_conf->ux.mode) == -1)) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100239 msg = "cannot change UNIX socket ownership";
Willy Tarreaue6ad2b12007-10-18 12:45:54 +0200240 goto err_unlink_temp;
241 }
242
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100243 if (listen(fd, listener->backlog ? listener->backlog : listener->maxconn) < 0) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100244 msg = "cannot listen to UNIX socket";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200245 goto err_unlink_temp;
246 }
247
248 /* 5. install.
249 * Point of no return: we are ready, we'll switch the sockets. We don't
250 * fear loosing the socket <path> because we have a copy of it in
251 * backname.
252 */
253 if (rename(tempname, path) < 0) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100254 msg = "cannot switch final and temporary UNIX sockets";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200255 goto err_rename;
256 }
257
258 /* 6. cleanup */
259 unlink(backname); /* no need to keep this one either */
260
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100261 /* the socket is now listening */
262 listener->fd = fd;
263 listener->state = LI_LISTEN;
264
265 /* the function for the accept() event */
266 fd_insert(fd);
Willy Tarreauaece46a2012-07-06 12:25:58 +0200267 fdtab[fd].iocb = listener->proto->accept;
Willy Tarreaueabf3132008-08-29 23:36:51 +0200268 fdtab[fd].owner = listener; /* reference the listener instead of a task */
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100269 return ERR_NONE;
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100270 err_rename:
271 ret = rename(backname, path);
272 if (ret < 0 && errno == ENOENT)
273 unlink(path);
274 err_unlink_temp:
275 unlink(tempname);
276 close(fd);
277 err_unlink_back:
278 unlink(backname);
279 err_return:
280 if (msg && errlen)
281 snprintf(errmsg, errlen, "%s [%s]", msg, path);
282 return ERR_FATAL | ERR_ALERT;
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100283}
284
285/* This function closes the UNIX sockets for the specified listener.
286 * The listener enters the LI_ASSIGNED state. It always returns ERR_NONE.
287 */
288static int uxst_unbind_listener(struct listener *listener)
289{
Willy Tarreaube58c382011-07-24 18:28:10 +0200290 if (listener->state > LI_ASSIGNED) {
291 unbind_listener(listener);
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100292 destroy_uxst_socket(((struct sockaddr_un *)&listener->addr)->sun_path);
293 }
294 return ERR_NONE;
295}
296
297/* Add a listener to the list of unix stream listeners. The listener's state
298 * is automatically updated from LI_INIT to LI_ASSIGNED. The number of
299 * listeners is updated. This is the function to use to add a new listener.
300 */
301void uxst_add_listener(struct listener *listener)
302{
303 if (listener->state != LI_INIT)
304 return;
305 listener->state = LI_ASSIGNED;
306 listener->proto = &proto_unix;
307 LIST_ADDQ(&proto_unix.listeners, &listener->proto_list);
308 proto_unix.nb_listeners++;
309}
310
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100311/********************************
312 * 3) protocol-oriented functions
313 ********************************/
314
315
Willy Tarreau92fb9832007-10-16 17:34:28 +0200316/* This function creates all UNIX sockets bound to the protocol entry <proto>.
317 * It is intended to be used as the protocol's bind_all() function.
318 * The sockets will be registered but not added to any fd_set, in order not to
319 * loose them across the fork(). A call to uxst_enable_listeners() is needed
320 * to complete initialization.
321 *
322 * The return value is composed from ERR_NONE, ERR_RETRYABLE and ERR_FATAL.
323 */
Emeric Bruncf20bf12010-10-22 16:06:11 +0200324static int uxst_bind_listeners(struct protocol *proto, char *errmsg, int errlen)
Willy Tarreau92fb9832007-10-16 17:34:28 +0200325{
326 struct listener *listener;
327 int err = ERR_NONE;
Willy Tarreau92fb9832007-10-16 17:34:28 +0200328
329 list_for_each_entry(listener, &proto->listeners, proto_list) {
Emeric Bruncf20bf12010-10-22 16:06:11 +0200330 err |= uxst_bind_listener(listener, errmsg, errlen);
331 if (err & ERR_ABORT)
332 break;
Willy Tarreau92fb9832007-10-16 17:34:28 +0200333 }
Willy Tarreau92fb9832007-10-16 17:34:28 +0200334 return err;
335}
336
Willy Tarreau92fb9832007-10-16 17:34:28 +0200337
338/* This function stops all listening UNIX sockets bound to the protocol
339 * <proto>. It does not detaches them from the protocol.
340 * It always returns ERR_NONE.
341 */
342static int uxst_unbind_listeners(struct protocol *proto)
343{
344 struct listener *listener;
345
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100346 list_for_each_entry(listener, &proto->listeners, proto_list)
347 uxst_unbind_listener(listener);
Willy Tarreau92fb9832007-10-16 17:34:28 +0200348 return ERR_NONE;
349}
350
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200351/* parse the "mode" bind keyword */
Willy Tarreau4348fad2012-09-20 16:48:07 +0200352static int bind_parse_mode(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200353{
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200354 if (!*args[cur_arg + 1]) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200355 memprintf(err, "'%s' : missing mode (octal integer expected)", args[cur_arg]);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200356 return ERR_ALERT | ERR_FATAL;
357 }
358
Willy Tarreau290e63a2012-09-20 18:07:14 +0200359 conf->ux.mode = strtol(args[cur_arg + 1], NULL, 8);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200360 return 0;
361}
362
363/* parse the "gid" bind keyword */
Willy Tarreau4348fad2012-09-20 16:48:07 +0200364static int bind_parse_gid(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200365{
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200366 if (!*args[cur_arg + 1]) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200367 memprintf(err, "'%s' : missing value", args[cur_arg]);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200368 return ERR_ALERT | ERR_FATAL;
369 }
370
Willy Tarreau290e63a2012-09-20 18:07:14 +0200371 conf->ux.gid = atol(args[cur_arg + 1]);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200372 return 0;
373}
374
375/* parse the "group" bind keyword */
Willy Tarreau4348fad2012-09-20 16:48:07 +0200376static int bind_parse_group(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200377{
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200378 struct group *group;
379
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200380 if (!*args[cur_arg + 1]) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200381 memprintf(err, "'%s' : missing group name", args[cur_arg]);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200382 return ERR_ALERT | ERR_FATAL;
383 }
384
385 group = getgrnam(args[cur_arg + 1]);
386 if (!group) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200387 memprintf(err, "'%s' : unknown group name '%s'", args[cur_arg], args[cur_arg + 1]);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200388 return ERR_ALERT | ERR_FATAL;
389 }
390
Willy Tarreau290e63a2012-09-20 18:07:14 +0200391 conf->ux.gid = group->gr_gid;
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200392 return 0;
393}
394
395/* parse the "uid" bind keyword */
Willy Tarreau4348fad2012-09-20 16:48:07 +0200396static int bind_parse_uid(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200397{
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200398 if (!*args[cur_arg + 1]) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200399 memprintf(err, "'%s' : missing value", args[cur_arg]);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200400 return ERR_ALERT | ERR_FATAL;
401 }
402
Willy Tarreau290e63a2012-09-20 18:07:14 +0200403 conf->ux.uid = atol(args[cur_arg + 1]);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200404 return 0;
405}
406
407/* parse the "user" bind keyword */
Willy Tarreau4348fad2012-09-20 16:48:07 +0200408static int bind_parse_user(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200409{
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200410 struct passwd *user;
411
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200412 if (!*args[cur_arg + 1]) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200413 memprintf(err, "'%s' : missing user name", args[cur_arg]);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200414 return ERR_ALERT | ERR_FATAL;
415 }
416
417 user = getpwnam(args[cur_arg + 1]);
418 if (!user) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200419 memprintf(err, "'%s' : unknown user name '%s'", args[cur_arg], args[cur_arg + 1]);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200420 return ERR_ALERT | ERR_FATAL;
421 }
422
Willy Tarreau290e63a2012-09-20 18:07:14 +0200423 conf->ux.uid = user->pw_uid;
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200424 return 0;
425}
426
427/* Note: must not be declared <const> as its list will be overwritten.
428 * Please take care of keeping this list alphabetically sorted, doing so helps
429 * all code contributors.
430 * Optional keywords are also declared with a NULL ->parse() function so that
431 * the config parser can report an appropriate error when a known keyword was
432 * not enabled.
433 */
Willy Tarreau51fb7652012-09-18 18:24:39 +0200434static struct bind_kw_list bind_kws = { "UNIX", { }, {
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200435 { "gid", bind_parse_gid, 1 }, /* set the socket's gid */
436 { "group", bind_parse_group, 1 }, /* set the socket's gid from the group name */
437 { "mode", bind_parse_mode, 1 }, /* set the socket's mode (eg: 0644)*/
438 { "uid", bind_parse_uid, 1 }, /* set the socket's uid */
439 { "user", bind_parse_user, 1 }, /* set the socket's uid from the user name */
440 { NULL, NULL, 0 },
441}};
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100442
443/********************************
444 * 4) high-level functions
445 ********************************/
446
Willy Tarreau92fb9832007-10-16 17:34:28 +0200447__attribute__((constructor))
448static void __uxst_protocol_init(void)
449{
450 protocol_register(&proto_unix);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200451 bind_register_keywords(&bind_kws);
Willy Tarreau92fb9832007-10-16 17:34:28 +0200452}
453
454
455/*
456 * Local variables:
457 * c-indent-level: 8
458 * c-basic-offset: 8
459 * End:
460 */