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*52047Seric static char sccsid[] = "@(#)recipient.c 5.26 (Berkeley) 12/20/91"; 1133731Sbostic #endif /* not lint */ 1222710Sdist 1336928Sbostic # include <sys/types.h> 1436928Sbostic # include <sys/stat.h> 1552046Seric # 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(); 14252046Seric 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 23652046Seric if (a->q_alias == NULL && RcptLogFile != NULL && 23752046Seric !bitset(QDONTSEND, a->q_flags)) 23852046Seric { 23952046Seric static int RcptLogFd = -1; 24052046Seric 24152046Seric /* 24252046Seric ** Log the incoming recipient name before aliasing, 24352046Seric ** expanding, forwarding, rewriting, and all that jazz. 24452046Seric ** We'll use this to track down out-of-date aliases, 24552046Seric ** host names, and so forth. 24652046Seric */ 24752046Seric 24852046Seric if (RcptLogFd < 0) 24952046Seric { 25052046Seric /* try to open the log file */ 25152046Seric RcptLogFd = open(RcptLogFile, O_WRONLY|O_APPEND|O_CREAT, 0666); 252*52047Seric if (RcptLogFd >= 0) 253*52047Seric (void) fcntl(RcptLogFd, F_SETFD, 1); 25452046Seric } 25552046Seric if (RcptLogFd >= 0) 25652046Seric { 25752046Seric int l = strlen(a->q_paddr); 25852046Seric 25952046Seric a->q_paddr[l] = '\n'; 26052046Seric if (write(RcptLogFd, a->q_paddr, l + 1) < 0) 26152046Seric { 26252046Seric (void) close(RcptLogFd); 26352046Seric RcptLogFd = -1; 26452046Seric } 26552046Seric a->q_paddr[l] = '\0'; 26652046Seric } 26752046Seric } 26852046Seric 2694174Seric /* 2704174Seric ** Alias the name and handle :include: specs. 2714174Seric */ 2724174Seric 2739210Seric if (m == LocalMailer && !bitset(QDONTSEND, a->q_flags)) 2744174Seric { 2754174Seric if (strncmp(a->q_user, ":include:", 9) == 0) 2764174Seric { 2774174Seric a->q_flags |= QDONTSEND; 27836231Sbostic if (a->q_alias == NULL && !QueueRun && !ForceMail) 27929915Seric { 28029915Seric a->q_flags |= QBADADDR; 2814399Seric usrerr("Cannot mail directly to :include:s"); 28229915Seric } 2834399Seric else 2844399Seric { 2857054Seric message(Arpa_Info, "including file %s", &a->q_user[9]); 2865006Seric include(&a->q_user[9], " sending", a, sendq); 2874399Seric } 2884174Seric } 2894174Seric else 29050556Seric { 29150556Seric /* try aliasing */ 2925006Seric alias(a, sendq); 29350556Seric 29450556Seric # ifdef USERDB 29551923Seric /* if not aliased, look it up in the user database */ 29651360Seric if (!bitset(QDONTSEND|QNOTREMOTE, a->q_flags)) 29751923Seric { 29851923Seric extern int udbexpand(); 29951923Seric 30051923Seric if (udbexpand(a, sendq) == EX_TEMPFAIL) 30151923Seric { 30251923Seric a->q_flags |= QQUEUEUP; 30351923Seric if (CurEnv->e_message == NULL) 30451923Seric CurEnv->e_message = newstr("Deferred: user database error"); 30551923Seric # ifdef LOG 30651923Seric if (LogLevel > 3) 30751923Seric syslog(LOG_INFO, "%s: deferred: udbexpand", 30851923Seric CurEnv->e_id); 30950556Seric # endif 31051923Seric message(Arpa_Info, "queued (user database error)"); 31151923Seric return (a); 31251923Seric } 31351923Seric } 31451923Seric # endif 31550556Seric } 3164174Seric } 3174174Seric 3184174Seric /* 3194174Seric ** If the user is local and still being sent, verify that 3204174Seric ** the address is good. If it is, try to forward. 3214174Seric ** If the address is already good, we have a forwarding 3224174Seric ** loop. This can be broken by just sending directly to 3234174Seric ** the user (which is probably correct anyway). 3244174Seric */ 3254174Seric 32651317Seric if (bitset(QDONTSEND, a->q_flags) || m != LocalMailer) 32751317Seric return (a); 32851317Seric 32951317Seric /* see if this is to a file */ 33051317Seric if (buf[0] == '/') 3314174Seric { 3324329Seric struct stat stb; 3334329Seric extern bool writable(); 3344174Seric 33551317Seric p = rindex(buf, '/'); 33651317Seric /* check if writable or creatable */ 33751317Seric if (a->q_alias == NULL && !QueueRun && !ForceMail) 3384174Seric { 33951317Seric a->q_flags |= QDONTSEND|QBADADDR; 34051317Seric usrerr("Cannot mail directly to files"); 3414174Seric } 34251317Seric else if ((stat(buf, &stb) >= 0) ? (!writable(&stb)) : 34351317Seric (*p = '\0', !safefile(buf, getruid(), S_IWRITE|S_IEXEC))) 34451317Seric { 34551317Seric a->q_flags |= QBADADDR; 34651317Seric giveresponse(EX_CANTCREAT, m, CurEnv); 34751317Seric } 34851317Seric return (a); 34951317Seric } 35051317Seric 35151317Seric /* 35251317Seric ** If we have a level two config file, then pass the name through 35351317Seric ** Ruleset 5 before sending it off. Ruleset 5 has the right 35451317Seric ** to send rewrite it to another mailer. This gives us a hook 35551317Seric ** after local aliasing has been done. 35651317Seric */ 35751317Seric 35851317Seric if (tTd(29, 5)) 35951317Seric { 36051317Seric printf("recipient: testing local? cl=%d, rr5=%x\n\t", 36151317Seric ConfigLevel, RewriteRules[5]); 36251317Seric printaddr(a, FALSE); 36351317Seric } 36451317Seric if (!bitset(QNOTREMOTE, a->q_flags) && ConfigLevel >= 2 && 36551317Seric RewriteRules[5] != NULL) 36651317Seric { 36751317Seric maplocaluser(a, sendq); 36851317Seric } 36951317Seric 37051317Seric /* 37151317Seric ** If it didn't get rewritten to another mailer, go ahead 37251317Seric ** and deliver it. 37351317Seric */ 37451317Seric 37551317Seric if (!bitset(QDONTSEND, a->q_flags)) 37651317Seric { 37751317Seric register struct passwd *pw; 37851317Seric extern struct passwd *finduser(); 37951317Seric 38051317Seric /* warning -- finduser may trash buf */ 38151317Seric pw = finduser(buf); 38251317Seric if (pw == NULL) 38351317Seric { 38451317Seric a->q_flags |= QBADADDR; 38551317Seric giveresponse(EX_NOUSER, m, CurEnv); 38651317Seric } 3874174Seric else 3884174Seric { 38951317Seric char nbuf[MAXNAME]; 3904373Seric 39151317Seric if (strcmp(a->q_user, pw->pw_name) != 0) 3924174Seric { 39351317Seric a->q_user = newstr(pw->pw_name); 39451317Seric (void) strcpy(buf, pw->pw_name); 3954174Seric } 39651317Seric a->q_home = newstr(pw->pw_dir); 39751317Seric a->q_uid = pw->pw_uid; 39851317Seric a->q_gid = pw->pw_gid; 39951317Seric a->q_flags |= QGOODUID; 40051317Seric buildfname(pw->pw_gecos, pw->pw_name, nbuf); 40151317Seric if (nbuf[0] != '\0') 40251317Seric a->q_fullname = newstr(nbuf); 40351317Seric if (!quoted) 40451317Seric forward(a, sendq); 4054174Seric } 4064174Seric } 40712613Seric return (a); 4084174Seric } 4094174Seric /* 4104373Seric ** FINDUSER -- find the password entry for a user. 4114373Seric ** 4124373Seric ** This looks a lot like getpwnam, except that it may want to 4134373Seric ** do some fancier pattern matching in /etc/passwd. 4144373Seric ** 4159379Seric ** This routine contains most of the time of many sendmail runs. 4169379Seric ** It deserves to be optimized. 4179379Seric ** 4184373Seric ** Parameters: 4194373Seric ** name -- the name to match against. 4204373Seric ** 4214373Seric ** Returns: 4224373Seric ** A pointer to a pw struct. 4234373Seric ** NULL if name is unknown or ambiguous. 4244373Seric ** 4254373Seric ** Side Effects: 4264407Seric ** may modify name. 4274373Seric */ 4284373Seric 4294373Seric struct passwd * 4304373Seric finduser(name) 4314373Seric char *name; 4324373Seric { 4334376Seric register struct passwd *pw; 4344407Seric register char *p; 43515325Seric extern struct passwd *getpwent(); 43615325Seric extern struct passwd *getpwnam(); 4374373Seric 43825777Seric /* map upper => lower case */ 4394407Seric for (p = name; *p != '\0'; p++) 4404407Seric { 44125777Seric if (isascii(*p) && isupper(*p)) 44225568Seric *p = tolower(*p); 4434407Seric } 4444407Seric 44525777Seric /* look up this login name using fast path */ 44612634Seric if ((pw = getpwnam(name)) != NULL) 44712634Seric return (pw); 44812634Seric 44912634Seric /* search for a matching full name instead */ 45025777Seric for (p = name; *p != '\0'; p++) 45125777Seric { 45225777Seric if (*p == (SpaceSub & 0177) || *p == '_') 45325777Seric *p = ' '; 45425777Seric } 45523107Seric (void) setpwent(); 4564376Seric while ((pw = getpwent()) != NULL) 4574376Seric { 4584998Seric char buf[MAXNAME]; 4594376Seric 4604998Seric buildfname(pw->pw_gecos, pw->pw_name, buf); 46133725Sbostic if (index(buf, ' ') != NULL && !strcasecmp(buf, name)) 4624381Seric { 4637054Seric message(Arpa_Info, "sending to login name %s", pw->pw_name); 4644376Seric return (pw); 4654377Seric } 4664376Seric } 4674376Seric return (NULL); 4684373Seric } 4694373Seric /* 4704329Seric ** WRITABLE -- predicate returning if the file is writable. 4714329Seric ** 4724329Seric ** This routine must duplicate the algorithm in sys/fio.c. 4734329Seric ** Unfortunately, we cannot use the access call since we 4744329Seric ** won't necessarily be the real uid when we try to 4754329Seric ** actually open the file. 4764329Seric ** 4774329Seric ** Notice that ANY file with ANY execute bit is automatically 4784329Seric ** not writable. This is also enforced by mailfile. 4794329Seric ** 4804329Seric ** Parameters: 4814329Seric ** s -- pointer to a stat struct for the file. 4824329Seric ** 4834329Seric ** Returns: 4844329Seric ** TRUE -- if we will be able to write this file. 4854329Seric ** FALSE -- if we cannot write this file. 4864329Seric ** 4874329Seric ** Side Effects: 4884329Seric ** none. 4894329Seric */ 4904329Seric 4914329Seric bool 4924329Seric writable(s) 4934329Seric register struct stat *s; 4944329Seric { 4954329Seric int euid, egid; 4964329Seric int bits; 4974329Seric 4984329Seric if (bitset(0111, s->st_mode)) 4994329Seric return (FALSE); 5004329Seric euid = getruid(); 5014329Seric egid = getrgid(); 5024329Seric if (geteuid() == 0) 5034329Seric { 5044329Seric if (bitset(S_ISUID, s->st_mode)) 5054329Seric euid = s->st_uid; 5064329Seric if (bitset(S_ISGID, s->st_mode)) 5074329Seric egid = s->st_gid; 5084329Seric } 5094329Seric 5104329Seric if (euid == 0) 5114329Seric return (TRUE); 5124329Seric bits = S_IWRITE; 5134329Seric if (euid != s->st_uid) 5144329Seric { 5154329Seric bits >>= 3; 5164329Seric if (egid != s->st_gid) 5174329Seric bits >>= 3; 5184329Seric } 5194329Seric return ((s->st_mode & bits) != 0); 5204329Seric } 5214329Seric /* 5224174Seric ** INCLUDE -- handle :include: specification. 5234174Seric ** 5244174Seric ** Parameters: 5254174Seric ** fname -- filename to include. 5264176Seric ** msg -- message to print in verbose mode. 5274399Seric ** ctladdr -- address template to use to fill in these 5284399Seric ** addresses -- effective user/group id are 5294399Seric ** the important things. 5305006Seric ** sendq -- a pointer to the head of the send queue 5315006Seric ** to put these addresses in. 5324174Seric ** 5334174Seric ** Returns: 5344174Seric ** none. 5354174Seric ** 5364174Seric ** Side Effects: 5374174Seric ** reads the :include: file and sends to everyone 5384174Seric ** listed in that file. 5394174Seric */ 5404174Seric 5415006Seric include(fname, msg, ctladdr, sendq) 5424174Seric char *fname; 5434176Seric char *msg; 5444399Seric ADDRESS *ctladdr; 5455006Seric ADDRESS **sendq; 5464174Seric { 5474174Seric char buf[MAXLINE]; 5484174Seric register FILE *fp; 5496906Seric char *oldto = CurEnv->e_to; 5509379Seric char *oldfilename = FileName; 5519379Seric int oldlinenumber = LineNumber; 5524174Seric 5534174Seric fp = fopen(fname, "r"); 5544174Seric if (fp == NULL) 5554174Seric { 5564174Seric usrerr("Cannot open %s", fname); 5574174Seric return; 5584174Seric } 5594406Seric if (getctladdr(ctladdr) == NULL) 5604406Seric { 5614406Seric struct stat st; 5624174Seric 5634406Seric if (fstat(fileno(fp), &st) < 0) 5644406Seric syserr("Cannot fstat %s!", fname); 5654406Seric ctladdr->q_uid = st.st_uid; 5664406Seric ctladdr->q_gid = st.st_gid; 5674406Seric ctladdr->q_flags |= QGOODUID; 5684406Seric } 5694406Seric 5704174Seric /* read the file -- each line is a comma-separated list. */ 5719379Seric FileName = fname; 5729379Seric LineNumber = 0; 5734174Seric while (fgets(buf, sizeof buf, fp) != NULL) 5744174Seric { 5754174Seric register char *p = index(buf, '\n'); 5764174Seric 57740963Sbostic LineNumber++; 5784174Seric if (p != NULL) 5794174Seric *p = '\0'; 58051781Seric if (buf[0] == '\0' || buf[0] == '#') 5814174Seric continue; 5826906Seric CurEnv->e_to = oldto; 5837054Seric message(Arpa_Info, "%s to %s", msg, buf); 5844176Seric AliasLevel++; 5859622Seric sendtolist(buf, ctladdr, sendq); 5864176Seric AliasLevel--; 5874174Seric } 5884174Seric 5894319Seric (void) fclose(fp); 5909379Seric FileName = oldfilename; 5919379Seric LineNumber = oldlinenumber; 5924174Seric } 5934324Seric /* 5944324Seric ** SENDTOARGV -- send to an argument vector. 5954324Seric ** 5964324Seric ** Parameters: 5974324Seric ** argv -- argument vector to send to. 5984324Seric ** 5994324Seric ** Returns: 6004324Seric ** none. 6014324Seric ** 6024324Seric ** Side Effects: 6034324Seric ** puts all addresses on the argument vector onto the 6044324Seric ** send queue. 6054324Seric */ 6064324Seric 6074324Seric sendtoargv(argv) 6084324Seric register char **argv; 6094324Seric { 6104324Seric register char *p; 6114324Seric 6124324Seric while ((p = *argv++) != NULL) 6134324Seric { 61433725Sbostic if (argv[0] != NULL && argv[1] != NULL && !strcasecmp(argv[0], "at")) 6154324Seric { 6164324Seric char nbuf[MAXNAME]; 6174324Seric 6184324Seric if (strlen(p) + strlen(argv[1]) + 2 > sizeof nbuf) 6194324Seric usrerr("address overflow"); 6204324Seric else 6214324Seric { 6224324Seric (void) strcpy(nbuf, p); 6234324Seric (void) strcat(nbuf, "@"); 6244324Seric (void) strcat(nbuf, argv[1]); 6254324Seric p = newstr(nbuf); 6264324Seric argv += 2; 6274324Seric } 6284324Seric } 6299622Seric sendtolist(p, (ADDRESS *) NULL, &CurEnv->e_sendqueue); 6304324Seric } 6314324Seric } 6324399Seric /* 6334399Seric ** GETCTLADDR -- get controlling address from an address header. 6344399Seric ** 6354399Seric ** If none, get one corresponding to the effective userid. 6364399Seric ** 6374399Seric ** Parameters: 6384399Seric ** a -- the address to find the controller of. 6394399Seric ** 6404399Seric ** Returns: 6414399Seric ** the controlling address. 6424399Seric ** 6434399Seric ** Side Effects: 6444399Seric ** none. 6454399Seric */ 6464399Seric 6474399Seric ADDRESS * 6484399Seric getctladdr(a) 6494399Seric register ADDRESS *a; 6504399Seric { 6514404Seric while (a != NULL && !bitset(QGOODUID, a->q_flags)) 6524399Seric a = a->q_alias; 6534399Seric return (a); 6544399Seric } 655