122710Sdist /* 234921Sbostic * Copyright (c) 1983 Eric P. Allman 333731Sbostic * Copyright (c) 1988 Regents of the University of California. 433731Sbostic * All rights reserved. 533731Sbostic * 642829Sbostic * %sccs.include.redist.c% 733731Sbostic */ 822710Sdist 922710Sdist #ifndef lint 10*52046Seric static char sccsid[] = "@(#)recipient.c 5.25 (Berkeley) 12/20/91"; 1133731Sbostic #endif /* not lint */ 1222710Sdist 1336928Sbostic # include <sys/types.h> 1436928Sbostic # include <sys/stat.h> 15*52046Seric # include <sys/file.h> 164174Seric # include <pwd.h> 174627Seric # include "sendmail.h" 184174Seric 194174Seric /* 209622Seric ** SENDTOLIST -- Designate a send list. 214174Seric ** 224174Seric ** The parameter is a comma-separated list of people to send to. 234174Seric ** This routine arranges to send to all of them. 244174Seric ** 254174Seric ** Parameters: 264174Seric ** list -- the send list. 274399Seric ** ctladdr -- the address template for the person to 284399Seric ** send to -- effective uid/gid are important. 295006Seric ** This is typically the alias that caused this 305006Seric ** expansion. 315006Seric ** sendq -- a pointer to the head of a queue to put 325006Seric ** these people into. 334174Seric ** 344174Seric ** Returns: 354998Seric ** none 364174Seric ** 374174Seric ** Side Effects: 384174Seric ** none. 394174Seric */ 404174Seric 414174Seric # define MAXRCRSN 10 424174Seric 439622Seric sendtolist(list, ctladdr, sendq) 444174Seric char *list; 454399Seric ADDRESS *ctladdr; 465198Seric ADDRESS **sendq; 474174Seric { 484174Seric register char *p; 498223Seric register ADDRESS *al; /* list of addresses to send to */ 504423Seric bool firstone; /* set on first address sent */ 514444Seric bool selfref; /* set if this list includes ctladdr */ 5211446Seric char delimiter; /* the address delimiter */ 534174Seric 547676Seric if (tTd(25, 1)) 554444Seric { 564444Seric printf("sendto: %s\n ctladdr=", list); 574444Seric printaddr(ctladdr, FALSE); 584444Seric } 594324Seric 608223Seric /* heuristic to determine old versus new style addresses */ 618230Seric if (ctladdr == NULL && 628230Seric (index(list, ',') != NULL || index(list, ';') != NULL || 638230Seric index(list, '<') != NULL || index(list, '(') != NULL)) 649340Seric CurEnv->e_flags &= ~EF_OLDSTYLE; 6511446Seric delimiter = ' '; 6611446Seric if (!bitset(EF_OLDSTYLE, CurEnv->e_flags) || ctladdr != NULL) 6711446Seric delimiter = ','; 688223Seric 694423Seric firstone = TRUE; 704444Seric selfref = FALSE; 714324Seric al = NULL; 728223Seric 738081Seric for (p = list; *p != '\0'; ) 744174Seric { 758081Seric register ADDRESS *a; 768081Seric extern char *DelimChar; /* defined in prescan */ 774319Seric 788081Seric /* parse the address */ 798081Seric while (isspace(*p) || *p == ',') 804174Seric p++; 8111446Seric a = parseaddr(p, (ADDRESS *) NULL, 1, delimiter); 829297Seric p = DelimChar; 839297Seric if (a == NULL) 844174Seric continue; 854324Seric a->q_next = al; 864399Seric a->q_alias = ctladdr; 874444Seric 884444Seric /* see if this should be marked as a primary address */ 894423Seric if (ctladdr == NULL || 908081Seric (firstone && *p == '\0' && bitset(QPRIMARY, ctladdr->q_flags))) 914423Seric a->q_flags |= QPRIMARY; 924444Seric 934444Seric /* put on send queue or suppress self-reference */ 949379Seric if (ctladdr != NULL && sameaddr(ctladdr, a)) 954444Seric selfref = TRUE; 964444Seric else 974444Seric al = a; 984423Seric firstone = FALSE; 994324Seric } 1004324Seric 1014444Seric /* if this alias doesn't include itself, delete ctladdr */ 1024444Seric if (!selfref && ctladdr != NULL) 1034444Seric ctladdr->q_flags |= QDONTSEND; 1044444Seric 1054324Seric /* arrange to send to everyone on the local send list */ 1064324Seric while (al != NULL) 1074324Seric { 1084324Seric register ADDRESS *a = al; 10912613Seric extern ADDRESS *recipient(); 1104324Seric 1114324Seric al = a->q_next; 11240973Sbostic setctladdr(a); 11312613Seric a = recipient(a, sendq); 1144993Seric 1154998Seric /* arrange to inherit full name */ 1164998Seric if (a->q_fullname == NULL && ctladdr != NULL) 1174998Seric a->q_fullname = ctladdr->q_fullname; 1184174Seric } 1194324Seric 1206906Seric CurEnv->e_to = NULL; 1214174Seric } 1224174Seric /* 1234174Seric ** RECIPIENT -- Designate a message recipient 1244174Seric ** 1254174Seric ** Saves the named person for future mailing. 1264174Seric ** 1274174Seric ** Parameters: 1284174Seric ** a -- the (preparsed) address header for the recipient. 1295006Seric ** sendq -- a pointer to the head of a queue to put the 1305006Seric ** recipient in. Duplicate supression is done 1315006Seric ** in this queue. 1324174Seric ** 1334174Seric ** Returns: 13412613Seric ** The actual address in the queue. This will be "a" if 13512613Seric ** the address is not a duplicate, else the original address. 1364174Seric ** 1374174Seric ** Side Effects: 1384174Seric ** none. 1394174Seric */ 1404174Seric 14146928Sbostic extern ADDRESS *getctladdr(); 142*52046Seric extern char *RcptLogFile; 14346928Sbostic 14412613Seric ADDRESS * 1455006Seric recipient(a, sendq) 1464174Seric register ADDRESS *a; 1475006Seric register ADDRESS **sendq; 1484174Seric { 1494174Seric register ADDRESS *q; 1504319Seric ADDRESS **pq; 1514174Seric register struct mailer *m; 1529210Seric register char *p; 1539210Seric bool quoted = FALSE; /* set if the addr has a quote bit */ 1549210Seric char buf[MAXNAME]; /* unquoted image of the user name */ 1554627Seric extern bool safefile(); 1564174Seric 1576906Seric CurEnv->e_to = a->q_paddr; 1584600Seric m = a->q_mailer; 1594174Seric errno = 0; 1607676Seric if (tTd(26, 1)) 1614444Seric { 1624444Seric printf("\nrecipient: "); 1634444Seric printaddr(a, FALSE); 1644444Seric } 1654174Seric 1664174Seric /* break aliasing loops */ 1674174Seric if (AliasLevel > MAXRCRSN) 1684174Seric { 1694174Seric usrerr("aliasing/forwarding loop broken"); 17012613Seric return (a); 1714174Seric } 1724174Seric 1734174Seric /* 1744627Seric ** Finish setting up address structure. 1754174Seric */ 1764174Seric 17716160Seric /* set the queue timeout */ 1784627Seric a->q_timeout = TimeOut; 1794627Seric 18016160Seric /* map user & host to lower case if requested on non-aliases */ 18116160Seric if (a->q_alias == NULL) 18216160Seric loweraddr(a); 18316160Seric 18416160Seric /* get unquoted user for file, program or user.name check */ 1859210Seric (void) strcpy(buf, a->q_user); 1869210Seric for (p = buf; *p != '\0' && !quoted; p++) 1879210Seric { 1889210Seric if (!isascii(*p) && (*p & 0377) != (SpaceSub & 0377)) 1899210Seric quoted = TRUE; 1909210Seric } 1919210Seric stripquotes(buf, TRUE); 1929210Seric 1934627Seric /* do sickly crude mapping for program mailing, etc. */ 1949210Seric if (m == LocalMailer && buf[0] == '|') 1954174Seric { 1969210Seric a->q_mailer = m = ProgMailer; 1979210Seric a->q_user++; 19836231Sbostic if (a->q_alias == NULL && !QueueRun && !ForceMail) 1994174Seric { 20029915Seric a->q_flags |= QDONTSEND|QBADADDR; 2019210Seric usrerr("Cannot mail directly to programs"); 2024174Seric } 2034174Seric } 2044174Seric 2054174Seric /* 2064419Seric ** Look up this person in the recipient list. 2074419Seric ** If they are there already, return, otherwise continue. 2084419Seric ** If the list is empty, just add it. Notice the cute 2094419Seric ** hack to make from addresses suppress things correctly: 2104419Seric ** the QDONTSEND bit will be set in the send list. 2114419Seric ** [Please note: the emphasis is on "hack."] 2124174Seric */ 2134174Seric 2145006Seric for (pq = sendq; (q = *pq) != NULL; pq = &q->q_next) 2154174Seric { 2169379Seric if (!ForceMail && sameaddr(q, a)) 2174174Seric { 2187676Seric if (tTd(26, 1)) 2194444Seric { 2204444Seric printf("%s in sendq: ", a->q_paddr); 2214444Seric printaddr(q, FALSE); 2224444Seric } 2237054Seric if (!bitset(QDONTSEND, a->q_flags)) 2244324Seric message(Arpa_Info, "duplicate suppressed"); 2254423Seric if (!bitset(QPRIMARY, q->q_flags)) 2264423Seric q->q_flags |= a->q_flags; 22712613Seric return (q); 2284174Seric } 2294319Seric } 2304174Seric 2314319Seric /* add address on list */ 2324319Seric *pq = a; 2334174Seric a->q_next = NULL; 23424951Seric CurEnv->e_nrcpts++; 2354174Seric 236*52046Seric if (a->q_alias == NULL && RcptLogFile != NULL && 237*52046Seric !bitset(QDONTSEND, a->q_flags)) 238*52046Seric { 239*52046Seric static int RcptLogFd = -1; 240*52046Seric 241*52046Seric /* 242*52046Seric ** Log the incoming recipient name before aliasing, 243*52046Seric ** expanding, forwarding, rewriting, and all that jazz. 244*52046Seric ** We'll use this to track down out-of-date aliases, 245*52046Seric ** host names, and so forth. 246*52046Seric */ 247*52046Seric 248*52046Seric if (RcptLogFd < 0) 249*52046Seric { 250*52046Seric /* try to open the log file */ 251*52046Seric RcptLogFd = open(RcptLogFile, O_WRONLY|O_APPEND|O_CREAT, 0666); 252*52046Seric } 253*52046Seric if (RcptLogFd >= 0) 254*52046Seric { 255*52046Seric int l = strlen(a->q_paddr); 256*52046Seric 257*52046Seric a->q_paddr[l] = '\n'; 258*52046Seric if (write(RcptLogFd, a->q_paddr, l + 1) < 0) 259*52046Seric { 260*52046Seric (void) close(RcptLogFd); 261*52046Seric RcptLogFd = -1; 262*52046Seric } 263*52046Seric a->q_paddr[l] = '\0'; 264*52046Seric } 265*52046Seric } 266*52046Seric 2674174Seric /* 2684174Seric ** Alias the name and handle :include: specs. 2694174Seric */ 2704174Seric 2719210Seric if (m == LocalMailer && !bitset(QDONTSEND, a->q_flags)) 2724174Seric { 2734174Seric if (strncmp(a->q_user, ":include:", 9) == 0) 2744174Seric { 2754174Seric a->q_flags |= QDONTSEND; 27636231Sbostic if (a->q_alias == NULL && !QueueRun && !ForceMail) 27729915Seric { 27829915Seric a->q_flags |= QBADADDR; 2794399Seric usrerr("Cannot mail directly to :include:s"); 28029915Seric } 2814399Seric else 2824399Seric { 2837054Seric message(Arpa_Info, "including file %s", &a->q_user[9]); 2845006Seric include(&a->q_user[9], " sending", a, sendq); 2854399Seric } 2864174Seric } 2874174Seric else 28850556Seric { 28950556Seric /* try aliasing */ 2905006Seric alias(a, sendq); 29150556Seric 29250556Seric # ifdef USERDB 29351923Seric /* if not aliased, look it up in the user database */ 29451360Seric if (!bitset(QDONTSEND|QNOTREMOTE, a->q_flags)) 29551923Seric { 29651923Seric extern int udbexpand(); 29751923Seric 29851923Seric if (udbexpand(a, sendq) == EX_TEMPFAIL) 29951923Seric { 30051923Seric a->q_flags |= QQUEUEUP; 30151923Seric if (CurEnv->e_message == NULL) 30251923Seric CurEnv->e_message = newstr("Deferred: user database error"); 30351923Seric # ifdef LOG 30451923Seric if (LogLevel > 3) 30551923Seric syslog(LOG_INFO, "%s: deferred: udbexpand", 30651923Seric CurEnv->e_id); 30750556Seric # endif 30851923Seric message(Arpa_Info, "queued (user database error)"); 30951923Seric return (a); 31051923Seric } 31151923Seric } 31251923Seric # endif 31350556Seric } 3144174Seric } 3154174Seric 3164174Seric /* 3174174Seric ** If the user is local and still being sent, verify that 3184174Seric ** the address is good. If it is, try to forward. 3194174Seric ** If the address is already good, we have a forwarding 3204174Seric ** loop. This can be broken by just sending directly to 3214174Seric ** the user (which is probably correct anyway). 3224174Seric */ 3234174Seric 32451317Seric if (bitset(QDONTSEND, a->q_flags) || m != LocalMailer) 32551317Seric return (a); 32651317Seric 32751317Seric /* see if this is to a file */ 32851317Seric if (buf[0] == '/') 3294174Seric { 3304329Seric struct stat stb; 3314329Seric extern bool writable(); 3324174Seric 33351317Seric p = rindex(buf, '/'); 33451317Seric /* check if writable or creatable */ 33551317Seric if (a->q_alias == NULL && !QueueRun && !ForceMail) 3364174Seric { 33751317Seric a->q_flags |= QDONTSEND|QBADADDR; 33851317Seric usrerr("Cannot mail directly to files"); 3394174Seric } 34051317Seric else if ((stat(buf, &stb) >= 0) ? (!writable(&stb)) : 34151317Seric (*p = '\0', !safefile(buf, getruid(), S_IWRITE|S_IEXEC))) 34251317Seric { 34351317Seric a->q_flags |= QBADADDR; 34451317Seric giveresponse(EX_CANTCREAT, m, CurEnv); 34551317Seric } 34651317Seric return (a); 34751317Seric } 34851317Seric 34951317Seric /* 35051317Seric ** If we have a level two config file, then pass the name through 35151317Seric ** Ruleset 5 before sending it off. Ruleset 5 has the right 35251317Seric ** to send rewrite it to another mailer. This gives us a hook 35351317Seric ** after local aliasing has been done. 35451317Seric */ 35551317Seric 35651317Seric if (tTd(29, 5)) 35751317Seric { 35851317Seric printf("recipient: testing local? cl=%d, rr5=%x\n\t", 35951317Seric ConfigLevel, RewriteRules[5]); 36051317Seric printaddr(a, FALSE); 36151317Seric } 36251317Seric if (!bitset(QNOTREMOTE, a->q_flags) && ConfigLevel >= 2 && 36351317Seric RewriteRules[5] != NULL) 36451317Seric { 36551317Seric maplocaluser(a, sendq); 36651317Seric } 36751317Seric 36851317Seric /* 36951317Seric ** If it didn't get rewritten to another mailer, go ahead 37051317Seric ** and deliver it. 37151317Seric */ 37251317Seric 37351317Seric if (!bitset(QDONTSEND, a->q_flags)) 37451317Seric { 37551317Seric register struct passwd *pw; 37651317Seric extern struct passwd *finduser(); 37751317Seric 37851317Seric /* warning -- finduser may trash buf */ 37951317Seric pw = finduser(buf); 38051317Seric if (pw == NULL) 38151317Seric { 38251317Seric a->q_flags |= QBADADDR; 38351317Seric giveresponse(EX_NOUSER, m, CurEnv); 38451317Seric } 3854174Seric else 3864174Seric { 38751317Seric char nbuf[MAXNAME]; 3884373Seric 38951317Seric if (strcmp(a->q_user, pw->pw_name) != 0) 3904174Seric { 39151317Seric a->q_user = newstr(pw->pw_name); 39251317Seric (void) strcpy(buf, pw->pw_name); 3934174Seric } 39451317Seric a->q_home = newstr(pw->pw_dir); 39551317Seric a->q_uid = pw->pw_uid; 39651317Seric a->q_gid = pw->pw_gid; 39751317Seric a->q_flags |= QGOODUID; 39851317Seric buildfname(pw->pw_gecos, pw->pw_name, nbuf); 39951317Seric if (nbuf[0] != '\0') 40051317Seric a->q_fullname = newstr(nbuf); 40151317Seric if (!quoted) 40251317Seric forward(a, sendq); 4034174Seric } 4044174Seric } 40512613Seric return (a); 4064174Seric } 4074174Seric /* 4084373Seric ** FINDUSER -- find the password entry for a user. 4094373Seric ** 4104373Seric ** This looks a lot like getpwnam, except that it may want to 4114373Seric ** do some fancier pattern matching in /etc/passwd. 4124373Seric ** 4139379Seric ** This routine contains most of the time of many sendmail runs. 4149379Seric ** It deserves to be optimized. 4159379Seric ** 4164373Seric ** Parameters: 4174373Seric ** name -- the name to match against. 4184373Seric ** 4194373Seric ** Returns: 4204373Seric ** A pointer to a pw struct. 4214373Seric ** NULL if name is unknown or ambiguous. 4224373Seric ** 4234373Seric ** Side Effects: 4244407Seric ** may modify name. 4254373Seric */ 4264373Seric 4274373Seric struct passwd * 4284373Seric finduser(name) 4294373Seric char *name; 4304373Seric { 4314376Seric register struct passwd *pw; 4324407Seric register char *p; 43315325Seric extern struct passwd *getpwent(); 43415325Seric extern struct passwd *getpwnam(); 4354373Seric 43625777Seric /* map upper => lower case */ 4374407Seric for (p = name; *p != '\0'; p++) 4384407Seric { 43925777Seric if (isascii(*p) && isupper(*p)) 44025568Seric *p = tolower(*p); 4414407Seric } 4424407Seric 44325777Seric /* look up this login name using fast path */ 44412634Seric if ((pw = getpwnam(name)) != NULL) 44512634Seric return (pw); 44612634Seric 44712634Seric /* search for a matching full name instead */ 44825777Seric for (p = name; *p != '\0'; p++) 44925777Seric { 45025777Seric if (*p == (SpaceSub & 0177) || *p == '_') 45125777Seric *p = ' '; 45225777Seric } 45323107Seric (void) setpwent(); 4544376Seric while ((pw = getpwent()) != NULL) 4554376Seric { 4564998Seric char buf[MAXNAME]; 4574376Seric 4584998Seric buildfname(pw->pw_gecos, pw->pw_name, buf); 45933725Sbostic if (index(buf, ' ') != NULL && !strcasecmp(buf, name)) 4604381Seric { 4617054Seric message(Arpa_Info, "sending to login name %s", pw->pw_name); 4624376Seric return (pw); 4634377Seric } 4644376Seric } 4654376Seric return (NULL); 4664373Seric } 4674373Seric /* 4684329Seric ** WRITABLE -- predicate returning if the file is writable. 4694329Seric ** 4704329Seric ** This routine must duplicate the algorithm in sys/fio.c. 4714329Seric ** Unfortunately, we cannot use the access call since we 4724329Seric ** won't necessarily be the real uid when we try to 4734329Seric ** actually open the file. 4744329Seric ** 4754329Seric ** Notice that ANY file with ANY execute bit is automatically 4764329Seric ** not writable. This is also enforced by mailfile. 4774329Seric ** 4784329Seric ** Parameters: 4794329Seric ** s -- pointer to a stat struct for the file. 4804329Seric ** 4814329Seric ** Returns: 4824329Seric ** TRUE -- if we will be able to write this file. 4834329Seric ** FALSE -- if we cannot write this file. 4844329Seric ** 4854329Seric ** Side Effects: 4864329Seric ** none. 4874329Seric */ 4884329Seric 4894329Seric bool 4904329Seric writable(s) 4914329Seric register struct stat *s; 4924329Seric { 4934329Seric int euid, egid; 4944329Seric int bits; 4954329Seric 4964329Seric if (bitset(0111, s->st_mode)) 4974329Seric return (FALSE); 4984329Seric euid = getruid(); 4994329Seric egid = getrgid(); 5004329Seric if (geteuid() == 0) 5014329Seric { 5024329Seric if (bitset(S_ISUID, s->st_mode)) 5034329Seric euid = s->st_uid; 5044329Seric if (bitset(S_ISGID, s->st_mode)) 5054329Seric egid = s->st_gid; 5064329Seric } 5074329Seric 5084329Seric if (euid == 0) 5094329Seric return (TRUE); 5104329Seric bits = S_IWRITE; 5114329Seric if (euid != s->st_uid) 5124329Seric { 5134329Seric bits >>= 3; 5144329Seric if (egid != s->st_gid) 5154329Seric bits >>= 3; 5164329Seric } 5174329Seric return ((s->st_mode & bits) != 0); 5184329Seric } 5194329Seric /* 5204174Seric ** INCLUDE -- handle :include: specification. 5214174Seric ** 5224174Seric ** Parameters: 5234174Seric ** fname -- filename to include. 5244176Seric ** msg -- message to print in verbose mode. 5254399Seric ** ctladdr -- address template to use to fill in these 5264399Seric ** addresses -- effective user/group id are 5274399Seric ** the important things. 5285006Seric ** sendq -- a pointer to the head of the send queue 5295006Seric ** to put these addresses in. 5304174Seric ** 5314174Seric ** Returns: 5324174Seric ** none. 5334174Seric ** 5344174Seric ** Side Effects: 5354174Seric ** reads the :include: file and sends to everyone 5364174Seric ** listed in that file. 5374174Seric */ 5384174Seric 5395006Seric include(fname, msg, ctladdr, sendq) 5404174Seric char *fname; 5414176Seric char *msg; 5424399Seric ADDRESS *ctladdr; 5435006Seric ADDRESS **sendq; 5444174Seric { 5454174Seric char buf[MAXLINE]; 5464174Seric register FILE *fp; 5476906Seric char *oldto = CurEnv->e_to; 5489379Seric char *oldfilename = FileName; 5499379Seric int oldlinenumber = LineNumber; 5504174Seric 5514174Seric fp = fopen(fname, "r"); 5524174Seric if (fp == NULL) 5534174Seric { 5544174Seric usrerr("Cannot open %s", fname); 5554174Seric return; 5564174Seric } 5574406Seric if (getctladdr(ctladdr) == NULL) 5584406Seric { 5594406Seric struct stat st; 5604174Seric 5614406Seric if (fstat(fileno(fp), &st) < 0) 5624406Seric syserr("Cannot fstat %s!", fname); 5634406Seric ctladdr->q_uid = st.st_uid; 5644406Seric ctladdr->q_gid = st.st_gid; 5654406Seric ctladdr->q_flags |= QGOODUID; 5664406Seric } 5674406Seric 5684174Seric /* read the file -- each line is a comma-separated list. */ 5699379Seric FileName = fname; 5709379Seric LineNumber = 0; 5714174Seric while (fgets(buf, sizeof buf, fp) != NULL) 5724174Seric { 5734174Seric register char *p = index(buf, '\n'); 5744174Seric 57540963Sbostic LineNumber++; 5764174Seric if (p != NULL) 5774174Seric *p = '\0'; 57851781Seric if (buf[0] == '\0' || buf[0] == '#') 5794174Seric continue; 5806906Seric CurEnv->e_to = oldto; 5817054Seric message(Arpa_Info, "%s to %s", msg, buf); 5824176Seric AliasLevel++; 5839622Seric sendtolist(buf, ctladdr, sendq); 5844176Seric AliasLevel--; 5854174Seric } 5864174Seric 5874319Seric (void) fclose(fp); 5889379Seric FileName = oldfilename; 5899379Seric LineNumber = oldlinenumber; 5904174Seric } 5914324Seric /* 5924324Seric ** SENDTOARGV -- send to an argument vector. 5934324Seric ** 5944324Seric ** Parameters: 5954324Seric ** argv -- argument vector to send to. 5964324Seric ** 5974324Seric ** Returns: 5984324Seric ** none. 5994324Seric ** 6004324Seric ** Side Effects: 6014324Seric ** puts all addresses on the argument vector onto the 6024324Seric ** send queue. 6034324Seric */ 6044324Seric 6054324Seric sendtoargv(argv) 6064324Seric register char **argv; 6074324Seric { 6084324Seric register char *p; 6094324Seric 6104324Seric while ((p = *argv++) != NULL) 6114324Seric { 61233725Sbostic if (argv[0] != NULL && argv[1] != NULL && !strcasecmp(argv[0], "at")) 6134324Seric { 6144324Seric char nbuf[MAXNAME]; 6154324Seric 6164324Seric if (strlen(p) + strlen(argv[1]) + 2 > sizeof nbuf) 6174324Seric usrerr("address overflow"); 6184324Seric else 6194324Seric { 6204324Seric (void) strcpy(nbuf, p); 6214324Seric (void) strcat(nbuf, "@"); 6224324Seric (void) strcat(nbuf, argv[1]); 6234324Seric p = newstr(nbuf); 6244324Seric argv += 2; 6254324Seric } 6264324Seric } 6279622Seric sendtolist(p, (ADDRESS *) NULL, &CurEnv->e_sendqueue); 6284324Seric } 6294324Seric } 6304399Seric /* 6314399Seric ** GETCTLADDR -- get controlling address from an address header. 6324399Seric ** 6334399Seric ** If none, get one corresponding to the effective userid. 6344399Seric ** 6354399Seric ** Parameters: 6364399Seric ** a -- the address to find the controller of. 6374399Seric ** 6384399Seric ** Returns: 6394399Seric ** the controlling address. 6404399Seric ** 6414399Seric ** Side Effects: 6424399Seric ** none. 6434399Seric */ 6444399Seric 6454399Seric ADDRESS * 6464399Seric getctladdr(a) 6474399Seric register ADDRESS *a; 6484399Seric { 6494404Seric while (a != NULL && !bitset(QGOODUID, a->q_flags)) 6504399Seric a = a->q_alias; 6514399Seric return (a); 6524399Seric } 653