122698Sdist /* 234920Sbostic * Copyright (c) 1983 Eric P. Allman 333728Sbostic * Copyright (c) 1988 Regents of the University of California. 433728Sbostic * All rights reserved. 533728Sbostic * 642825Sbostic * %sccs.include.redist.c% 733728Sbostic */ 822698Sdist 922698Sdist #ifndef lint 10*54996Seric static char sccsid[] = "@(#)conf.c 5.38 (Berkeley) 07/12/92"; 1133728Sbostic #endif /* not lint */ 1222698Sdist 1314881Seric # include <sys/ioctl.h> 1424943Seric # include <sys/param.h> 1536928Sbostic # include <pwd.h> 163309Seric # include "sendmail.h" 1740980Sbostic # include "pathnames.h" 18404Seric 19294Seric /* 203309Seric ** CONF.C -- Sendmail Configuration Tables. 21294Seric ** 22294Seric ** Defines the configuration of this installation. 23294Seric ** 241388Seric ** Configuration Variables: 252897Seric ** HdrInfo -- a table describing well-known header fields. 262897Seric ** Each entry has the field name and some flags, 274147Seric ** which are described in sendmail.h. 284093Seric ** 294093Seric ** Notes: 304093Seric ** I have tried to put almost all the reasonable 314093Seric ** configuration information into the configuration 324093Seric ** file read at runtime. My intent is that anything 334093Seric ** here is a function of the version of UNIX you 344093Seric ** are running, or is really static -- for example 354093Seric ** the headers are a superset of widely used 364093Seric ** protocols. If you find yourself playing with 374093Seric ** this file too much, you may be making a mistake! 38294Seric */ 39294Seric 40294Seric 41294Seric 42294Seric 434437Seric /* 442897Seric ** Header info table 453057Seric ** Final (null) entry contains the flags used for any other field. 464147Seric ** 474147Seric ** Not all of these are actually handled specially by sendmail 484147Seric ** at this time. They are included as placeholders, to let 494147Seric ** you know that "someday" I intend to have sendmail do 504147Seric ** something with them. 512897Seric */ 522897Seric 532897Seric struct hdrinfo HdrInfo[] = 542897Seric { 558060Seric /* originator fields, most to least significant */ 5611417Seric "resent-sender", H_FROM|H_RESENT, 5711417Seric "resent-from", H_FROM|H_RESENT, 5825686Seric "resent-reply-to", H_FROM|H_RESENT, 599055Seric "sender", H_FROM, 609055Seric "from", H_FROM, 6125686Seric "reply-to", H_FROM, 629055Seric "full-name", H_ACHECK, 639055Seric "return-receipt-to", H_FROM, 649055Seric "errors-to", H_FROM, 658060Seric /* destination fields */ 669055Seric "to", H_RCPT, 6711417Seric "resent-to", H_RCPT|H_RESENT, 689055Seric "cc", H_RCPT, 6911417Seric "resent-cc", H_RCPT|H_RESENT, 709055Seric "bcc", H_RCPT|H_ACHECK, 7111417Seric "resent-bcc", H_RCPT|H_ACHECK|H_RESENT, 728060Seric /* message identification and control */ 7311417Seric "message-id", 0, 7411417Seric "resent-message-id", H_RESENT, 759055Seric "message", H_EOH, 769055Seric "text", H_EOH, 7711417Seric /* date fields */ 7811417Seric "date", 0, 7911417Seric "resent-date", H_RESENT, 808060Seric /* trace fields */ 819055Seric "received", H_TRACE|H_FORCE, 829055Seric "via", H_TRACE|H_FORCE, 839055Seric "mail-from", H_TRACE|H_FORCE, 848060Seric 859055Seric NULL, 0, 862897Seric }; 874166Seric 884166Seric 894166Seric /* 904166Seric ** ARPANET error message numbers. 914166Seric */ 924166Seric 937956Seric char Arpa_Info[] = "050"; /* arbitrary info */ 947956Seric char Arpa_TSyserr[] = "451"; /* some (transient) system error */ 957956Seric char Arpa_PSyserr[] = "554"; /* some (permanent) system error */ 967956Seric char Arpa_Usrerr[] = "554"; /* some (fatal) user error */ 974282Seric 984282Seric 994282Seric 1004282Seric /* 1014282Seric ** Location of system files/databases/etc. 1024282Seric */ 1034282Seric 10440980Sbostic char *ConfFile = _PATH_SENDMAILCF; /* runtime configuration */ 10540980Sbostic char *FreezeFile = _PATH_SENDMAILFC; /* frozen version of above */ 1069039Seric 1079064Seric 1089064Seric 1099039Seric /* 11024943Seric ** Miscellaneous stuff. 1119039Seric */ 1129039Seric 11324943Seric int DtableSize = 50; /* max open files; reset in 4.2bsd */ 11424943Seric /* 11524943Seric ** SETDEFAULTS -- set default values 11624943Seric ** 11724943Seric ** Because of the way freezing is done, these must be initialized 11824943Seric ** using direct code. 11924943Seric ** 12024943Seric ** Parameters: 12124943Seric ** none. 12224943Seric ** 12324943Seric ** Returns: 12424943Seric ** none. 12524943Seric ** 12624943Seric ** Side Effects: 12724943Seric ** Initializes a bunch of global variables to their 12824943Seric ** default values. 12924943Seric */ 13024943Seric 13124943Seric setdefaults() 13224943Seric { 13324943Seric QueueLA = 8; 13424943Seric QueueFactor = 10000; 13524943Seric RefuseLA = 12; 13624943Seric SpaceSub = ' '; 13724981Seric WkRecipFact = 1000; 13824981Seric WkClassFact = 1800; 13925812Seric WkTimeFact = 9000; 14024981Seric FileMode = 0644; 14124981Seric DefUid = 1; 14224981Seric DefGid = 1; 14347284Seric CheckpointInterval = 10; 14451305Seric MaxHopCount = MAXHOP; 14552105Seric SendMode = SM_FORK; 14652105Seric ErrorMode = EM_PRINT; 14752106Seric EightBit = FALSE; 14854967Seric MaxMciCache = 1; 14954967Seric MciCacheTimeout = 300; 15040973Sbostic setdefuser(); 15153654Seric setupmaps(); 15224943Seric } 153294Seric 15440973Sbostic 1554326Seric /* 15640973Sbostic ** SETDEFUSER -- set/reset DefUser using DefUid (for initgroups()) 15740973Sbostic */ 15840973Sbostic 15940973Sbostic setdefuser() 16040973Sbostic { 16140973Sbostic struct passwd *defpwent; 16240973Sbostic 16340973Sbostic if (DefUser != NULL) 16440973Sbostic free(DefUser); 16540973Sbostic if ((defpwent = getpwuid(DefUid)) != NULL) 16640973Sbostic DefUser = newstr(defpwent->pw_name); 16740973Sbostic else 16840973Sbostic DefUser = newstr("nobody"); 16940973Sbostic } 17053654Seric /* 17153654Seric ** SETUPMAPS -- set up map classes 17253654Seric ** 17353654Seric ** Since these are compiled in, they cannot be in the config file. 17453654Seric ** 17553654Seric */ 17640973Sbostic 17753654Seric setupmaps() 17853654Seric { 17953654Seric register STAB *s; 18053654Seric MAPCLASS *hostmapclass; 18153654Seric extern char *maphostname(); 18240973Sbostic 18353654Seric /* set up host name lookup map */ 18453654Seric s = stab("host", ST_MAPCLASS, ST_ENTER); 18553654Seric s->s_mapclass.map_init = NULL; 18653654Seric s->s_mapclass.map_lookup = maphostname; 18753654Seric hostmapclass = &s->s_mapclass; 18853654Seric 18953654Seric s = stab("host", ST_MAP, ST_ENTER); 19053654Seric s->s_map.map_class = hostmapclass; 19153654Seric s->s_map.map_flags = MF_VALID; 19253654Seric 19353654Seric /* 19453654Seric ** Set up other map classes. 19553654Seric */ 19653654Seric 19753654Seric # ifdef DBM_MAP 19853654Seric /* dbm file access */ 19953654Seric { 20053654Seric extern void dbm_map_init(); 20153654Seric extern char *dbm_map_lookup(); 20253654Seric 20353654Seric s = stab("dbm", ST_MAPCLASS, ST_ENTER); 20453654Seric s->s_mapclass.map_init = dbm_map_init; 20553654Seric s->s_mapclass.map_lookup = dbm_map_lookup; 20653654Seric } 20753654Seric # endif 20853654Seric 20953654Seric # ifdef BTREE_MAP 21053654Seric /* new database file access -- btree files */ 21153654Seric { 21253654Seric extern void bt_map_init(); 21353654Seric extern char *bt_map_lookup(); 21453654Seric 21553654Seric s = stab("btree", ST_MAPCLASS, ST_ENTER); 21653654Seric s->s_mapclass.map_init = bt_map_init; 21753654Seric s->s_mapclass.map_lookup = bt_map_lookup; 21853654Seric } 21953654Seric # endif 22053654Seric 22153654Seric # ifdef HASH_MAP 22253654Seric /* new database file access -- hash files */ 22353654Seric { 22453654Seric extern void hash_map_init(); 22553654Seric extern char *hash_map_lookup(); 22653654Seric 22753654Seric s = stab("hash", ST_MAPCLASS, ST_ENTER); 22853654Seric s->s_mapclass.map_init = hash_map_init; 22953654Seric s->s_mapclass.map_lookup = hash_map_lookup; 23053654Seric } 23153654Seric # endif 23253654Seric 23353654Seric # ifdef USERDB_MAP 23453654Seric /* user database */ 23553654Seric { 23653654Seric extern void udb_map_init(); 23753654Seric extern char *udb_map_lookup(); 23853654Seric 23953654Seric s = stab("udb", ST_MAPCLASS, ST_ENTER); 24053654Seric s->s_mapclass.map_init = udb_map_init; 24153654Seric s->s_mapclass.map_lookup = udb_map_lookup; 24253654Seric } 24353654Seric # endif 24453654Seric } 24553654Seric /* 2464326Seric ** GETRUID -- get real user id (V7) 2474326Seric */ 2484326Seric 2494326Seric getruid() 2504326Seric { 2519274Seric if (OpMode == MD_DAEMON) 2524536Seric return (RealUid); 2534536Seric else 2544536Seric return (getuid()); 2554326Seric } 2564326Seric 2574326Seric 2584326Seric /* 2594326Seric ** GETRGID -- get real group id (V7). 2604326Seric */ 2614326Seric 2624326Seric getrgid() 2634326Seric { 2649274Seric if (OpMode == MD_DAEMON) 2654536Seric return (RealGid); 2664536Seric else 2674536Seric return (getgid()); 2684326Seric } 26953654Seric /* 2709369Seric ** USERNAME -- return the user id of the logged in user. 2719369Seric ** 2729369Seric ** Parameters: 2739369Seric ** none. 2749369Seric ** 2759369Seric ** Returns: 2769369Seric ** The login name of the logged in user. 2779369Seric ** 2789369Seric ** Side Effects: 2799369Seric ** none. 2809369Seric ** 2819369Seric ** Notes: 2829369Seric ** The return value is statically allocated. 2839369Seric */ 2849369Seric 2859369Seric char * 2869369Seric username() 2879369Seric { 28817469Seric static char *myname = NULL; 2899369Seric extern char *getlogin(); 29019904Smiriam register struct passwd *pw; 2919369Seric 29217469Seric /* cache the result */ 29317469Seric if (myname == NULL) 29417469Seric { 29517469Seric myname = getlogin(); 29617469Seric if (myname == NULL || myname[0] == '\0') 29717469Seric { 29817469Seric 29917469Seric pw = getpwuid(getruid()); 30017469Seric if (pw != NULL) 30140993Sbostic myname = newstr(pw->pw_name); 30217469Seric } 30319904Smiriam else 30419904Smiriam { 30519873Smiriam 30640993Sbostic myname = newstr(myname); 30740993Sbostic if ((pw = getpwnam(myname)) == NULL || 30840993Sbostic getuid() != pw->pw_uid) 30919904Smiriam { 31019873Smiriam pw = getpwuid(getuid()); 31124945Seric if (pw != NULL) 31240993Sbostic myname = newstr(pw->pw_name); 31319873Smiriam } 31419873Smiriam } 31517469Seric if (myname == NULL || myname[0] == '\0') 31617469Seric { 31717469Seric syserr("Who are you?"); 31817469Seric myname = "postmaster"; 31917469Seric } 32017469Seric } 32117469Seric 32217469Seric return (myname); 3239369Seric } 3249369Seric /* 3254190Seric ** TTYPATH -- Get the path of the user's tty 326294Seric ** 327294Seric ** Returns the pathname of the user's tty. Returns NULL if 328294Seric ** the user is not logged in or if s/he has write permission 329294Seric ** denied. 330294Seric ** 331294Seric ** Parameters: 332294Seric ** none 333294Seric ** 334294Seric ** Returns: 335294Seric ** pathname of the user's tty. 336294Seric ** NULL if not logged in or write permission denied. 337294Seric ** 338294Seric ** Side Effects: 339294Seric ** none. 340294Seric ** 341294Seric ** WARNING: 342294Seric ** Return value is in a local buffer. 343294Seric ** 344294Seric ** Called By: 345294Seric ** savemail 346294Seric */ 347294Seric 348294Seric # include <sys/stat.h> 349294Seric 350294Seric char * 351294Seric ttypath() 352294Seric { 353294Seric struct stat stbuf; 354294Seric register char *pathn; 355294Seric extern char *ttyname(); 3564081Seric extern char *getlogin(); 357294Seric 358294Seric /* compute the pathname of the controlling tty */ 3599369Seric if ((pathn = ttyname(2)) == NULL && (pathn = ttyname(1)) == NULL && 3609369Seric (pathn = ttyname(0)) == NULL) 361294Seric { 362294Seric errno = 0; 363294Seric return (NULL); 364294Seric } 365294Seric 366294Seric /* see if we have write permission */ 3672967Seric if (stat(pathn, &stbuf) < 0 || !bitset(02, stbuf.st_mode)) 368294Seric { 369294Seric errno = 0; 370294Seric return (NULL); 371294Seric } 372294Seric 373294Seric /* see if the user is logged in */ 374294Seric if (getlogin() == NULL) 375294Seric return (NULL); 376294Seric 377294Seric /* looks good */ 378294Seric return (pathn); 379294Seric } 3802967Seric /* 3812967Seric ** CHECKCOMPAT -- check for From and To person compatible. 3822967Seric ** 3832967Seric ** This routine can be supplied on a per-installation basis 3842967Seric ** to determine whether a person is allowed to send a message. 3852967Seric ** This allows restriction of certain types of internet 3862967Seric ** forwarding or registration of users. 3872967Seric ** 3882967Seric ** If the hosts are found to be incompatible, an error 3892967Seric ** message should be given using "usrerr" and FALSE should 3902967Seric ** be returned. 3912967Seric ** 3924288Seric ** 'NoReturn' can be set to suppress the return-to-sender 3934288Seric ** function; this should be done on huge messages. 3944288Seric ** 3952967Seric ** Parameters: 3962967Seric ** to -- the person being sent to. 3972967Seric ** 3982967Seric ** Returns: 3992967Seric ** TRUE -- ok to send. 4002967Seric ** FALSE -- not ok. 4012967Seric ** 4022967Seric ** Side Effects: 4032967Seric ** none (unless you include the usrerr stuff) 4042967Seric */ 4052967Seric 4062967Seric bool 4072967Seric checkcompat(to) 4082967Seric register ADDRESS *to; 4092967Seric { 41012133Seric # ifdef lint 41112133Seric if (to == NULL) 41212133Seric to++; 41312133Seric # endif lint 41410698Seric # ifdef EXAMPLE_CODE 41510698Seric /* this code is intended as an example only */ 4164437Seric register STAB *s; 4174437Seric 4184437Seric s = stab("arpa", ST_MAILER, ST_FIND); 4199369Seric if (s != NULL && CurEnv->e_from.q_mailer != LocalMailer && 4209369Seric to->q_mailer == s->s_mailer) 4214437Seric { 4224437Seric usrerr("No ARPA mail through this machine: see your system administration"); 42310698Seric /* NoReturn = TRUE; to supress return copy */ 4244437Seric return (FALSE); 4254437Seric } 42610698Seric # endif EXAMPLE_CODE 4272967Seric return (TRUE); 4282967Seric } 4299369Seric /* 4309369Seric ** HOLDSIGS -- arrange to hold all signals 4319369Seric ** 4329369Seric ** Parameters: 4339369Seric ** none. 4349369Seric ** 4359369Seric ** Returns: 4369369Seric ** none. 4379369Seric ** 4389369Seric ** Side Effects: 4399369Seric ** Arranges that signals are held. 4409369Seric */ 4419369Seric 4429369Seric holdsigs() 4439369Seric { 4449369Seric } 4459369Seric /* 4469369Seric ** RLSESIGS -- arrange to release all signals 4479369Seric ** 4489369Seric ** This undoes the effect of holdsigs. 4499369Seric ** 4509369Seric ** Parameters: 4519369Seric ** none. 4529369Seric ** 4539369Seric ** Returns: 4549369Seric ** none. 4559369Seric ** 4569369Seric ** Side Effects: 4579369Seric ** Arranges that signals are released. 4589369Seric */ 4599369Seric 4609369Seric rlsesigs() 4619369Seric { 4629369Seric } 46314872Seric /* 46414872Seric ** GETLA -- get the current load average 46514872Seric ** 46614881Seric ** This code stolen from la.c. 46714881Seric ** 46814872Seric ** Parameters: 46914872Seric ** none. 47014872Seric ** 47114872Seric ** Returns: 47214872Seric ** The current load average as an integer. 47314872Seric ** 47414872Seric ** Side Effects: 47514872Seric ** none. 47614872Seric */ 47714872Seric 47851920Seric /* try to guess what style of load average we have */ 47951920Seric #define LA_ZERO 1 /* always return load average as zero */ 48051920Seric #define LA_INT 2 /* read kmem for avenrun; interpret as int */ 48151920Seric #define LA_FLOAT 3 /* read kmem for avenrun; interpret as float */ 48251920Seric #define LA_SUBR 4 /* call getloadavg */ 48314872Seric 48451920Seric #ifndef LA_TYPE 48551920Seric # if defined(sun) 48651920Seric # define LA_TYPE LA_INT 48751920Seric # endif 48851920Seric # if defined(mips) 48951920Seric /* Ultrix or RISC/os */ 49051920Seric # define LA_TYPE LA_INT 49151920Seric # define LA_AVENRUN "avenrun" 49251920Seric # endif 49351920Seric # if defined(hpux) 49451920Seric # define LA_TYPE LA_FLOAT 49551920Seric # endif 49651920Seric # if defined(BSD) 49751920Seric # define LA_TYPE LA_SUBR 49851920Seric # endif 49951920Seric 50051920Seric # ifndef LA_TYPE 50151920Seric # define LA_TYPE LA_ZERO 50251920Seric # endif 50351920Seric #endif 50451920Seric 50551920Seric #if (LA_TYPE == LA_INT) || (LA_TYPE == LA_FLOAT) 50651920Seric 50714872Seric #include <nlist.h> 50851920Seric #include <fcntl.h> 50914872Seric 51051920Seric #ifndef LA_AVENRUN 51151920Seric #define LA_AVENRUN "_avenrun" 51251920Seric #endif 51351920Seric 51451920Seric /* _PATH_UNIX should be defined in <paths.h> */ 51551920Seric #ifndef _PATH_UNIX 51651920Seric # if defined(hpux) 51751920Seric # define _PATH_UNIX "/hp-ux" 51851920Seric # endif 51951920Seric # if defined(mips) && !defined(ultrix) 52051920Seric /* powerful RISC/os */ 52151920Seric # define _PATH_UNIX "/unix" 52251920Seric # endif 52351920Seric # ifndef _PATH_UNIX 52451920Seric # define _PATH_UNIX "/vmunix" 52551920Seric # endif 52651920Seric #endif 52751920Seric 52814872Seric struct nlist Nl[] = 52914872Seric { 53051920Seric { LA_AVENRUN }, 53114872Seric #define X_AVENRUN 0 53214872Seric { 0 }, 53314872Seric }; 53414872Seric 53551920Seric #if (LA_TYPE == LA_INT) && !defined(FSHIFT) 53651920Seric # define FSHIFT 8 53751920Seric # define FSCALE (1 << FSHIFT) 53851920Seric #endif 53940930Srick 54014872Seric getla() 54114872Seric { 54214872Seric static int kmem = -1; 54351920Seric #if LA_TYPE == LA_INT 54424943Seric long avenrun[3]; 54551920Seric #else 54651920Seric double avenrun[3]; 54751920Seric #endif 54825615Seric extern off_t lseek(); 54914872Seric 55014872Seric if (kmem < 0) 55114872Seric { 55224945Seric kmem = open("/dev/kmem", 0, 0); 55314872Seric if (kmem < 0) 55414872Seric return (-1); 55551920Seric (void) fcntl(kmem, F_SETFD, 1); 55651920Seric nlist(_PATH_UNIX, Nl); 55714872Seric if (Nl[0].n_type == 0) 55814872Seric return (-1); 55914872Seric } 56024945Seric if (lseek(kmem, (off_t) Nl[X_AVENRUN].n_value, 0) == -1 || 56123118Seric read(kmem, (char *) avenrun, sizeof(avenrun)) < sizeof(avenrun)) 56219967Seric { 56319967Seric /* thank you Ian */ 56419967Seric return (-1); 56519967Seric } 56651920Seric #if LA_TYPE == LA_INT 56724943Seric return ((int) (avenrun[0] + FSCALE/2) >> FSHIFT); 56851920Seric #else 56951920Seric return ((int) (avenrun[0] + 0.5)); 57051920Seric #endif 57114872Seric } 57214872Seric 57351773Seric #else 57451920Seric #if LA_TYPE == LA_SUBR 57551773Seric 57651773Seric getla() 57751773Seric { 57851920Seric double avenrun[3]; 57951920Seric 58051920Seric if (getloadavg(avenrun, sizeof(avenrun) / sizeof(avenrun[0])) < 0) 58151920Seric return (-1); 58251920Seric return ((int) (avenrun[0] + 0.5)); 58351773Seric } 58451773Seric 58551773Seric #else 58651773Seric 58751773Seric getla() 58851773Seric { 58951920Seric return (0); 59051773Seric } 59151773Seric 59251773Seric #endif 59351773Seric #endif 59424943Seric /* 59524943Seric ** SHOULDQUEUE -- should this message be queued or sent? 59624943Seric ** 59724943Seric ** Compares the message cost to the load average to decide. 59824943Seric ** 59924943Seric ** Parameters: 60024943Seric ** pri -- the priority of the message in question. 60124943Seric ** 60224943Seric ** Returns: 60324943Seric ** TRUE -- if this message should be queued up for the 60424943Seric ** time being. 60524943Seric ** FALSE -- if the load is low enough to send this message. 60624943Seric ** 60724943Seric ** Side Effects: 60824943Seric ** none. 60924943Seric */ 61024943Seric 61124943Seric bool 61224943Seric shouldqueue(pri) 61324943Seric long pri; 61424943Seric { 61551920Seric if (CurrentLA < QueueLA) 61624943Seric return (FALSE); 61751920Seric return (pri > (QueueFactor / (CurrentLA - QueueLA + 1))); 61824943Seric } 61924943Seric /* 62053037Seric ** REFUSECONNECTIONS -- decide if connections should be refused 62153037Seric ** 62253037Seric ** Parameters: 62353037Seric ** none. 62453037Seric ** 62553037Seric ** Returns: 62653037Seric ** TRUE if incoming SMTP connections should be refused 62753037Seric ** (for now). 62853037Seric ** FALSE if we should accept new work. 62953037Seric ** 63053037Seric ** Side Effects: 63153037Seric ** none. 63253037Seric */ 63353037Seric 63453037Seric bool 63553037Seric refuseconnections() 63653037Seric { 63753037Seric /* this is probably too simplistic */ 63853037Seric return (CurrentLA > RefuseLA); 63953037Seric } 64053037Seric /* 64124943Seric ** SETPROCTITLE -- set process title for ps 64224943Seric ** 64324943Seric ** Parameters: 64424943Seric ** fmt -- a printf style format string. 64524943Seric ** a, b, c -- possible parameters to fmt. 64624943Seric ** 64724943Seric ** Returns: 64824943Seric ** none. 64924943Seric ** 65024943Seric ** Side Effects: 65124943Seric ** Clobbers argv of our main procedure so ps(1) will 65224943Seric ** display the title. 65324943Seric */ 65424943Seric 65524943Seric /*VARARGS1*/ 65624943Seric setproctitle(fmt, a, b, c) 65724943Seric char *fmt; 65824943Seric { 65924943Seric # ifdef SETPROCTITLE 66024943Seric register char *p; 66125049Seric register int i; 66224943Seric extern char **Argv; 66324943Seric extern char *LastArgv; 66425049Seric char buf[MAXLINE]; 66524943Seric 666*54996Seric p = buf; 66724943Seric 668*54996Seric /* print sendmail: heading for grep */ 669*54996Seric (void) strcpy(p, "sendmail: "); 670*54996Seric p += strlen(p); 67124943Seric 672*54996Seric /* print the argument string */ 673*54996Seric (void) sprintf(p, fmt, a, b, c); 674*54996Seric 67525049Seric i = strlen(buf); 676*54996Seric if (i > LastArgv - Argv[0] - 2) 67725049Seric { 678*54996Seric i = LastArgv - Argv[0] - 2; 67925049Seric buf[i] = '\0'; 68025049Seric } 681*54996Seric (void) strcpy(Argv[0], buf); 682*54996Seric p = Argv[i]; 68324943Seric while (p < LastArgv) 68424943Seric *p++ = ' '; 68524943Seric # endif SETPROCTITLE 68624943Seric } 68725698Seric /* 68825698Seric ** REAPCHILD -- pick up the body of my child, lest it become a zombie 68925698Seric ** 69025698Seric ** Parameters: 69125698Seric ** none. 69225698Seric ** 69325698Seric ** Returns: 69425698Seric ** none. 69525698Seric ** 69625698Seric ** Side Effects: 69725698Seric ** Picks up extant zombies. 69825698Seric */ 69925698Seric 70025698Seric # include <sys/wait.h> 70125698Seric 70246928Sbostic void 70325698Seric reapchild() 70425698Seric { 70525698Seric # ifdef WNOHANG 70625698Seric union wait status; 70725698Seric 70846928Sbostic while (wait3((int *)&status, WNOHANG, (struct rusage *) NULL) > 0) 70925698Seric continue; 71025698Seric # else WNOHANG 71125698Seric auto int status; 71225698Seric 71346928Sbostic while (wait((int *)&status) > 0) 71425698Seric continue; 71525698Seric # endif WNOHANG 71625698Seric } 717