blob: 3263ea4ab1bccf0e7b28a8391a75b818d86c4f43 [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.
Willy Tarreau8ab505b2013-01-24 01:41:38 +0100147 * The return value is composed from ERR_NONE, ERR_RETRYABLE and ERR_FATAL. It
148 * may return a warning or an error message in <errmsg> if the message is at
149 * most <errlen> bytes long (including '\0'). Note that <errmsg> may be NULL if
150 * <errlen> is also zero.
Willy Tarreau92fb9832007-10-16 17:34:28 +0200151 */
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100152static int uxst_bind_listener(struct listener *listener, char *errmsg, int errlen)
Willy Tarreau92fb9832007-10-16 17:34:28 +0200153{
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100154 int fd;
Willy Tarreau92fb9832007-10-16 17:34:28 +0200155 char tempname[MAXPATHLEN];
156 char backname[MAXPATHLEN];
157 struct sockaddr_un addr;
Willy Tarreaub40dc942010-11-07 12:10:51 +0100158 const char *msg = NULL;
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100159 const char *path;
160
161 int ret;
Willy Tarreau92fb9832007-10-16 17:34:28 +0200162
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100163 /* ensure we never return garbage */
Willy Tarreau8ab505b2013-01-24 01:41:38 +0100164 if (errlen)
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100165 *errmsg = 0;
166
167 if (listener->state != LI_ASSIGNED)
168 return ERR_NONE; /* already bound */
169
170 path = ((struct sockaddr_un *)&listener->addr)->sun_path;
Willy Tarreau92fb9832007-10-16 17:34:28 +0200171
172 /* 1. create socket names */
173 if (!path[0]) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100174 msg = "Invalid empty name for a UNIX socket";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200175 goto err_return;
176 }
177
178 ret = snprintf(tempname, MAXPATHLEN, "%s.%d.tmp", path, pid);
179 if (ret < 0 || ret >= MAXPATHLEN) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100180 msg = "name too long for UNIX socket";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200181 goto err_return;
182 }
183
184 ret = snprintf(backname, MAXPATHLEN, "%s.%d.bak", path, pid);
185 if (ret < 0 || ret >= MAXPATHLEN) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100186 msg = "name too long for UNIX socket";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200187 goto err_return;
188 }
189
190 /* 2. clean existing orphaned entries */
191 if (unlink(tempname) < 0 && errno != ENOENT) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100192 msg = "error when trying to unlink previous UNIX socket";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200193 goto err_return;
194 }
195
196 if (unlink(backname) < 0 && errno != ENOENT) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100197 msg = "error when trying to unlink previous UNIX socket";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200198 goto err_return;
199 }
200
201 /* 3. backup existing socket */
202 if (link(path, backname) < 0 && errno != ENOENT) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100203 msg = "error when trying to preserve previous UNIX socket";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200204 goto err_return;
205 }
206
207 /* 4. prepare new socket */
208 addr.sun_family = AF_UNIX;
209 strncpy(addr.sun_path, tempname, sizeof(addr.sun_path));
210 addr.sun_path[sizeof(addr.sun_path) - 1] = 0;
211
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100212 fd = socket(PF_UNIX, SOCK_STREAM, 0);
213 if (fd < 0) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100214 msg = "cannot create UNIX socket";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200215 goto err_unlink_back;
216 }
217
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100218 if (fd >= global.maxsock) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100219 msg = "socket(): not enough free sockets, raise -n argument";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200220 goto err_unlink_temp;
221 }
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100222
223 if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100224 msg = "cannot make UNIX socket non-blocking";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200225 goto err_unlink_temp;
226 }
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100227
228 if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
Willy Tarreau92fb9832007-10-16 17:34:28 +0200229 /* note that bind() creates the socket <tempname> on the file system */
Willy Tarreaub40dc942010-11-07 12:10:51 +0100230 msg = "cannot bind UNIX socket";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200231 goto err_unlink_temp;
232 }
233
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100234 /* <uid> and <gid> different of -1 will be used to change the socket owner.
235 * If <mode> is not 0, it will be used to restrict access to the socket.
236 * While it is known not to be portable on every OS, it's still useful
237 * where it works.
238 */
Willy Tarreau290e63a2012-09-20 18:07:14 +0200239 if (((listener->bind_conf->ux.uid != -1 || listener->bind_conf->ux.gid != -1) &&
240 (chown(tempname, listener->bind_conf->ux.uid, listener->bind_conf->ux.gid) == -1)) ||
241 (listener->bind_conf->ux.mode != 0 && chmod(tempname, listener->bind_conf->ux.mode) == -1)) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100242 msg = "cannot change UNIX socket ownership";
Willy Tarreaue6ad2b12007-10-18 12:45:54 +0200243 goto err_unlink_temp;
244 }
245
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100246 if (listen(fd, listener->backlog ? listener->backlog : listener->maxconn) < 0) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100247 msg = "cannot listen to UNIX socket";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200248 goto err_unlink_temp;
249 }
250
251 /* 5. install.
252 * Point of no return: we are ready, we'll switch the sockets. We don't
253 * fear loosing the socket <path> because we have a copy of it in
254 * backname.
255 */
256 if (rename(tempname, path) < 0) {
Willy Tarreaub40dc942010-11-07 12:10:51 +0100257 msg = "cannot switch final and temporary UNIX sockets";
Willy Tarreau92fb9832007-10-16 17:34:28 +0200258 goto err_rename;
259 }
260
261 /* 6. cleanup */
262 unlink(backname); /* no need to keep this one either */
263
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100264 /* the socket is now listening */
265 listener->fd = fd;
266 listener->state = LI_LISTEN;
267
268 /* the function for the accept() event */
269 fd_insert(fd);
Willy Tarreauaece46a2012-07-06 12:25:58 +0200270 fdtab[fd].iocb = listener->proto->accept;
Willy Tarreaueabf3132008-08-29 23:36:51 +0200271 fdtab[fd].owner = listener; /* reference the listener instead of a task */
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100272 return ERR_NONE;
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100273 err_rename:
274 ret = rename(backname, path);
275 if (ret < 0 && errno == ENOENT)
276 unlink(path);
277 err_unlink_temp:
278 unlink(tempname);
279 close(fd);
280 err_unlink_back:
281 unlink(backname);
282 err_return:
283 if (msg && errlen)
284 snprintf(errmsg, errlen, "%s [%s]", msg, path);
285 return ERR_FATAL | ERR_ALERT;
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100286}
287
288/* This function closes the UNIX sockets for the specified listener.
289 * The listener enters the LI_ASSIGNED state. It always returns ERR_NONE.
290 */
291static int uxst_unbind_listener(struct listener *listener)
292{
Willy Tarreaube58c382011-07-24 18:28:10 +0200293 if (listener->state > LI_ASSIGNED) {
294 unbind_listener(listener);
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100295 destroy_uxst_socket(((struct sockaddr_un *)&listener->addr)->sun_path);
296 }
297 return ERR_NONE;
298}
299
300/* Add a listener to the list of unix stream listeners. The listener's state
301 * is automatically updated from LI_INIT to LI_ASSIGNED. The number of
302 * listeners is updated. This is the function to use to add a new listener.
303 */
304void uxst_add_listener(struct listener *listener)
305{
306 if (listener->state != LI_INIT)
307 return;
308 listener->state = LI_ASSIGNED;
309 listener->proto = &proto_unix;
310 LIST_ADDQ(&proto_unix.listeners, &listener->proto_list);
311 proto_unix.nb_listeners++;
312}
313
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100314/********************************
315 * 3) protocol-oriented functions
316 ********************************/
317
318
Willy Tarreau92fb9832007-10-16 17:34:28 +0200319/* This function creates all UNIX sockets bound to the protocol entry <proto>.
320 * It is intended to be used as the protocol's bind_all() function.
321 * The sockets will be registered but not added to any fd_set, in order not to
322 * loose them across the fork(). A call to uxst_enable_listeners() is needed
323 * to complete initialization.
324 *
325 * The return value is composed from ERR_NONE, ERR_RETRYABLE and ERR_FATAL.
326 */
Emeric Bruncf20bf12010-10-22 16:06:11 +0200327static int uxst_bind_listeners(struct protocol *proto, char *errmsg, int errlen)
Willy Tarreau92fb9832007-10-16 17:34:28 +0200328{
329 struct listener *listener;
330 int err = ERR_NONE;
Willy Tarreau92fb9832007-10-16 17:34:28 +0200331
332 list_for_each_entry(listener, &proto->listeners, proto_list) {
Emeric Bruncf20bf12010-10-22 16:06:11 +0200333 err |= uxst_bind_listener(listener, errmsg, errlen);
334 if (err & ERR_ABORT)
335 break;
Willy Tarreau92fb9832007-10-16 17:34:28 +0200336 }
Willy Tarreau92fb9832007-10-16 17:34:28 +0200337 return err;
338}
339
Willy Tarreau92fb9832007-10-16 17:34:28 +0200340
341/* This function stops all listening UNIX sockets bound to the protocol
342 * <proto>. It does not detaches them from the protocol.
343 * It always returns ERR_NONE.
344 */
345static int uxst_unbind_listeners(struct protocol *proto)
346{
347 struct listener *listener;
348
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100349 list_for_each_entry(listener, &proto->listeners, proto_list)
350 uxst_unbind_listener(listener);
Willy Tarreau92fb9832007-10-16 17:34:28 +0200351 return ERR_NONE;
352}
353
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200354/* parse the "mode" bind keyword */
Willy Tarreau4348fad2012-09-20 16:48:07 +0200355static 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 +0200356{
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200357 if (!*args[cur_arg + 1]) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200358 memprintf(err, "'%s' : missing mode (octal integer expected)", args[cur_arg]);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200359 return ERR_ALERT | ERR_FATAL;
360 }
361
Willy Tarreau290e63a2012-09-20 18:07:14 +0200362 conf->ux.mode = strtol(args[cur_arg + 1], NULL, 8);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200363 return 0;
364}
365
366/* parse the "gid" bind keyword */
Willy Tarreau4348fad2012-09-20 16:48:07 +0200367static 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 +0200368{
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200369 if (!*args[cur_arg + 1]) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200370 memprintf(err, "'%s' : missing value", args[cur_arg]);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200371 return ERR_ALERT | ERR_FATAL;
372 }
373
Willy Tarreau290e63a2012-09-20 18:07:14 +0200374 conf->ux.gid = atol(args[cur_arg + 1]);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200375 return 0;
376}
377
378/* parse the "group" bind keyword */
Willy Tarreau4348fad2012-09-20 16:48:07 +0200379static 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 +0200380{
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200381 struct group *group;
382
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200383 if (!*args[cur_arg + 1]) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200384 memprintf(err, "'%s' : missing group name", args[cur_arg]);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200385 return ERR_ALERT | ERR_FATAL;
386 }
387
388 group = getgrnam(args[cur_arg + 1]);
389 if (!group) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200390 memprintf(err, "'%s' : unknown group name '%s'", args[cur_arg], args[cur_arg + 1]);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200391 return ERR_ALERT | ERR_FATAL;
392 }
393
Willy Tarreau290e63a2012-09-20 18:07:14 +0200394 conf->ux.gid = group->gr_gid;
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200395 return 0;
396}
397
398/* parse the "uid" bind keyword */
Willy Tarreau4348fad2012-09-20 16:48:07 +0200399static 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 +0200400{
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200401 if (!*args[cur_arg + 1]) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200402 memprintf(err, "'%s' : missing value", args[cur_arg]);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200403 return ERR_ALERT | ERR_FATAL;
404 }
405
Willy Tarreau290e63a2012-09-20 18:07:14 +0200406 conf->ux.uid = atol(args[cur_arg + 1]);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200407 return 0;
408}
409
410/* parse the "user" bind keyword */
Willy Tarreau4348fad2012-09-20 16:48:07 +0200411static 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 +0200412{
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200413 struct passwd *user;
414
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200415 if (!*args[cur_arg + 1]) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200416 memprintf(err, "'%s' : missing user name", args[cur_arg]);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200417 return ERR_ALERT | ERR_FATAL;
418 }
419
420 user = getpwnam(args[cur_arg + 1]);
421 if (!user) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200422 memprintf(err, "'%s' : unknown user name '%s'", args[cur_arg], args[cur_arg + 1]);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200423 return ERR_ALERT | ERR_FATAL;
424 }
425
Willy Tarreau290e63a2012-09-20 18:07:14 +0200426 conf->ux.uid = user->pw_uid;
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200427 return 0;
428}
429
430/* Note: must not be declared <const> as its list will be overwritten.
431 * Please take care of keeping this list alphabetically sorted, doing so helps
432 * all code contributors.
433 * Optional keywords are also declared with a NULL ->parse() function so that
434 * the config parser can report an appropriate error when a known keyword was
435 * not enabled.
436 */
Willy Tarreau51fb7652012-09-18 18:24:39 +0200437static struct bind_kw_list bind_kws = { "UNIX", { }, {
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200438 { "gid", bind_parse_gid, 1 }, /* set the socket's gid */
439 { "group", bind_parse_group, 1 }, /* set the socket's gid from the group name */
440 { "mode", bind_parse_mode, 1 }, /* set the socket's mode (eg: 0644)*/
441 { "uid", bind_parse_uid, 1 }, /* set the socket's uid */
442 { "user", bind_parse_user, 1 }, /* set the socket's uid from the user name */
443 { NULL, NULL, 0 },
444}};
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100445
446/********************************
447 * 4) high-level functions
448 ********************************/
449
Willy Tarreau92fb9832007-10-16 17:34:28 +0200450__attribute__((constructor))
451static void __uxst_protocol_init(void)
452{
453 protocol_register(&proto_unix);
Willy Tarreaud0a895d2012-09-18 17:40:35 +0200454 bind_register_keywords(&bind_kws);
Willy Tarreau92fb9832007-10-16 17:34:28 +0200455}
456
457
458/*
459 * Local variables:
460 * c-indent-level: 8
461 * c-basic-offset: 8
462 * End:
463 */