1 1.9 rillig /* $NetBSD: syslogd.h,v 1.9 2021/11/27 22:30:26 rillig Exp $ */ 2 1.1 christos 3 1.1 christos /*- 4 1.1 christos * Copyright (c) 2008 The NetBSD Foundation, Inc. 5 1.1 christos * All rights reserved. 6 1.1 christos * 7 1.1 christos * This code is derived from software contributed to The NetBSD Foundation 8 1.1 christos * by Martin Schtte. 9 1.1 christos * 10 1.1 christos * Redistribution and use in source and binary forms, with or without 11 1.1 christos * modification, are permitted provided that the following conditions 12 1.1 christos * are met: 13 1.1 christos * 1. Redistributions of source code must retain the above copyright 14 1.1 christos * notice, this list of conditions and the following disclaimer. 15 1.1 christos * 2. Redistributions in binary form must reproduce the above copyright 16 1.1 christos * notice, this list of conditions and the following disclaimer in the 17 1.1 christos * documentation and/or other materials provided with the distribution. 18 1.1 christos * 3. All advertising materials mentioning features or use of this software 19 1.1 christos * must display the following acknowledgement: 20 1.1 christos * This product includes software developed by the NetBSD 21 1.1 christos * Foundation, Inc. and its contributors. 22 1.1 christos * 4. Neither the name of The NetBSD Foundation nor the names of its 23 1.1 christos * contributors may be used to endorse or promote products derived 24 1.1 christos * from this software without specific prior written permission. 25 1.1 christos * 26 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 1.1 christos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 1.1 christos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 1.1 christos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 1.1 christos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 1.1 christos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 1.1 christos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 1.1 christos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 1.1 christos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 1.1 christos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 1.1 christos * POSSIBILITY OF SUCH DAMAGE. 37 1.1 christos */ 38 1.1 christos #ifndef SYSLOGD_H_ 39 1.1 christos #define SYSLOGD_H_ 40 1.1 christos /* 41 1.2 minskim * hold common data structures and prototypes 42 1.1 christos * for syslogd.c and tls.c 43 1.2 minskim * 44 1.1 christos */ 45 1.2 minskim 46 1.1 christos #include <sys/cdefs.h> 47 1.1 christos #define MAXLINE 1024 /* maximum line length */ 48 1.1 christos #define MAXSVLINE 120 /* maximum saved line length */ 49 1.1 christos #define DEFUPRI (LOG_USER|LOG_NOTICE) 50 1.1 christos #define DEFSPRI (LOG_KERN|LOG_NOTICE) 51 1.1 christos #define TIMERINTVL 30 /* interval for checking flush, mark */ 52 1.1 christos #define TTYMSGTIME 1 /* timeout passed to ttymsg */ 53 1.1 christos 54 1.1 christos #include <sys/param.h> 55 1.1 christos #include <sys/socket.h> 56 1.1 christos #include <sys/sysctl.h> 57 1.1 christos #include <sys/types.h> 58 1.1 christos #include <sys/un.h> 59 1.1 christos #include <sys/wait.h> 60 1.1 christos #include <sys/queue.h> 61 1.1 christos #include <netinet/in.h> 62 1.1 christos #include <sys/event.h> 63 1.1 christos #include <event.h> 64 1.1 christos 65 1.1 christos #include <assert.h> 66 1.1 christos #include <ctype.h> 67 1.1 christos #include <errno.h> 68 1.1 christos #include <fcntl.h> 69 1.1 christos #include <grp.h> 70 1.1 christos #include <locale.h> 71 1.1 christos #include <netdb.h> 72 1.1 christos #include <pwd.h> 73 1.1 christos #include <signal.h> 74 1.1 christos #include <stdarg.h> 75 1.1 christos #include <stdio.h> 76 1.1 christos #include <stdlib.h> 77 1.1 christos #include <string.h> 78 1.1 christos #include <unistd.h> 79 1.1 christos #include <stdbool.h> 80 1.1 christos #include <utmp.h> 81 1.1 christos #ifdef __NetBSD_Version__ 82 1.1 christos #include <util.h> 83 1.1 christos #include "utmpentry.h" 84 1.1 christos #endif /* __NetBSD_Version__ */ 85 1.1 christos #ifdef __FreeBSD_version 86 1.1 christos #include <libutil.h> 87 1.1 christos #include <sys/stat.h> 88 1.1 christos #include <sys/uio.h> 89 1.1 christos #include <limits.h> 90 1.1 christos #endif /* __FreeBSD_version */ 91 1.1 christos 92 1.1 christos #ifndef DISABLE_TLS 93 1.1 christos #include <netinet/tcp.h> 94 1.1 christos #include <openssl/ssl.h> 95 1.1 christos #endif /* !DISABLE_TLS */ 96 1.1 christos 97 1.1 christos #include <sys/stdint.h> 98 1.1 christos #include <sys/resource.h> 99 1.1 christos 100 1.1 christos #include "pathnames.h" 101 1.1 christos #include <sys/syslog.h> 102 1.1 christos 103 1.1 christos /* some differences between the BSDs */ 104 1.1 christos #ifdef __FreeBSD_version 105 1.1 christos #undef _PATH_UNIX 106 1.1 christos #define _PATH_UNIX "kernel" 107 1.1 christos #define HAVE_STRNDUP 0 108 1.1 christos #endif /* __FreeBSD_version */ 109 1.1 christos 110 1.1 christos #ifdef __NetBSD_Version__ 111 1.1 christos #define HAVE_STRNDUP 1 112 1.1 christos #define HAVE_DEHUMANIZE_NUMBER 1 113 1.1 christos #endif /* __NetBSD_Version__ */ 114 1.1 christos 115 1.1 christos #ifndef HAVE_DEHUMANIZE_NUMBER /* not in my 4.0-STABLE yet */ 116 1.1 christos extern int dehumanize_number(const char *str, int64_t *size); 117 1.1 christos #endif /* !HAVE_DEHUMANIZE_NUMBER */ 118 1.1 christos 119 1.1 christos #if !HAVE_STRNDUP 120 1.1 christos char *strndup(const char *str, size_t n); 121 1.1 christos #endif /* !HAVE_STRNDUP */ 122 1.1 christos 123 1.1 christos #ifdef LIBWRAP 124 1.1 christos #include <tcpd.h> 125 1.1 christos #endif 126 1.1 christos 127 1.1 christos #define FDMASK(fd) (1 << (fd)) 128 1.1 christos 129 1.1 christos #define A_CNT(x) (sizeof((x)) / sizeof((x)[0])) 130 1.1 christos 131 1.1 christos /* debug messages with categories */ 132 1.1 christos #define D_NONE 0 133 1.1 christos #define D_CALL 1 /* function calls */ 134 1.1 christos #define D_DATA 2 /* syslog message reading/formatting */ 135 1.1 christos #define D_NET 4 /* sockets/network */ 136 1.1 christos #define D_FILE 8 /* local files */ 137 1.1 christos #define D_TLS 16 /* TLS */ 138 1.1 christos #define D_PARSE 32 /* configuration/parsing */ 139 1.1 christos #define D_EVENT 64 /* libevent */ 140 1.1 christos #define D_BUFFER 128 /* message queues */ 141 1.1 christos #define D_MEM 256 /* malloc/free */ 142 1.1 christos #define D_MEM2 1024 /* every single malloc/free */ 143 1.1 christos #define D_SIGN 2048 /* -sign */ 144 1.1 christos #define D_MISC 4096 /* everything else */ 145 1.1 christos #define D_ALL (D_CALL | D_DATA | D_NET | D_FILE | D_TLS | D_PARSE | \ 146 1.1 christos D_EVENT | D_BUFFER | D_MEM | D_MEM2 | D_SIGN | D_MISC) 147 1.1 christos #define D_DEFAULT (D_CALL | D_NET | D_FILE | D_TLS | D_MISC) 148 1.1 christos 149 1.1 christos 150 1.1 christos /* build with -DNDEBUG to remove all assert()s and DPRINTF()s */ 151 1.1 christos #ifdef NDEBUG 152 1.1 christos #define DPRINTF(x, ...) (void)0 153 1.1 christos #else 154 1.6 joerg void dbprintf(const char *, const char *, size_t, const char *, ...) 155 1.6 joerg __printflike(4, 5); 156 1.1 christos #define DPRINTF(x, ...) /*LINTED null effect */(void)(Debug & (x) \ 157 1.7 plunky ? dbprintf(__FILE__, __func__, __LINE__, __VA_ARGS__) : ((void)0)) 158 1.1 christos #endif 159 1.1 christos 160 1.1 christos /* shortcuts for libevent */ 161 1.1 christos #define EVENT_ADD(x) do { \ 162 1.1 christos DPRINTF(D_EVENT, "event_add(%s@%p)\n", #x, x); \ 163 1.1 christos if (event_add(x, NULL) == -1) { \ 164 1.1 christos DPRINTF(D_EVENT, "Failure in event_add()\n"); \ 165 1.1 christos } \ 166 1.9 rillig } while (0) 167 1.1 christos #define RETRYEVENT_ADD(x) do { \ 168 1.1 christos struct timeval _tv; \ 169 1.1 christos _tv.tv_sec = 0; \ 170 1.1 christos _tv.tv_usec = TLS_RETRY_EVENT_USEC; \ 171 1.1 christos DPRINTF(D_EVENT, "retryevent_add(%s@%p)\n", #x, x); \ 172 1.1 christos if (event_add(x, &_tv) == -1) { \ 173 1.1 christos DPRINTF(D_EVENT, "Failure in event_add()\n"); \ 174 1.1 christos } \ 175 1.9 rillig } while (0) 176 1.1 christos #define DEL_EVENT(x) do { \ 177 1.1 christos DPRINTF(D_MEM2, "DEL_EVENT(%s@%p)\n", #x, x); \ 178 1.1 christos if ((x) && (event_del(x) == -1)) { \ 179 1.1 christos DPRINTF(D_EVENT, "Failure in event_del()\n"); \ 180 1.1 christos } \ 181 1.9 rillig } while (0) 182 1.1 christos 183 1.1 christos /* safe calls to free() */ 184 1.1 christos #define FREEPTR(x) if (x) { \ 185 1.1 christos DPRINTF(D_MEM2, "free(%s@%p)\n", #x, x); \ 186 1.1 christos free(x); x = NULL; } 187 1.1 christos #define FREE_SSL(x) if (x) { \ 188 1.1 christos DPRINTF(D_MEM2, "SSL_free(%s@%p)\n", #x, x); \ 189 1.1 christos SSL_free(x); x = NULL; } 190 1.1 christos #define FREE_SSL_CTX(x) if (x) { \ 191 1.1 christos DPRINTF(D_MEM2, "SSL_CTX_free(%s@%p)\n", #x, x); \ 192 1.1 christos SSL_CTX_free(x); x = NULL; } 193 1.1 christos 194 1.2 minskim /* reference counting macros for buffers */ 195 1.1 christos #define NEWREF(x) ((x) ? (DPRINTF(D_BUFFER, "inc refcount of " #x \ 196 1.1 christos " @ %p: %zu --> %zu\n", (x), (x)->refcount, \ 197 1.1 christos (x)->refcount + 1), (x)->refcount++, (x))\ 198 1.1 christos : (DPRINTF(D_BUFFER, "inc refcount of NULL!\n"), NULL)) 199 1.1 christos #define DELREF(x) /*LINTED null effect*/(void)((x) ? (DPRINTF(D_BUFFER, "dec refcount of " #x \ 200 1.1 christos " @ %p: %zu --> %zu\n", (x), (x)->refcount, \ 201 1.1 christos (x)->refcount - 1), buf_msg_free(x), NULL) \ 202 1.1 christos : (DPRINTF(D_BUFFER, "dec refcount of NULL!\n"), NULL)) 203 1.1 christos 204 1.2 minskim /* assumption: 205 1.1 christos * - malloc()/calloc() only fails if not enough memory available 206 1.1 christos * - once init() has set up all global variables etc. 207 1.1 christos * the bulk of available memory is used for buffers 208 1.1 christos * and can be freed if necessary 209 1.1 christos */ 210 1.1 christos #define MALLOC(ptr, size) do { \ 211 1.1 christos while(!(ptr = malloc(size))) { \ 212 1.1 christos DPRINTF(D_MEM, "Unable to allocate memory"); \ 213 1.1 christos message_allqueues_purge(); \ 214 1.1 christos } \ 215 1.1 christos DPRINTF(D_MEM2, "MALLOC(%s@%p, %zu)\n", #ptr, ptr, size); \ 216 1.9 rillig } while (0) 217 1.1 christos 218 1.1 christos #define CALLOC(ptr, size) do { \ 219 1.1 christos while(!(ptr = calloc(1, size))) { \ 220 1.1 christos DPRINTF(D_MEM, "Unable to allocate memory"); \ 221 1.1 christos message_allqueues_purge(); \ 222 1.1 christos } \ 223 1.1 christos DPRINTF(D_MEM2, "CALLOC(%s@%p, %zu)\n", #ptr, ptr, size); \ 224 1.9 rillig } while (0) 225 1.1 christos 226 1.1 christos /* define strlen(NULL) to be 0 */ 227 1.1 christos #define SAFEstrlen(x) ((x) ? strlen(x) : 0) 228 1.1 christos 229 1.1 christos /* shorthand to block/restore signals for the duration of one function */ 230 1.1 christos #define BLOCK_SIGNALS(omask, newmask) do { \ 231 1.1 christos sigemptyset(&newmask); \ 232 1.1 christos sigaddset(&newmask, SIGHUP); \ 233 1.1 christos sigaddset(&newmask, SIGALRM); \ 234 1.1 christos sigprocmask(SIG_BLOCK, &newmask, &omask); \ 235 1.9 rillig } while (0) 236 1.1 christos 237 1.1 christos #define RESTORE_SIGNALS(omask) sigprocmask(SIG_SETMASK, &omask, NULL) 238 1.1 christos 239 1.1 christos /* small optimization to call send_queue() only if queue has elements */ 240 1.1 christos #define SEND_QUEUE(f) do { \ 241 1.1 christos if ((f)->f_qelements) \ 242 1.1 christos send_queue(0, 0, f); \ 243 1.9 rillig } while (0) 244 1.1 christos 245 1.1 christos #define MAXUNAMES 20 /* maximum number of user names */ 246 1.8 mrg #define BSD_TIMESTAMPLEN (14+1) 247 1.8 mrg #define MAX_TIMESTAMPLEN (31+1) 248 1.1 christos 249 1.1 christos /* maximum field lengths in syslog-protocol */ 250 1.1 christos #define PRI_MAX 5 251 1.1 christos #define HOST_MAX 255 252 1.1 christos #define APPNAME_MAX 48 253 1.1 christos #define PROCID_MAX 128 254 1.1 christos #define MSGID_MAX 32 255 1.1 christos /* longest possible header length */ 256 1.1 christos #define HEADER_LEN_MAX (PRI_MAX + 1 + 1 + MAX_TIMESTAMPLEN + 1 + HOST_MAX \ 257 1.1 christos + 1 + APPNAME_MAX + 1 + PROCID_MAX + 1 + MSGID_MAX) 258 1.1 christos 259 1.1 christos /* allowed number of priorities by IETF standards */ 260 1.1 christos #define IETF_NUM_PRIVALUES 192 261 1.1 christos 262 1.2 minskim /* check if message with fac/sev belogs to a destination f */ 263 1.1 christos #define MATCH_PRI(f, fac, sev) \ 264 1.1 christos ( (((f)->f_pcmp[fac] & PRI_EQ) && ((f)->f_pmask[fac] == (sev))) \ 265 1.1 christos ||(((f)->f_pcmp[fac] & PRI_LT) && ((f)->f_pmask[fac] < (sev))) \ 266 1.1 christos ||(((f)->f_pcmp[fac] & PRI_GT) && ((f)->f_pmask[fac] > (sev))) \ 267 1.1 christos ) 268 1.1 christos 269 1.1 christos /* shorthand to test Byte Order Mark which indicates UTF-8 content */ 270 1.1 christos #define IS_BOM(p) ( \ 271 1.1 christos (p)[0] != '\0' && (unsigned char)(p)[0] == (unsigned char)0xEF && \ 272 1.1 christos (p)[1] != '\0' && (unsigned char)(p)[1] == (unsigned char)0xBB && \ 273 1.1 christos (p)[2] != '\0' && (unsigned char)(p)[2] == (unsigned char)0xBF) 274 1.1 christos 275 1.1 christos /* message buffer container used for processing, formatting, and queueing */ 276 1.1 christos struct buf_msg { 277 1.1 christos size_t refcount; 278 1.1 christos int pri; 279 1.1 christos int flags; 280 1.1 christos char *timestamp; 281 1.1 christos char *recvhost; 282 1.1 christos char *host; 283 1.1 christos char *prog; 284 1.1 christos char *pid; 285 1.1 christos char *msgid; 286 1.1 christos char *sd; /* structured data */ 287 1.1 christos char *msg; /* message content */ 288 1.1 christos char *msgorig; /* in case we advance *msg beyond header fields 289 1.1 christos we still want to free() the original ptr */ 290 1.1 christos size_t msglen; /* strlen(msg) */ 291 1.1 christos size_t msgsize; /* allocated memory size */ 292 1.1 christos size_t tlsprefixlen; /* bytes for the TLS length prefix */ 293 1.1 christos size_t prilen; /* bytes for priority and version */ 294 1.1 christos }; 295 1.1 christos 296 1.1 christos /* queue of messages */ 297 1.1 christos struct buf_queue { 298 1.1 christos struct buf_msg* msg; 299 1.1 christos STAILQ_ENTRY(buf_queue) entries; 300 1.1 christos }; 301 1.1 christos STAILQ_HEAD(buf_queue_head, buf_queue); 302 1.1 christos 303 1.1 christos /* a pair of a socket and an associated event object */ 304 1.1 christos struct socketEvent { 305 1.1 christos int fd; 306 1.4 christos int af; 307 1.1 christos struct event *ev; 308 1.1 christos }; 309 1.1 christos 310 1.1 christos /* 311 1.1 christos * Flags to logmsg(). 312 1.1 christos */ 313 1.1 christos #define IGN_CONS 0x001 /* don't print on console */ 314 1.1 christos #define SYNC_FILE 0x002 /* do fsync on file after printing */ 315 1.1 christos #define ADDDATE 0x004 /* add a date to the message */ 316 1.1 christos #define MARK 0x008 /* this message is a mark */ 317 1.1 christos #define ISKERNEL 0x010 /* kernel generated message */ 318 1.1 christos #define BSDSYSLOG 0x020 /* line in traditional BSD Syslog format */ 319 1.1 christos #define SIGN_MSG 0x040 /* syslog-sign data, not signed again */ 320 1.1 christos 321 1.1 christos /* strategies for message_queue_purge() */ 322 1.1 christos #define PURGE_OLDEST 1 323 1.1 christos #define PURGE_BY_PRIORITY 2 324 1.1 christos 325 1.1 christos /* 326 1.1 christos * This structure represents the files that will have log 327 1.1 christos * copies printed. 328 1.1 christos * We require f_file to be valid if f_type is F_FILE, F_CONSOLE, F_TTY, 329 1.1 christos * or if f_type is F_PIPE and f_pid > 0. 330 1.1 christos */ 331 1.1 christos 332 1.1 christos struct filed { 333 1.1 christos struct filed *f_next; /* next in linked list */ 334 1.1 christos short f_type; /* entry type, see below */ 335 1.1 christos short f_file; /* file descriptor */ 336 1.1 christos time_t f_time; /* time this was last written */ 337 1.1 christos char *f_host; /* host from which to record */ 338 1.1 christos u_char f_pmask[LOG_NFACILITIES+1]; /* priority mask */ 339 1.1 christos u_char f_pcmp[LOG_NFACILITIES+1]; /* compare priority */ 340 1.1 christos #define PRI_LT 0x1 341 1.1 christos #define PRI_EQ 0x2 342 1.1 christos #define PRI_GT 0x4 343 1.1 christos char *f_program; /* program this applies to */ 344 1.1 christos union { 345 1.1 christos char f_uname[MAXUNAMES][UT_NAMESIZE+1]; 346 1.1 christos struct { 347 1.1 christos char f_hname[MAXHOSTNAMELEN]; 348 1.1 christos struct addrinfo *f_addr; 349 1.1 christos } f_forw; /* UDP forwarding address */ 350 1.1 christos #ifndef DISABLE_TLS 351 1.1 christos struct { 352 1.1 christos SSL *ssl; /* SSL object */ 353 1.2 minskim struct tls_conn_settings *tls_conn; /* certificate info */ 354 1.1 christos } f_tls; /* TLS forwarding address */ 355 1.1 christos #endif /* !DISABLE_TLS */ 356 1.1 christos char f_fname[MAXPATHLEN]; 357 1.1 christos struct { 358 1.1 christos char f_pname[MAXPATHLEN]; 359 1.1 christos pid_t f_pid; 360 1.1 christos } f_pipe; 361 1.1 christos } f_un; 362 1.1 christos #ifndef DISABLE_SIGN 363 1.1 christos struct signature_group_t *f_sg; /* one signature group */ 364 1.1 christos #endif /* !DISABLE_SIGN */ 365 1.1 christos struct buf_queue_head f_qhead; /* undelivered msgs queue */ 366 1.1 christos size_t f_qelements; /* elements in queue */ 367 1.1 christos size_t f_qsize; /* size of queue in bytes */ 368 1.1 christos struct buf_msg *f_prevmsg; /* last message logged */ 369 1.1 christos struct event *f_sq_event; /* timer for send_queue() */ 370 1.1 christos int f_prevcount; /* repetition cnt of prevmsg */ 371 1.1 christos int f_repeatcount; /* number of "repeated" msgs */ 372 1.1 christos int f_lasterror; /* last error on writev() */ 373 1.1 christos int f_flags; /* file-specific flags */ 374 1.1 christos #define FFLAG_SYNC 0x01 /* for F_FILE: fsync after every msg */ 375 1.1 christos #define FFLAG_FULL 0x02 /* for F_FILE | F_PIPE: write PRI header */ 376 1.1 christos #define FFLAG_SIGN 0x04 /* for syslog-sign with SG="3": 377 1.1 christos * sign the messages to this destination */ 378 1.1 christos }; 379 1.1 christos 380 1.1 christos #ifndef DISABLE_TLS 381 1.1 christos 382 1.1 christos /* linked list for allowed TLS peer credentials 383 1.1 christos * (one for fingerprint, one for cert-files) 384 1.1 christos */ 385 1.1 christos SLIST_HEAD(peer_cred_head, peer_cred); 386 1.1 christos struct peer_cred { 387 1.1 christos SLIST_ENTRY(peer_cred) entries; 388 1.1 christos char *data; 389 1.1 christos }; 390 1.1 christos 391 1.1 christos /* config options for TLS server-side */ 392 1.1 christos struct tls_global_options_t { 393 1.1 christos SSL_CTX *global_TLS_CTX; 394 1.1 christos struct peer_cred_head fprint_head; /* trusted client fingerprints */ 395 1.1 christos struct peer_cred_head cert_head; /* trusted client cert files */ 396 1.1 christos char *keyfile; /* file with private key */ 397 1.1 christos char *certfile; /* file with own certificate */ 398 1.1 christos char *CAfile; /* file with CA certificate */ 399 1.1 christos char *CAdir; /* alternative: path to directory with CA certs */ 400 1.1 christos char *x509verify; /* level of peer verification */ 401 1.2 minskim char *bindhost; /* hostname/IP to bind to */ 402 1.1 christos char *bindport; /* port/service to bind to */ 403 1.1 christos char *server; /* if !NULL: do not listen to incoming TLS */ 404 1.1 christos char *gen_cert; /* if !NULL: generate self-signed certificate */ 405 1.1 christos }; 406 1.1 christos 407 1.1 christos /* TLS needs three sets of sockets: 408 1.1 christos * - listening sockets: a fixed size array TLS_Listen_Set, just like finet for UDP. 409 1.1 christos * - outgoing connections: managed as part of struct filed. 410 1.1 christos * - incoming connections: variable sized, thus a linked list TLS_Incoming. 411 1.1 christos */ 412 1.1 christos /* every connection has its own input buffer with status 413 1.1 christos * variables for message reading */ 414 1.1 christos SLIST_HEAD(TLS_Incoming, TLS_Incoming_Conn); 415 1.2 minskim 416 1.1 christos struct TLS_Incoming_Conn { 417 1.1 christos SLIST_ENTRY(TLS_Incoming_Conn) entries; 418 1.1 christos struct tls_conn_settings *tls_conn; 419 1.1 christos int socket; 420 1.1 christos char *inbuf; /* input buffer */ 421 1.1 christos size_t inbuflen; 422 1.1 christos size_t cur_msg_len; /* length of current msg */ 423 1.1 christos size_t cur_msg_start; /* beginning of current msg */ 424 1.1 christos size_t read_pos; /* ring buffer position to write to */ 425 1.1 christos size_t errorcount; /* to close faulty connections */ 426 1.1 christos bool closenow; /* close connection as soon as buffer processed */ 427 1.1 christos bool dontsave; /* for receiving oversized messages w/o saving them */ 428 1.1 christos }; 429 1.1 christos 430 1.1 christos #endif /* !DISABLE_TLS */ 431 1.1 christos 432 1.1 christos #endif /*SYSLOGD_H_*/ 433