2 * Copyright (c) 1997-2005 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 /* Should we enable the HTTP hack? */
39 /* Log over requests to the KDC */
40 const char *request_log
;
42 /* A string describing on what ports to listen */
45 krb5_addresses explicit_addresses
;
47 size_t max_request_udp
;
48 size_t max_request_tcp
;
51 * a tuple describing on what to listen
60 /* the current ones */
62 static struct port_desc
*ports
;
66 * add `family, port, protocol' to the list with duplicate suppresion.
70 add_port(krb5_context context
,
71 int family
, int port
, const char *protocol
)
76 if(strcmp(protocol
, "udp") == 0)
78 else if(strcmp(protocol
, "tcp") == 0)
82 for(i
= 0; i
< num_ports
; i
++){
83 if(ports
[i
].type
== type
84 && ports
[i
].port
== port
85 && ports
[i
].family
== family
)
88 ports
= realloc(ports
, (num_ports
+ 1) * sizeof(*ports
));
90 krb5_err (context
, 1, errno
, "realloc");
91 ports
[num_ports
].family
= family
;
92 ports
[num_ports
].type
= type
;
93 ports
[num_ports
].port
= port
;
98 * add a triple but with service -> port lookup
99 * (this prints warnings for stuff that does not exist)
103 add_port_service(krb5_context context
,
104 int family
, const char *service
, int port
,
105 const char *protocol
)
107 port
= krb5_getportbyname (context
, service
, protocol
, port
);
108 add_port (context
, family
, port
, protocol
);
112 * add the port with service -> port lookup or string -> number
113 * (no warning is printed)
117 add_port_string (krb5_context context
,
118 int family
, const char *str
, const char *protocol
)
123 sp
= roken_getservbyname (str
, protocol
);
129 port
= htons(strtol(str
, &end
, 0));
133 add_port (context
, family
, port
, protocol
);
137 * add the standard collection of ports for `family'
141 add_standard_ports (krb5_context context
,
142 krb5_kdc_configuration
*config
,
145 add_port_service(context
, family
, "kerberos", 88, "udp");
146 add_port_service(context
, family
, "kerberos", 88, "tcp");
147 add_port_service(context
, family
, "kerberos-sec", 88, "udp");
148 add_port_service(context
, family
, "kerberos-sec", 88, "tcp");
150 add_port_service(context
, family
, "http", 80, "tcp");
151 if(config
->enable_524
) {
152 add_port_service(context
, family
, "krb524", 4444, "udp");
153 add_port_service(context
, family
, "krb524", 4444, "tcp");
155 if(config
->enable_v4
) {
156 add_port_service(context
, family
, "kerberos-iv", 750, "udp");
157 add_port_service(context
, family
, "kerberos-iv", 750, "tcp");
159 if (config
->enable_kaserver
)
160 add_port_service(context
, family
, "afs3-kaserver", 7004, "udp");
161 if(config
->enable_kx509
) {
162 add_port_service(context
, family
, "kca_service", 9878, "udp");
163 add_port_service(context
, family
, "kca_service", 9878, "tcp");
169 * parse the set of space-delimited ports in `str' and add them.
170 * "+" => all the standard ones
171 * otherwise it's port|service[/protocol]
175 parse_ports(krb5_context context
,
176 krb5_kdc_configuration
*config
,
181 char *str_copy
= strdup (str
);
183 p
= strtok_r(str_copy
, " \t", &pos
);
185 if(strcmp(p
, "+") == 0) {
187 add_standard_ports(context
, config
, AF_INET6
);
189 add_standard_ports(context
, config
, AF_INET
);
191 char *q
= strchr(p
, '/');
195 add_port_string(context
, AF_INET6
, p
, q
);
197 add_port_string(context
, AF_INET
, p
, q
);
200 add_port_string(context
, AF_INET6
, p
, "udp");
201 add_port_string(context
, AF_INET6
, p
, "tcp");
203 add_port_string(context
, AF_INET
, p
, "udp");
204 add_port_string(context
, AF_INET
, p
, "tcp");
208 p
= strtok_r(NULL
, " \t", &pos
);
214 * every socket we listen on
225 struct sockaddr_storage __ss
;
228 char addr_string
[128];
232 init_descr(struct descr
*d
)
234 memset(d
, 0, sizeof(*d
));
235 d
->sa
= (struct sockaddr
*)&d
->__ss
;
236 d
->s
= rk_INVALID_SOCKET
;
240 * re-initialize all `n' ->sa in `d'.
244 reinit_descrs (struct descr
*d
, int n
)
248 for (i
= 0; i
< n
; ++i
)
249 d
[i
].sa
= (struct sockaddr
*)&d
[i
].__ss
;
253 * Create the socket (family, type, port) in `d'
257 init_socket(krb5_context context
,
258 krb5_kdc_configuration
*config
,
259 struct descr
*d
, krb5_address
*a
, int family
, int type
, int port
)
262 struct sockaddr_storage __ss
;
263 struct sockaddr
*sa
= (struct sockaddr
*)&__ss
;
264 krb5_socklen_t sa_size
= sizeof(__ss
);
268 ret
= krb5_addr2sockaddr (context
, a
, sa
, &sa_size
, port
);
270 krb5_warn(context
, ret
, "krb5_addr2sockaddr");
271 rk_closesocket(d
->s
);
272 d
->s
= rk_INVALID_SOCKET
;
276 if (sa
->sa_family
!= family
)
279 d
->s
= socket(family
, type
, 0);
280 if(rk_IS_BAD_SOCKET(d
->s
)){
281 krb5_warn(context
, errno
, "socket(%d, %d, 0)", family
, type
);
282 d
->s
= rk_INVALID_SOCKET
;
285 #if defined(HAVE_SETSOCKOPT) && defined(SOL_SOCKET) && defined(SO_REUSEADDR)
288 setsockopt(d
->s
, SOL_SOCKET
, SO_REUSEADDR
, (void *)&one
, sizeof(one
));
294 if(rk_IS_SOCKET_ERROR(bind(d
->s
, sa
, sa_size
))){
298 krb5_print_address (a
, a_str
, sizeof(a_str
), &len
);
299 krb5_warn(context
, errno
, "bind %s/%d", a_str
, ntohs(port
));
300 rk_closesocket(d
->s
);
301 d
->s
= rk_INVALID_SOCKET
;
304 if(type
== SOCK_STREAM
&& rk_IS_SOCKET_ERROR(listen(d
->s
, SOMAXCONN
))){
308 krb5_print_address (a
, a_str
, sizeof(a_str
), &len
);
309 krb5_warn(context
, errno
, "listen %s/%d", a_str
, ntohs(port
));
310 rk_closesocket(d
->s
);
311 d
->s
= rk_INVALID_SOCKET
;
317 * Allocate descriptors for all the sockets that we should listen on
318 * and return the number of them.
322 init_sockets(krb5_context context
,
323 krb5_kdc_configuration
*config
,
330 krb5_addresses addresses
;
332 if (explicit_addresses
.len
) {
333 addresses
= explicit_addresses
;
335 ret
= krb5_get_all_server_addrs (context
, &addresses
);
337 krb5_err (context
, 1, ret
, "krb5_get_all_server_addrs");
339 parse_ports(context
, config
, port_str
);
340 d
= malloc(addresses
.len
* num_ports
* sizeof(*d
));
342 krb5_errx(context
, 1, "malloc(%lu) failed",
343 (unsigned long)num_ports
* sizeof(*d
));
345 for (i
= 0; i
< num_ports
; i
++){
346 for (j
= 0; j
< addresses
.len
; ++j
) {
347 init_socket(context
, config
, &d
[num
], &addresses
.val
[j
],
348 ports
[i
].family
, ports
[i
].type
, ports
[i
].port
);
349 if(d
[num
].s
!= rk_INVALID_SOCKET
){
353 krb5_print_address (&addresses
.val
[j
], a_str
,
354 sizeof(a_str
), &len
);
356 kdc_log(context
, config
, 5, "listening on %s port %u/%s",
358 ntohs(ports
[i
].port
),
359 (ports
[i
].type
== SOCK_STREAM
) ? "tcp" : "udp");
365 krb5_free_addresses (context
, &addresses
);
366 d
= realloc(d
, num
* sizeof(*d
));
367 if (d
== NULL
&& num
!= 0)
368 krb5_errx(context
, 1, "realloc(%lu) failed",
369 (unsigned long)num
* sizeof(*d
));
370 reinit_descrs (d
, num
);
380 descr_type(struct descr
*d
)
382 if (d
->type
== SOCK_DGRAM
)
384 else if (d
->type
== SOCK_STREAM
)
390 addr_to_string(krb5_context context
,
391 struct sockaddr
*addr
, size_t addr_len
, char *str
, size_t len
)
394 if(krb5_sockaddr2address(context
, addr
, &a
) == 0) {
395 if(krb5_print_address(&a
, str
, len
, &len
) == 0) {
396 krb5_free_address(context
, &a
);
399 krb5_free_address(context
, &a
);
401 snprintf(str
, len
, "<family=%d>", addr
->sa_family
);
409 send_reply(krb5_context context
,
410 krb5_kdc_configuration
*config
,
411 krb5_boolean prependlength
,
415 kdc_log(context
, config
, 5,
416 "sending %lu bytes to %s", (unsigned long)reply
->length
,
420 l
[0] = (reply
->length
>> 24) & 0xff;
421 l
[1] = (reply
->length
>> 16) & 0xff;
422 l
[2] = (reply
->length
>> 8) & 0xff;
423 l
[3] = reply
->length
& 0xff;
424 if(rk_IS_SOCKET_ERROR(sendto(d
->s
, l
, sizeof(l
), 0, d
->sa
, d
->sock_len
))) {
425 kdc_log (context
, config
,
426 0, "sendto(%s): %s", d
->addr_string
,
427 strerror(rk_SOCK_ERRNO
));
431 if(rk_IS_SOCKET_ERROR(sendto(d
->s
, reply
->data
, reply
->length
, 0, d
->sa
, d
->sock_len
))) {
432 kdc_log (context
, config
, 0, "sendto(%s): %s", d
->addr_string
,
433 strerror(rk_SOCK_ERRNO
));
439 * Handle the request in `buf, len' to socket `d'
443 do_request(krb5_context context
,
444 krb5_kdc_configuration
*config
,
445 void *buf
, size_t len
, krb5_boolean prependlength
,
450 int datagram_reply
= (d
->type
== SOCK_DGRAM
);
452 krb5_kdc_update_time(NULL
);
454 krb5_data_zero(&reply
);
455 ret
= krb5_kdc_process_request(context
, config
,
456 buf
, len
, &reply
, &prependlength
,
457 d
->addr_string
, d
->sa
,
460 krb5_kdc_save_request(context
, request_log
, buf
, len
, &reply
, d
->sa
);
462 send_reply(context
, config
, prependlength
, d
, &reply
);
463 krb5_data_free(&reply
);
466 kdc_log(context
, config
, 0,
467 "Failed processing %lu byte request from %s",
468 (unsigned long)len
, d
->addr_string
);
472 * Handle incoming data to the UDP socket in `d'
476 handle_udp(krb5_context context
,
477 krb5_kdc_configuration
*config
,
483 buf
= malloc(max_request_udp
);
485 kdc_log(context
, config
, 0, "Failed to allocate %lu bytes", (unsigned long)max_request_udp
);
489 d
->sock_len
= sizeof(d
->__ss
);
490 n
= recvfrom(d
->s
, buf
, max_request_udp
, 0, d
->sa
, &d
->sock_len
);
491 if(rk_IS_SOCKET_ERROR(n
))
492 krb5_warn(context
, rk_SOCK_ERRNO
, "recvfrom");
494 addr_to_string (context
, d
->sa
, d
->sock_len
,
495 d
->addr_string
, sizeof(d
->addr_string
));
496 if (n
== max_request_udp
) {
498 krb5_warn(context
, errno
,
499 "recvfrom: truncated packet from %s, asking for TCP",
501 krb5_mk_error(context
,
502 KRB5KRB_ERR_RESPONSE_TOO_BIG
,
510 send_reply(context
, config
, FALSE
, d
, &data
);
511 krb5_data_free(&data
);
513 do_request(context
, config
, buf
, n
, FALSE
, d
);
520 clear_descr(struct descr
*d
)
523 memset(d
->buf
, 0, d
->size
);
525 if(d
->s
!= rk_INVALID_SOCKET
)
526 rk_closesocket(d
->s
);
527 d
->s
= rk_INVALID_SOCKET
;
531 /* remove HTTP %-quoting from buf */
535 unsigned char *p
, *q
;
536 for(p
= q
= (unsigned char *)buf
; *p
; p
++, q
++) {
537 if(*p
== '%' && isxdigit(p
[1]) && isxdigit(p
[2])) {
539 if(sscanf((char *)p
+ 1, "%2x", &x
) != 1)
550 #define TCP_TIMEOUT 4
553 * accept a new TCP connection on `d[parent]' and store it in `d[child]'
557 add_new_tcp (krb5_context context
,
558 krb5_kdc_configuration
*config
,
559 struct descr
*d
, int parent
, int child
)
566 d
[child
].sock_len
= sizeof(d
[child
].__ss
);
567 s
= accept(d
[parent
].s
, d
[child
].sa
, &d
[child
].sock_len
);
568 if(rk_IS_BAD_SOCKET(s
)) {
569 krb5_warn(context
, rk_SOCK_ERRNO
, "accept");
574 if (s
>= FD_SETSIZE
) {
575 krb5_warnx(context
, "socket FD too large");
582 d
[child
].timeout
= time(NULL
) + TCP_TIMEOUT
;
583 d
[child
].type
= SOCK_STREAM
;
584 addr_to_string (context
,
585 d
[child
].sa
, d
[child
].sock_len
,
586 d
[child
].addr_string
, sizeof(d
[child
].addr_string
));
590 * Grow `d' to handle at least `n'.
591 * Return != 0 if fails
595 grow_descr (krb5_context context
,
596 krb5_kdc_configuration
*config
,
597 struct descr
*d
, size_t n
)
599 if (d
->size
- d
->len
< n
) {
603 grow
= max(1024, d
->len
+ n
);
604 if (d
->size
+ grow
> max_request_tcp
) {
605 kdc_log(context
, config
, 0, "Request exceeds max request size (%lu bytes).",
606 (unsigned long)d
->size
+ grow
);
610 tmp
= realloc (d
->buf
, d
->size
+ grow
);
612 kdc_log(context
, config
, 0, "Failed to re-allocate %lu bytes.",
613 (unsigned long)d
->size
+ grow
);
624 * Try to handle the TCP data at `d->buf, d->len'.
625 * Return -1 if failed, 0 if succesful, and 1 if data is complete.
629 handle_vanilla_tcp (krb5_context context
,
630 krb5_kdc_configuration
*config
,
636 sp
= krb5_storage_from_mem(d
->buf
, d
->len
);
638 kdc_log (context
, config
, 0, "krb5_storage_from_mem failed");
641 krb5_ret_uint32(sp
, &len
);
642 krb5_storage_free(sp
);
643 if(d
->len
- 4 >= len
) {
644 memmove(d
->buf
, d
->buf
+ 4, d
->len
- 4);
652 * Try to handle the TCP/HTTP data at `d->buf, d->len'.
653 * Return -1 if failed, 0 if succesful, and 1 if data is complete.
657 handle_http_tcp (krb5_context context
,
658 krb5_kdc_configuration
*config
,
668 /* If its a multi line query, truncate off the first line */
669 p
= strstr(s
, "\r\n");
674 t
= strtok_r(s
, " \t", &p
);
676 kdc_log(context
, config
, 0,
677 "Missing HTTP operand (GET) request from %s", d
->addr_string
);
681 t
= strtok_r(NULL
, " \t", &p
);
683 kdc_log(context
, config
, 0,
684 "Missing HTTP GET data in request from %s", d
->addr_string
);
688 data
= malloc(strlen(t
));
690 kdc_log(context
, config
, 0, "Failed to allocate %lu bytes",
691 (unsigned long)strlen(t
));
696 if(de_http(t
) != 0) {
697 kdc_log(context
, config
, 0, "Malformed HTTP request from %s", d
->addr_string
);
698 kdc_log(context
, config
, 5, "HTTP request: %s", t
);
702 proto
= strtok_r(NULL
, " \t", &p
);
704 kdc_log(context
, config
, 0, "Malformed HTTP request from %s", d
->addr_string
);
708 len
= base64_decode(t
, data
);
712 "Server: Heimdal/" VERSION
"\r\n"
713 "Cache-Control: no-cache\r\n"
714 "Pragma: no-cache\r\n"
715 "Content-type: text/html\r\n"
716 "Content-transfer-encoding: 8bit\r\n\r\n"
717 "<TITLE>404 Not found</TITLE>\r\n"
718 "<H1>404 Not found</H1>\r\n"
719 "That page doesn't exist, maybe you are looking for "
720 "<A HREF=\"http://www.h5l.org/\">Heimdal</A>?\r\n";
721 kdc_log(context
, config
, 0, "HTTP request from %s is non KDC request", d
->addr_string
);
722 kdc_log(context
, config
, 5, "HTTP request: %s", t
);
724 if (rk_IS_SOCKET_ERROR(send(d
->s
, proto
, strlen(proto
), 0))) {
725 kdc_log(context
, config
, 0, "HTTP write failed: %s: %s",
726 d
->addr_string
, strerror(rk_SOCK_ERRNO
));
729 if (rk_IS_SOCKET_ERROR(send(d
->s
, msg
, strlen(msg
), 0))) {
730 kdc_log(context
, config
, 0, "HTTP write failed: %s: %s",
731 d
->addr_string
, strerror(rk_SOCK_ERRNO
));
739 "Server: Heimdal/" VERSION
"\r\n"
740 "Cache-Control: no-cache\r\n"
741 "Pragma: no-cache\r\n"
742 "Content-type: application/octet-stream\r\n"
743 "Content-transfer-encoding: binary\r\n\r\n";
744 if (rk_IS_SOCKET_ERROR(send(d
->s
, proto
, strlen(proto
), 0))) {
746 kdc_log(context
, config
, 0, "HTTP write failed: %s: %s",
747 d
->addr_string
, strerror(rk_SOCK_ERRNO
));
750 if (rk_IS_SOCKET_ERROR(send(d
->s
, msg
, strlen(msg
), 0))) {
752 kdc_log(context
, config
, 0, "HTTP write failed: %s: %s",
753 d
->addr_string
, strerror(rk_SOCK_ERRNO
));
759 memcpy(d
->buf
, data
, len
);
766 * Handle incoming data to the TCP socket in `d[index]'
770 handle_tcp(krb5_context context
,
771 krb5_kdc_configuration
*config
,
772 struct descr
*d
, int idx
, int min_free
)
774 unsigned char buf
[1024];
778 if (d
[idx
].timeout
== 0) {
779 add_new_tcp (context
, config
, d
, idx
, min_free
);
783 n
= recvfrom(d
[idx
].s
, buf
, sizeof(buf
), 0, NULL
, NULL
);
784 if(rk_IS_SOCKET_ERROR(n
)){
785 krb5_warn(context
, rk_SOCK_ERRNO
, "recvfrom failed from %s to %s/%d",
786 d
[idx
].addr_string
, descr_type(d
+ idx
),
790 krb5_warnx(context
, "connection closed before end of data after %lu "
791 "bytes from %s to %s/%d", (unsigned long)d
[idx
].len
,
792 d
[idx
].addr_string
, descr_type(d
+ idx
),
794 clear_descr (d
+ idx
);
797 if (grow_descr (context
, config
, &d
[idx
], n
))
799 memcpy(d
[idx
].buf
+ d
[idx
].len
, buf
, n
);
801 if(d
[idx
].len
> 4 && d
[idx
].buf
[0] == 0) {
802 ret
= handle_vanilla_tcp (context
, config
, &d
[idx
]);
803 } else if(enable_http
&&
805 strncmp((char *)d
[idx
].buf
, "GET ", 4) == 0 &&
806 strncmp((char *)d
[idx
].buf
+ d
[idx
].len
- 4,
807 "\r\n\r\n", 4) == 0) {
809 /* remove the trailing \r\n\r\n so the string is NUL terminated */
810 d
[idx
].buf
[d
[idx
].len
- 4] = '\0';
812 ret
= handle_http_tcp (context
, config
, &d
[idx
]);
814 clear_descr (d
+ idx
);
815 } else if (d
[idx
].len
> 4) {
816 kdc_log (context
, config
,
817 0, "TCP data of strange type from %s to %s/%d",
818 d
[idx
].addr_string
, descr_type(d
+ idx
),
820 if (d
[idx
].buf
[0] & 0x80) {
823 kdc_log (context
, config
, 0, "TCP extension not supported");
825 ret
= krb5_mk_error(context
,
826 KRB5KRB_ERR_FIELD_TOOLONG
,
835 send_reply(context
, config
, TRUE
, d
+ idx
, &reply
);
836 krb5_data_free(&reply
);
839 clear_descr(d
+ idx
);
845 do_request(context
, config
,
846 d
[idx
].buf
, d
[idx
].len
, TRUE
, &d
[idx
]);
847 clear_descr(d
+ idx
);
852 loop(krb5_context context
,
853 krb5_kdc_configuration
*config
)
858 ndescr
= init_sockets(context
, config
, &d
);
860 krb5_errx(context
, 1, "No sockets!");
861 kdc_log(context
, config
, 0, "KDC started");
862 while(exit_flag
== 0){
863 struct timeval tmout
;
870 for(i
= 0; i
< ndescr
; i
++) {
871 if(!rk_IS_BAD_SOCKET(d
[i
].s
)){
872 if(d
[i
].type
== SOCK_STREAM
&&
873 d
[i
].timeout
&& d
[i
].timeout
< time(NULL
)) {
874 kdc_log(context
, config
, 1,
875 "TCP-connection from %s expired after %lu bytes",
876 d
[i
].addr_string
, (unsigned long)d
[i
].len
);
880 #ifndef NO_LIMIT_FD_SETSIZE
884 if (max_fd
>= FD_SETSIZE
)
885 krb5_errx(context
, 1, "fd too large");
888 FD_SET(d
[i
].s
, &fds
);
889 } else if(min_free
< 0 || i
< min_free
)
894 tmp
= realloc(d
, (ndescr
+ 4) * sizeof(*d
));
896 krb5_warnx(context
, "No memory");
899 reinit_descrs (d
, ndescr
);
900 memset(d
+ ndescr
, 0, 4 * sizeof(*d
));
901 for(i
= ndescr
; i
< ndescr
+ 4; i
++)
908 tmout
.tv_sec
= TCP_TIMEOUT
;
910 switch(select(max_fd
+ 1, &fds
, 0, 0, &tmout
)){
915 krb5_warn(context
, rk_SOCK_ERRNO
, "select");
918 for(i
= 0; i
< ndescr
; i
++)
919 if(!rk_IS_BAD_SOCKET(d
[i
].s
) && FD_ISSET(d
[i
].s
, &fds
)) {
920 if(d
[i
].type
== SOCK_DGRAM
)
921 handle_udp(context
, config
, &d
[i
]);
922 else if(d
[i
].type
== SOCK_STREAM
)
923 handle_tcp(context
, config
, d
, i
, min_free
);
929 else if(exit_flag
== SIGXCPU
)
930 kdc_log(context
, config
, 0, "CPU time limit exceeded");
932 else if(exit_flag
== SIGINT
|| exit_flag
== SIGTERM
)
933 kdc_log(context
, config
, 0, "Terminated");
935 kdc_log(context
, config
, 0, "Unexpected exit reason: %d", exit_flag
);