Deleted Added
full compact
daemon.c (141858) daemon.c (147078)
1/*
1/*
2 * Copyright (c) 1998-2004 Sendmail, Inc. and its suppliers.
2 * Copyright (c) 1998-2005 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
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.653 2004/11/18 23:45:01 ca Exp $")
16SM_RCSID("@(#)$Id: daemon.c,v 8.658 2005/02/02 18:19:28 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>

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

72 int d_socksize;
73 BITMAP256 d_flags; /* flags; see sendmail.h */
74 char *d_mflags; /* flags for use in macro */
75 char *d_name; /* user-supplied name */
76#if MILTER
77 char *d_inputfilterlist;
78 struct milter *d_inputfilters[MAXFILTERS];
79#endif /* MILTER */
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>

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

72 int d_socksize;
73 BITMAP256 d_flags; /* flags; see sendmail.h */
74 char *d_mflags; /* flags for use in macro */
75 char *d_name; /* user-supplied name */
76#if MILTER
77 char *d_inputfilterlist;
78 struct milter *d_inputfilters[MAXFILTERS];
79#endif /* MILTER */
80#if _FFR_SS_PER_DAEMON
81 int d_supersafe;
82#endif /* _FFR_SS_PER_DAEMON */
83#if _FFR_DM_PER_DAEMON
84 int d_dm; /* DeliveryMode */
85#endif /* _FFR_DM_PER_DAEMON */
80};
81
82typedef struct daemon DAEMON_T;
83
86};
87
88typedef struct daemon DAEMON_T;
89
90#define SAFE_NOTSET (-1) /* SuperSafe (per daemon) option not set */
91/* see also sendmail.h: SuperSafe values */
92
93#define DM_NOTSET (-1) /* DeliveryMode (per daemon) option not set */
94/* see also sendmail.h: values for e_sendmode -- send modes */
95
84static void connecttimeout __P((int));
85static int opendaemonsocket __P((DAEMON_T *, bool));
86static unsigned short setupdaemon __P((SOCKADDR *));
87static void getrequests_checkdiskspace __P((ENVELOPE *e));
88static void setsockaddroptions __P((char *, DAEMON_T *));
89static void printdaemonflags __P((DAEMON_T *));
90static int addr_family __P((char *));
91static int addrcmp __P((struct hostent *, char *, SOCKADDR *));

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

737 (void) sm_signal(SIGCHLD, reapchild);
738
739 /* Add parent process as first child item */
740 proc_list_add(CurrentPid, "daemon child",
741 PROC_DAEMON_CHILD, 0, -1, NULL);
742
743 /* don't schedule queue runs if ETRN */
744 QueueIntvl = 0;
96static void connecttimeout __P((int));
97static int opendaemonsocket __P((DAEMON_T *, bool));
98static unsigned short setupdaemon __P((SOCKADDR *));
99static void getrequests_checkdiskspace __P((ENVELOPE *e));
100static void setsockaddroptions __P((char *, DAEMON_T *));
101static void printdaemonflags __P((DAEMON_T *));
102static int addr_family __P((char *));
103static int addrcmp __P((struct hostent *, char *, SOCKADDR *));

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

749 (void) sm_signal(SIGCHLD, reapchild);
750
751 /* Add parent process as first child item */
752 proc_list_add(CurrentPid, "daemon child",
753 PROC_DAEMON_CHILD, 0, -1, NULL);
754
755 /* don't schedule queue runs if ETRN */
756 QueueIntvl = 0;
757#if _FFR_SS_PER_DAEMON
758 if (Daemons[curdaemon].d_supersafe !=
759 SAFE_NOTSET)
760 SuperSafe = Daemons[curdaemon].d_supersafe;
761#endif /* _FFR_SS_PER_DAEMON */
762#if _FFR_DM_PER_DAEMON
763 if (Daemons[curdaemon].d_dm != DM_NOTSET)
764 set_delivery_mode(
765 Daemons[curdaemon].d_dm, e);
766#endif /* _FFR_DM_PER_DAEMON */
767
745
746 sm_setproctitle(true, e, "startup with %s",
747 anynet_ntoa(&RealHostAddr));
748 }
749
750 if (pipefd[0] != -1)
751 {
752 auto char c;

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

1448 *p++ = '\0';
1449 v = strchr(f, '=');
1450 if (v == NULL)
1451 continue;
1452 while (isascii(*++v) && isspace(*v))
1453 continue;
1454 if (isascii(*f) && islower(*f))
1455 *f = toupper(*f);
768
769 sm_setproctitle(true, e, "startup with %s",
770 anynet_ntoa(&RealHostAddr));
771 }
772
773 if (pipefd[0] != -1)
774 {
775 auto char c;

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

1471 *p++ = '\0';
1472 v = strchr(f, '=');
1473 if (v == NULL)
1474 continue;
1475 while (isascii(*++v) && isspace(*v))
1476 continue;
1477 if (isascii(*f) && islower(*f))
1478 *f = toupper(*f);
1479#if _FFR_SS_PER_DAEMON
1480 d->d_supersafe = SAFE_NOTSET;
1481#endif /* _FFR_SS_PER_DAEMON */
1482#if _FFR_DM_PER_DAEMON
1483 d->d_dm = DM_NOTSET;
1484#endif /* _FFR_DM_PER_DAEMON */
1456
1457 switch (*f)
1458 {
1485
1486 switch (*f)
1487 {
1488 case 'A': /* address */
1489 addr = v;
1490 break;
1491
1492#if _FFR_DM_PER_DAEMON
1493 case 'D': /* DeliveryMode */
1494 switch (*v)
1495 {
1496 case SM_QUEUE:
1497 case SM_DEFER:
1498 case SM_DELIVER:
1499 case SM_FORK:
1500 d->d_dm = *v;
1501 break;
1502 default:
1503 syserr("554 5.3.5 Unknown delivery mode %c",
1504 *v);
1505 break;
1506 }
1507 break;
1508#endif /* _FFR_DM_PER_DAEMON */
1509
1459 case 'F': /* address family */
1460 if (isascii(*v) && isdigit(*v))
1461 d->d_addr.sa.sa_family = atoi(v);
1462#if _FFR_DAEMON_NETUNIX
1463# ifdef NETUNIX
1464 else if (sm_strcasecmp(v, "unix") == 0 ||
1465 sm_strcasecmp(v, "local") == 0)
1466 d->d_addr.sa.sa_family = AF_UNIX;

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

1486 else if (sm_strcasecmp(v, "x.25") == 0)
1487 d->d_addr.sa.sa_family = AF_CCITT;
1488#endif /* NETX25 */
1489 else
1490 syserr("554 5.3.5 Unknown address family %s in Family=option",
1491 v);
1492 break;
1493
1510 case 'F': /* address family */
1511 if (isascii(*v) && isdigit(*v))
1512 d->d_addr.sa.sa_family = atoi(v);
1513#if _FFR_DAEMON_NETUNIX
1514# ifdef NETUNIX
1515 else if (sm_strcasecmp(v, "unix") == 0 ||
1516 sm_strcasecmp(v, "local") == 0)
1517 d->d_addr.sa.sa_family = AF_UNIX;

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

1537 else if (sm_strcasecmp(v, "x.25") == 0)
1538 d->d_addr.sa.sa_family = AF_CCITT;
1539#endif /* NETX25 */
1540 else
1541 syserr("554 5.3.5 Unknown address family %s in Family=option",
1542 v);
1543 break;
1544
1494 case 'A': /* address */
1495 addr = v;
1496 break;
1497
1498#if MILTER
1499 case 'I':
1500 d->d_inputfilterlist = v;
1501 break;
1502#endif /* MILTER */
1503
1545#if MILTER
1546 case 'I':
1547 d->d_inputfilterlist = v;
1548 break;
1549#endif /* MILTER */
1550
1504 case 'P': /* port */
1505 port = v;
1506 break;
1507
1508 case 'L': /* listen queue size */
1509 d->d_listenqueue = atoi(v);
1510 break;
1511
1512 case 'M': /* modifiers (flags) */
1513 d->d_mflags = getmodifiers(v, d->d_flags);
1514 break;
1515
1551 case 'L': /* listen queue size */
1552 d->d_listenqueue = atoi(v);
1553 break;
1554
1555 case 'M': /* modifiers (flags) */
1556 d->d_mflags = getmodifiers(v, d->d_flags);
1557 break;
1558
1516 case 'S': /* send buffer size */
1517 d->d_tcpsndbufsize = atoi(v);
1559 case 'N': /* name */
1560 d->d_name = v;
1518 break;
1519
1561 break;
1562
1563 case 'P': /* port */
1564 port = v;
1565 break;
1566
1520 case 'R': /* receive buffer size */
1521 d->d_tcprcvbufsize = atoi(v);
1522 break;
1523
1567 case 'R': /* receive buffer size */
1568 d->d_tcprcvbufsize = atoi(v);
1569 break;
1570
1524 case 'N': /* name */
1525 d->d_name = v;
1571 case 'S': /* send buffer size */
1572 d->d_tcpsndbufsize = atoi(v);
1526 break;
1527
1573 break;
1574
1575#if _FFR_SS_PER_DAEMON
1576 case 'T': /* SuperSafe */
1577 if (tolower(*v) == 'i')
1578 d->d_supersafe = SAFE_INTERACTIVE;
1579 else if (tolower(*v) == 'p')
1580# if MILTER
1581 d->d_supersafe = SAFE_REALLY_POSTMILTER;
1582# else /* MILTER */
1583 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
1584 "Warning: SuperSafe=PostMilter requires Milter support (-DMILTER)\n");
1585# endif /* MILTER */
1586 else
1587 d->d_supersafe = atobool(v) ? SAFE_REALLY
1588 : SAFE_NO;
1589 break;
1590#endif /* _FFR_SS_PER_DAEMON */
1591
1528 default:
1529 syserr("554 5.3.5 PortOptions parameter \"%s\" unknown",
1530 f);
1531 }
1532 }
1533
1534 /* Check addr and port after finding family */
1535 if (addr != NULL)

--- 2858 unchanged lines hidden ---
1592 default:
1593 syserr("554 5.3.5 PortOptions parameter \"%s\" unknown",
1594 f);
1595 }
1596 }
1597
1598 /* Check addr and port after finding family */
1599 if (addr != NULL)

--- 2858 unchanged lines hidden ---