Deleted Added
full compact
daemon.c (157001) daemon.c (159609)
1/*
2 * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
4 * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
5 * Copyright (c) 1988, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * By using this file, you agree to the terms and conditions set
9 * forth in the LICENSE file which can be found at the top level of
10 * the sendmail distribution.
11 *
12 */
13
14#include <sendmail.h>
15
1/*
2 * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
4 * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
5 * Copyright (c) 1988, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * By using this file, you agree to the terms and conditions set
9 * forth in the LICENSE file which can be found at the top level of
10 * the sendmail distribution.
11 *
12 */
13
14#include <sendmail.h>
15
16SM_RCSID("@(#)$Id: daemon.c,v 8.665 2006/03/02 19:12:00 ca Exp $")
16SM_RCSID("@(#)$Id: daemon.c,v 8.666 2006/04/18 01:23:42 ca Exp $")
17
18#if defined(SOCK_STREAM) || defined(__GNU_LIBRARY__)
19# define USE_SOCK_STREAM 1
20#endif /* defined(SOCK_STREAM) || defined(__GNU_LIBRARY__) */
21
22#if defined(USE_SOCK_STREAM)
23# if NETINET || NETINET6
24# include <arpa/inet.h>

--- 490 unchanged lines hidden (view full) ---

515#ifdef EWOULDBLOCK
516 || save_errno == EWOULDBLOCK
517#endif /* EWOULDBLOCK */
518 )
519 continue;
520
521 syserr("getrequests: accept");
522
17
18#if defined(SOCK_STREAM) || defined(__GNU_LIBRARY__)
19# define USE_SOCK_STREAM 1
20#endif /* defined(SOCK_STREAM) || defined(__GNU_LIBRARY__) */
21
22#if defined(USE_SOCK_STREAM)
23# if NETINET || NETINET6
24# include <arpa/inet.h>

--- 490 unchanged lines hidden (view full) ---

515#ifdef EWOULDBLOCK
516 || save_errno == EWOULDBLOCK
517#endif /* EWOULDBLOCK */
518 )
519 continue;
520
521 syserr("getrequests: accept");
522
523 /* arrange to re-open the socket next time around */
524 (void) close(Daemons[curdaemon].d_socket);
525 Daemons[curdaemon].d_socket = -1;
523 if (curdaemon >= 0)
524 {
525 /* arrange to re-open socket next time around */
526 (void) close(Daemons[curdaemon].d_socket);
527 Daemons[curdaemon].d_socket = -1;
526#if SO_REUSEADDR_IS_BROKEN
528#if SO_REUSEADDR_IS_BROKEN
527 /*
528 ** Give time for bound socket to be released.
529 ** This creates a denial-of-service if you can
530 ** force accept() to fail on affected systems.
531 */
529 /*
530 ** Give time for bound socket to be released.
531 ** This creates a denial-of-service if you can
532 ** force accept() to fail on affected systems.
533 */
532
534
533 Daemons[curdaemon].d_refuse_connections_until = curtime() + 15;
535 Daemons[curdaemon].d_refuse_connections_until =
536 curtime() + 15;
534#endif /* SO_REUSEADDR_IS_BROKEN */
537#endif /* SO_REUSEADDR_IS_BROKEN */
538 }
535 continue;
536 }
537
538 if (!control)
539 {
540 /* set some daemon related macros */
541 switch (Daemons[curdaemon].d_addr.sa.sa_family)
542 {

--- 1535 unchanged lines hidden (view full) ---

2078{
2079 register volatile int addrno = 0;
2080 volatile int s;
2081 register struct hostent *volatile hp = (struct hostent *) NULL;
2082 SOCKADDR addr;
2083 SOCKADDR clt_addr;
2084 int save_errno = 0;
2085 volatile SOCKADDR_LEN_T addrlen;
539 continue;
540 }
541
542 if (!control)
543 {
544 /* set some daemon related macros */
545 switch (Daemons[curdaemon].d_addr.sa.sa_family)
546 {

--- 1535 unchanged lines hidden (view full) ---

2082{
2083 register volatile int addrno = 0;
2084 volatile int s;
2085 register struct hostent *volatile hp = (struct hostent *) NULL;
2086 SOCKADDR addr;
2087 SOCKADDR clt_addr;
2088 int save_errno = 0;
2089 volatile SOCKADDR_LEN_T addrlen;
2086 volatile bool firstconnect;
2090 volatile bool firstconnect = true;
2087 SM_EVENT *volatile ev = NULL;
2088#if NETINET6
2089 volatile bool v6found = false;
2090#endif /* NETINET6 */
2091 volatile int family = InetMode;
2092 SOCKADDR_LEN_T len;
2093 volatile SOCKADDR_LEN_T socksize = 0;
2094 volatile bool clt_bind;

--- 386 unchanged lines hidden (view full) ---

2481# if NETINET6
2482 if (hp != NULL)
2483 freehostent(hp);
2484# endif /* NETINET6 */
2485 return EX_TEMPFAIL;
2486 }
2487#endif /* XLA */
2488
2091 SM_EVENT *volatile ev = NULL;
2092#if NETINET6
2093 volatile bool v6found = false;
2094#endif /* NETINET6 */
2095 volatile int family = InetMode;
2096 SOCKADDR_LEN_T len;
2097 volatile SOCKADDR_LEN_T socksize = 0;
2098 volatile bool clt_bind;

--- 386 unchanged lines hidden (view full) ---

2485# if NETINET6
2486 if (hp != NULL)
2487 freehostent(hp);
2488# endif /* NETINET6 */
2489 return EX_TEMPFAIL;
2490 }
2491#endif /* XLA */
2492
2489 firstconnect = true;
2490 for (;;)
2491 {
2492 if (tTd(16, 1))
2493 sm_dprintf("makeconnection (%s [%s].%d (%d))\n",
2494 host, anynet_ntoa(&addr), ntohs(port),
2495 (int) addr.sa.sa_family);
2496
2497 /* save for logging */

--- 1956 unchanged lines hidden ---
2493 for (;;)
2494 {
2495 if (tTd(16, 1))
2496 sm_dprintf("makeconnection (%s [%s].%d (%d))\n",
2497 host, anynet_ntoa(&addr), ntohs(port),
2498 (int) addr.sa.sa_family);
2499
2500 /* save for logging */

--- 1956 unchanged lines hidden ---