Change parse to parseaddr for BB&N TCP/IP implementation; clean up
[unix-history] / usr / src / old / berknet / v6mail.c
CommitLineData
62205224
KM
1static char sccsid[] = "@(#)v6mail.c 4.1 (Berkeley) %G%";
2
3/*
4 * Version 6 Cory mail--
5 * a clean and simple mail program
6 * machine and version independent
7 * Eric Schmidt
8 * must run as setuid root to chown the destination mailbox
9 * if NOTROOT defined, doesn't need to run as root
10 *
11 * DON'T CHANGE THIS CODE
12 * bitch to "csvax:schmidt" instead
13 */
14
15/*
16 * mail command usage
17 * mail [-yn]
18 * prints your mail
19 * mail people
20 * sends standard input to people
21 *
22 * mail -r fromaddr people
23 * sends mail from the network
24 *
25 * mail -d people
26 * don't call delivermail, send mail directly
27 * mail msgs
28 * send to "msgs"
29 * mail filename
30 * mail to filename instead of user (must be at least one /)
31 * mail -D
32 * delete the invokers mailbox (more efficient than
33 * mail -n >/dev/null)
34 */
35
36/*
37 * bugs:
38 * Ingres 11/70 multiple names/uid?
39 * additions:
40 * Save? type 'x' - doesn't unlink the mail file
41 */
42/*
43 * BIFF is an immediate notification flag using the MPX stuff
44 */
45# include "local.h"
46# include <stdio.h>
47# include "mach.h"
48
49# ifdef RAND
50
51/* for all machines at RAND */
52# define MAILMODE 0644
53
54# endif RAND
55
56# ifdef NOSC
57
58/* for all machines at NOSC */
59# define MAILMODE 0644
60
61# endif NOSC
62
63# ifdef BERKELEY
64/* for Berkeley */
65/* for each machine */
66/* lump the CC machines into one */
67# ifdef CCV7
68# define MAILMODE 0600
69# define MSGSCMD "/usr/ucb/bin/msgs"
70# endif
71
72# ifdef CCV6
73# define MSGSCMD "/usr/bin/eecs/msgs"
74# define MAILMODE 0600
75# endif
76
77# ifdef ING70
78# define MAILMODE 0666
79# define MSGSCMD "/usr/bin/msgs"
80# define NOTROOT
81# endif
82
83# ifdef INGVAX
84# define MAILMODE 0644
85# define MSGSCMD "/usr/ucb/msgs"
86# endif
87
88/*
89# ifdef VIRUS
90# define MAILMODE 0644
91# define MSGSCMD "/usr/bin/msgs"
92# endif
93*/
94
95# ifdef UCBVAX
96# define MAILMODE 0644
97# define MSGSCMD "/usr/ucb/msgs"
98# define BIFF
99# endif
100
101# ifdef IMAGE
102# define MAILMODE 0644
103# define MSGSCMD "/usr/bin/msgs"
104# endif
105
106# ifdef KIM
107# define MAILMODE 0644
108# define MSGSCMD "/usr/ucb/msgs"
109# endif
110
111# ifdef ESVAX
112# define MAILMODE 0644
113# define MSGSCMD "/usr/ucb/msgs"
114# endif
115
116# ifdef Q
117# define MAILMODE 0600
118# define MSGSCMD "/usr/bin/eecs/msgs"
119# endif
120
121# ifdef ARPAVAX
122# define MAILMODE 0644
123# define MSGSCMD "/usr/ucb/msgs"
124# define BIFF
125# endif
126
127# ifdef SRC
128# define MAILMODE 0600
129# define MSGSCMD "/usr/bin/msgs"
130# endif
131
132# ifdef MATHSTAT
133# define MAILMODE 0600
134# define MSGSCMD "/usr/bin/msgs"
135# endif
136
137# ifdef CSVAX
138# define MAILMODE 0644
139# define MSGSCMD "/usr/ucb/msgs"
140# define BIFF
141# endif
142
143# ifdef ONYX
144# define MAILMODE 0644
145# define MSGSCMD "/usr/ucb/bin/msgs"
146# endif
147
148# ifdef CORY
149# define MAILMODE 0600
150# define MSGSCMD "/usr/bin/eecs/msgs"
151# endif
152
153# ifdef EECS40
154# define MAILMODE 0644
155# define MSGSCMD "/usr/bin/msgs"
156# endif
157/* end of berkeley defsn */
158
159# endif
160/* end of per-machine ifdefs */
161
162# ifdef USRMAIL
163# define MAILDIR "/usr/mail"
164# else
165# define MAILDIR "/usr/spool/mail"
166# endif
167
168char lettmp[] = "/tmp/MaXXXXX"; /* keep letter before sending it */
169char preptmp[] = "/tmp/mbXXXXX"; /* if prepending msg, use this file */
170int chew; /* if true, strip extra from lines */
171int dflag; /* if true, don't call delivermail */
172char shopcnt[30] = "0"; /* hop count parameter for rmt mail */
173int errs; /* no of errs in sending */
174char deleteonly; /* if true, just delete mailbox */
175char remname[50]; /* if non-empty, from line extra */
176
177char _sobuf[BUFSIZ];
178main(argc, argv)
179char **argv;
180{
181 register int myuid;
182 int delexit();
183 char namebuf[128], *sn = NULL, logindir[60];
184 struct passwd *pwd;
185
186 setbuf(stdout,_sobuf);
187 mktemp(lettmp);
188 mktemp(preptmp);
189 unlink(lettmp);
190 unlink(preptmp);
191 myuid = getuid();
192 logindir[0] = 0;
193 sn = getlogin();
194 if(sn == NULL || *sn == 0 || *sn == ' '){
195 pwd = getpwuid(myuid); /* will read passwd file */
196 if(pwd != NULL){
197 sn = pwd->pw_name;
198 strcpy(logindir,pwd->pw_dir);
199 }
200 if(sn == NULL){
201 fprintf(stderr,"Who are you?\n");
202 delexit(EX_OSFILE);
203 }
204 }
205 strcpy(namebuf,sn);
206 if (argc < 2)
207 goto hitit;
208 for (argc--, argv++; argc > 0 && argv[0][0] == '-'; argc--, argv++)
209 switch(argv[0][1]) {
210 case 'y':
211 case 'n':
212 argc++, argv--;
213hitit:
214 printmail(argc, argv, namebuf,logindir);
215 delexit(EX_OK);
216
217 case 'r': /* one-arg -r-- -r addr */
218 if (argc < 2)
219 continue;
220 /* ignore -r if not network or root */
221 if (strcmp("network", namebuf) == 0 || myuid == 0 ||
222 strcmp("uucp", namebuf) == 0 || index(argv[1], '!') != NULL) {
223 strcpy(namebuf,argv[1]);
224 chew++; /* eat From lines */
225 }
226 else strcpy(remname, argv[1]);
227 argc--, argv++;
228 continue;
229 case 'h': /* hop count - used by network */
230 if(argc < 2) continue;
231 strcpy(shopcnt,argv[1]);
232 argc--, argv++;
233 continue;
234 case 'd': /* really deliver this message */
235 dflag++;
236 continue;
237 case 'D': /* only delete the invokers mailbox */
238 deleteonly++;
239 goto hitit; /* delete mail box, thats all */
240 }
241 /* if we are already ignoring signals, catch sigint */
242 if(signal(SIGINT,SIG_IGN) != SIG_IGN)
243 signal(SIGINT, delexit);
244 argc++, argv--;
245 bulkmail(argc, argv, namebuf);
246 delexit(EX_OK);
247}
248
249printmail(argc, argv, name, logindir)
250char **argv;
251char *name, *logindir;
252{
253 register int c;
254 FILE *fdin;
255 char sfnmail[60], mbox[120];
256 struct stat statbuf;
257
258# ifdef OLDMAIL
259 if(logindir[0] == 0){
260 pwd = getpwuid(getuid());
261 if(pwd == NULL){
262 fprintf(stderr,"Can't get directory\n");
263 exit(EX_OSFILE);
264 }
265 strcpy(logindir, pwd->pw_dir);
266 }
267 sprintf(sfnmail,"%s/.mail",logindir);
268# else
269 sprintf(sfnmail,"%s/%s",MAILDIR,name);
270# endif
271 if(deleteonly){
272 remove(sfnmail);
273 return;
274 }
275 if (stat(sfnmail, &statbuf)>=0 && statbuf.st_nlink==1 &&
276 getsize(&statbuf) > 0L && (fdin = fopen(sfnmail, "r")) != NULL){
277 getput(fdin, stdout);
278 fclose(fdin);
279 fflush(stdout);
280 c = 'y';
281 if (argc<2) {
282 if(isatty(0)){
283 printf("Save(y-n) ?");
284 fflush(stdout);
285 c = getchar();
286 }
287 } else
288 c = argv[1][1];
289 if (!any(c, "xyn"))
290 delexit(EX_OK);
291 if (c == 'y') {
292 sprintf(mbox,"%s/mbox",logindir);
293 if (accesss(mbox)) {
294 printf("Saved mail in 'mbox'\n");
295 if(insert(sfnmail, mbox, getuid(),getgid()))
296 remove(sfnmail);
297 }
298 else printf("In wrong directory\n");
299 }
300 else if(c != 'x') remove(sfnmail);
301 } else
302 printf("No mail.\n");
303}
304
305bulkmail(argc, argv, from)
306char **argv, *from;
307{
308 extern int errno;
309 char linebuf[BUFSIZ];
310 char *getdate();
311 FILE *fdout;
312
313# ifdef DELIVERM
314 /*
315 ** Ship off to delivermail if appropriate (and possible)
316 */
317
318 if (!dflag)
319 {
320 argv[0] = "-delivermail";
321 argv[argc] = 0;
322 execv("/etc/delivermail", argv);
323 /* oops... better just deliver it. */
324 fprintf(stderr, "Not using delivermail\n");
325 errno = 0;
326 argv[argc] = (char *)-1;
327 }
328# endif
329
330 fdout = fopen(lettmp, "w");
331 if (fdout == NULL) {
332 perror(lettmp);
333 delexit(EX_OSFILE);
334 }
335 /*
336 * If delivering mail from the network via mail -r,
337 * Strip the leading line and throw it away, as long
338 * as it begins with "From ..." (and preserve the date if poss.)
339 */
340 if (chew) {
341 fgets(linebuf,BUFSIZ,stdin);
342 if(strncmp(linebuf,"From ",5) != 0){
343 fline(fdout,NULL,from);
344 fprintf(fdout,"%s", linebuf);
345 }
346 else fline(fdout,getdate(linebuf),from);
347 }
348 else fline(fdout,NULL,from);
349 if(remname[0]) fprintf(fdout,"(from %s)\n",remname);
350
351 /* on the image machine, promt with subj */
352 if(getput(stdin,fdout) == 0)
353 delexit(EX_OSERR);
354 putc('\n',fdout);
355 fclose(fdout);
356 while (--argc > 0)
357 sendto(*++argv,from);
358 delexit(errs);
359}
360/* print from line, with date date, if date = NULL, compute it */
361fline(fdout,date,from)
362FILE *fdout;
363char *date;
364char *from;
365{
366 int tbuf[2];
367
368 if(date == NULL){
369 time(tbuf);
370 date = ctime(tbuf);
371 }
372 fprintf(fdout,"From %s %s", from, date);
373}
374/* look over linebuf and return ptr to date, NULL if error */
375char *getdate(linebuf)
376char *linebuf;
377{
378 register char *s;
379 s = linebuf;
380 while(*s){
381 if(strncmp(s," Sun ",5) == 0
382 || strncmp(s," Mon ",5) == 0
383 || strncmp(s," Tue ",5) == 0
384 || strncmp(s," Wed ",5) == 0
385 || strncmp(s," Thu ",5) == 0
386 || strncmp(s," Fri ",5) == 0
387 || strncmp(s," Sat ",5) == 0)
388 return(++s);
389 s++;
390 }
391 return(NULL);
392}
393
394sendto(person, fromaddr)
395char *person;
396char *fromaddr;
397{
398 static int saved = 0;
399 register int hisuid, hisgid;
400 char sfnmail[60], logindir[60];
401 struct passwd *pwd;
402
403 stripmach(&person);
404 if(person[0] == ':')person++;
405 /* delivermail provides these services */
406 if(any(':',person)
407# ifdef MSGSCMD
408 || strcmp(person,"msgs") == 0
409# endif
410 ){
411 int pid;
412 int pidchild;
413
414 while((pid = fork()) == -1)sleep(2);
415 if (pid < 0) {
416 perror("fork");
417 goto assback;
418 }
419 if (pid == 0) {
420 fclose(stdin);
421 freopen(lettmp,"r",stdin);
422 setuid(getuid()); /* insure no security hole*/
423 if (strcmp(person,"msgs") != 0) {
424 /*
425 sendberkmail will add the machine, e.g.
426 CSVAX:schmidt, if the -f flag is not set
427 */
428 execl("/usr/net/bin/sendberkmail",
429 "sendberkmail", "-t",person,"-h",shopcnt,
430 chew ? "-f" : 0,fromaddr,0);
431 perror("/usr/net/bin/sendberkmail");
432 }
433# ifdef MSGSCMD
434 else {
435 execl(MSGSCMD, "msgs", "-s", 0);
436 perror(MSGSCMD);
437 }
438# endif
439 exit(EX_UNAVAILABLE);
440 }
441 for (;;) {
442 register int rcode = wait(&pidchild);
443 if (rcode == -1)
444 goto assback;
445 if (rcode == pid)
446 break;
447 }
448 if ((pidchild & 0377) != 0 || (pidchild >> 8) != 0)
449 goto assback;
450 return;
451 }
452
453 if(!any('/',person)){
454 /* if name has no / in it, we assume it is a user's name */
455# ifdef HPASSWD
456 hisuid = uidfromsn(person);
457# else
458 pwd = getpwnam(person);
459 if(pwd != NULL){
460 hisuid = guid(pwd->pw_uid,pwd->pw_gid);
461 hisgid = pwd->pw_gid;
462 strcpy(logindir,pwd->pw_dir);
463 }
464 else hisuid = -1;
465# endif
466 if(hisuid == -1){
467 assback:
468 fflush(stdout);
469 fprintf(stderr,"Can't send to %s.\n", person);
470 errs++;
471 if (isatty(0) && saved==0) {
472 saved++;
473 if (accesss("dead.letter")) {
474 printf("Letter saved in 'dead.letter'\n");
475 insert(lettmp, "dead.letter",
476 getuid(),getgid());
477 } else
478 printf("In wrong directory\n");
479 }
480 return;
481 }
482# ifdef OLDMAIL
483 sprintf(sfnmail,"%s/.mail",logindir);
484# else
485 sprintf(sfnmail,"%s/%s",MAILDIR,person);
486# endif
487 lock(sfnmail);
488 insert(lettmp, sfnmail, hisuid, hisgid);
489 unlock();
490 }
491 else { /* it has / in it, "person" is a file */
492 if(accesss(person)){
493 lock(person);
494 insert(lettmp, person, -1, -1);
495 unlock();
496 }
497 else
498 fprintf(stderr,"Can't access %s\n",person);
499 }
500}
501
502/* return 1 if success, 0 otherwise */
503insert(from, to, uid, gid)
504char *from, *to;
505{
506# ifdef V6
507 return(prepend(from,to,uid, gid));
508# else
509 return(append(from,to,uid, gid));
510# endif
511}
512/* return 1 if success, 0 otherwise */
513append(from,to,uid, gid)
514char *from, *to;
515{
516 register FILE *fdin, *fdout;
517 int ret;
518 struct stat statbuf;
519#ifdef BIFF
520/* biff ... */
521 char *rindex();
522 char *cp;
523 char buf[100];
524 int f;
525/* end biff */
526#endif BIFF
527 if (stat(to, &statbuf) >= 0 && (statbuf.st_mode&S_IFDIR) != 0) {
528 fprintf(stderr, "Exotic destination %s\n", to);
529 errs++;
530 return(0);
531 }
532 if ((fdout = fopen(to, "a")) == NULL) {
533 perror(to);
534 errs++;
535 return(0);
536 }
537# ifndef NOTROOT
538 if(uid != -1)mchown(to, uid, gid);
539# endif
540 if(uid != -1)chmod(to, MAILMODE);
541 if ((fdin = fopen(from, "r")) == NULL) {
542 perror(from);
543 return(0);
544 }
545#ifdef BIFF
546 {
547 f = open("/dev/mail", 1);
548 cp = rindex(to, '/');
549 if (cp) {
550 sprintf(buf, "%s@%d\n", cp+1, ftell(fdout));
551 }
552 }
553#endif BIFF
554 ret = getput(fdin,fdout);
555 fclose(fdin);
556 fclose(fdout);
557#ifdef BIFF
558 if (cp && f >= 0) {
559 write(f, buf, strlen(buf)+1);
560 close(f);
561 }
562#endif BIFF
563 return(ret);
564}
565
566/* return 1 if success, 0 otherwise */
567prepend(from, to, uid, gid)
568char *from, *to;
569{
570 register int (*sig)();
571 struct stat statbuf;
572 FILE *fdout, *fdin;
573 int ret;
574
575 if (stat(to, &statbuf) >= 0 && (statbuf.st_mode&S_IFDIR) != 0) {
576 fprintf(stderr, "Exotic destination %s\n", to);
577 goto badexit;
578 }
579 unlink(preptmp);
580 if ((fdout = fopen(preptmp, "w")) == NULL) {
581 perror("mail");
582 goto badexit;
583 }
584 chmod(preptmp, MAILMODE);
585 if ((fdin = fopen(from, "r")) == NULL) {
586 perror("mail");
587 goto badexit;
588 }
589 if(getput(fdin,fdout) == 0){
590 perror("file i/o");
591 goto badexit;
592 }
593 fclose(fdin);
594 fdin = fopen(to, "r");
595 /* ignore error since may not exist */
596 if(fdin != NULL && getput(fdin,fdout) == 0){
597 perror("file i/o");
598 goto badexit;
599 }
600 if(fdin != NULL)fclose(fdin);
601 fclose(fdout);
602 sig = signal(SIGINT, SIG_IGN);
603 remove(to);
604 if ((fdout = fopen(to, "w")) == NULL) {
605 perror(to);
606 unlink(preptmp);
607 signal(SIGINT, sig);
608 goto badexit;
609 }
610# ifdef NOTROOT
611 if(uid != -1)chmod(to,0666);
612# else
613 if(uid != -1)mchown(to, uid, gid);
614# endif
615 if(stat(to, &statbuf) < 0 || statbuf.st_nlink != 1) {
616 fclose(fdout);
617 signal(SIGINT, sig);
618 goto badexit;
619 }
620 if ((fdin = fopen(preptmp, "r")) == NULL) {
621 perror("mail");
622 signal(SIGINT, sig);
623 goto badexit;
624 }
625 ret = getput(fdin,fdout);
626 fclose(fdout);
627 fclose(fdin);
628 signal(SIGINT, sig);
629 return(ret);
630badexit:
631 unlink(preptmp);
632 errs++;
633 return(0);
634}
635
636delexit(ex)
637{
638 unlink(lettmp);
639 unlink(preptmp);
640 exit(ex);
641}
642
643/* return 1 if ok, 0 otherwise */
644getput(fdin, fdout)
645register FILE *fdin, *fdout;
646{
647 extern int errno;
648 register int c;
649
650 while((c = getc(fdin)) != EOF) {
651 errno = 0;
652 putc(c,fdout);
653 if(errno) {
654 perror("mail");
655 return(0);
656 }
657 }
658 return(1);
659}
660
661accesss(s1)
662register char *s1;
663{
664 struct stat statbuf;
665 if(stat(s1,&statbuf)<0 || access(s1,2) == 0)
666 return(1);
667 return(0);
668}
669
670any(c, str)
671 register char *str, c;
672{
673 register char *f;
674
675 f = str;
676 while (*f)
677 if (c == *f++)
678 return(1);
679 return(0);
680}
681char locktmp[30]; /* Usable lock temporary */
682char curlock[50]; /* Last used name of lock */
683int locked; /* To note that we locked it */
684
685/*
686 * Lock the specified mail file by setting the file mailfile.lock.
687 * We must, of course, be careful to unlink the lock file by a call
688 * to unlock before we stop. The algorithm used here is to see if
689 * the lock exists, and if it does, to check its modify time. If it
690 * is older than 30 seconds, we assume error and set our own file.
691 * Otherwise, we wait for 5 seconds and try again.
692 */
693
694lock(file)
695char *file;
696{
697 register int f;
698 struct stat statbuf;
699 long curtime;
700/*
701 if using OLDMAIL, and NOTROOT, cann't lock since can't necessarily
702 write on user's login directory
703*/
704# ifdef OLDMAIL
705 return;
706# endif
707
708 if (file == NULL) {
709 printf("Locked = %d\n", locked);
710 return(0);
711 }
712 if (locked)
713 return(0);
714 sprintf(curlock,"%s%s",file,".mail");
715 sprintf(locktmp,"%s/tmXXXXXX",MAILDIR);
716 mktemp(locktmp);
717 unlink(locktmp);
718 for (;;) {
719 f = lock1(locktmp, curlock);
720 if (f == 0) {
721 locked = 1;
722 return(0);
723 }
724 if (stat(curlock, &statbuf) < 0)
725 return(0);
726 time(&curtime);
727 if (curtime < statbuf.st_mtime + 30) {
728 sleep(5);
729 continue;
730 }
731 unlink(curlock);
732 }
733}
734
735/*
736 * Remove the mail lock, and note that we no longer
737 * have it locked.
738 */
739
740unlock()
741{
742
743 if (locked)
744 unlink(curlock);
745 locked = 0;
746}
747
748/*
749 * Attempt to set the lock by creating the temporary file,
750 * then doing a link/unlink. If it fails, return -1 else 0
751 */
752
753lock1(tempfile, name)
754 char tempfile[], name[];
755{
756 int fno;
757
758 fno = creat(tempfile, 0400);
759 if (fno < 0)
760 return(-1);
761 close(fno);
762 if (link(tempfile, name) < 0) {
763 unlink(tempfile);
764 return(-1);
765 }
766 unlink(tempfile);
767 return(0);
768}
769
770/*
771 stripfx(prefix string, pointer to string)
772
773 takes a ptr to string and compares it to prefix string.
774 may be called multiple times
775 returns ":username"
776*/
777stripfx(pfx, name)
778 register char *pfx;
779 register char **name;
780{
781 register char *cp = *name;
782
783 while (*pfx && (*cp == *pfx || *cp == toupper(*pfx)))
784 cp++, pfx++;
785 if (*cp != ':' || *pfx != 0)
786 return;
787 *name = cp;
788}
789stripmach(pperson)
790register char **pperson;
791{
792# ifdef RAND
793/* for machines at RAND */
794# ifdef GRAPHICS
795 stripfx("g",pperson);
796 stripfx("graphics",pperson);
797# endif
798# ifdef TP
799 stripfx("t",pperson);
800 stripfx("tp",pperson);
801# endif
802# ifdef VAX
803 stripfx("v",pperson);
804 stripfx("vax",pperson);
805# endif
806/* end of defns for Rand */
807# endif
808
809# ifdef NOSC
810/* for machines at NOSC */
811# ifdef ATTS
812 stripfx("a",pperson);
813 stripfx("atts",pperson);
814# endif
815# ifdef CCMM
816 stripfx("c",pperson);
817 stripfx("ccmm",pperson);
818# endif
819# ifdef MSSF
820 stripfx("m",pperson);
821 stripfx("mssf",pperson);
822# endif
823/* end of defns for NOSC */
824# endif
825
826# ifdef BERKELEY
827
828/* for Berkeley */
829# ifdef A
830 stripfx("a",pperson);
831# endif
832# ifdef B
833 stripfx("b",pperson);
834# endif
835# ifdef C
836 stripfx("c",pperson);
837# endif
838# ifdef D
839 stripfx("d",pperson);
840# endif
841# ifdef E
842 stripfx("e",pperson);
843# endif
844# ifdef ING70
845 stripfx("i",pperson);
846 stripfx("ing70",pperson);
847 stripfx("ingres",pperson);
848# endif
849# ifdef INGVAX
850 stripfx("j",pperson);
851 stripfx("ingvax",pperson);
852# endif
853# ifdef VIRUS
854 stripfx("k",pperson);
855 stripfx("virus",pperson);
856# endif
857# ifdef IMAGE
858 stripfx("m",pperson);
859 stripfx("image",pperson);
860# endif
861# ifdef KIM
862 stripfx("n",pperson);
863 stripfx("kim",pperson);
864# endif
865# ifdef ESVAX
866 stripfx("o",pperson);
867 stripfx("esvax",pperson);
868# endif
869# ifdef Q
870 stripfx("q",pperson);
871# endif
872# ifdef ARPAVAX
873 stripfx("r",pperson);
874 stripfx("arpavax",pperson);
875# endif
876# ifdef SRC
877 stripfx("s",pperson);
878 stripfx("src",pperson);
879# endif
880# ifdef MATHSTAT
881 stripfx("t",pperson);
882 stripfx("mathstat",pperson);
883# endif
884# ifdef CSVAX
885 stripfx("v",pperson);
886 stripfx("vax",pperson);
887 stripfx("csvax",pperson);
888# endif
889# ifdef CORY
890 stripfx("y",pperson);
891 stripfx("cory",pperson);
892# endif
893# ifdef EECS40
894 stripfx("z",pperson);
895 stripfx("eecs40",pperson);
896# endif
897/* end of berkeley defns */
898# endif
899}
900/*
901 this removes the mail file sfn by either truncating it, as required
902 on OLDMAIL systems, or unlinking it. If the unlink fails, we truncate it.
903*/
904remove(sfn)
905char *sfn;
906{
907 int i;
908# ifdef OLDMAIL
909 i = creat(sfn,0666);
910 if(i >= 0)close(i);
911# else
912 if(unlink(sfn) < 0){
913 i = creat(sfn,MAILMODE);
914 if(i >= 0)close(i);
915 }
916# endif
917}