⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rmail.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
	continue;    if (err[0] || mbox[0] == NULL)	return RETURN;    if (index (mbox, '!') || host[0] == NULL)	return UUCP;    if (rp_isgood (lookup (origsys, Okhosts)))	return ADDROK;    if (index (host, '@') || rp_isbad (okhost (host)))	return RETURN;    return ADDROK;}okhost(host)             /* Host permitted to use mail facilities? */char *host;{	if (rp_isgood (lookup (origsys, Okhosts)))		return (RP_OK);		/* Fully privledged originator */	if (rp_isgood (lookup (host, Okhosts)))		return (RP_OK);		/* Fully privledged dest */	if (rp_isgood (lookup (host, Okdests)))		return (RP_OK);		/* Unrestricted Dest. Host, OK */	return(RP_NO);			/* Not permitted; must be bad */}/*  *//* *	lookup()  --	This lookup function looks for strings which *			must be the first string on a line.  Sorry Dave (dhc) *			but the MMDF channel functions are too specific *			to be easily used here without much kludging. *//*********************************************	Can this be a call to a MMDF function??****	Remember I have the RHOSTs table and the OKHOSTS table.******************************************/lookup (what, where)char *what, *where;{	FILE *lookf;	char entry[LINESIZE];	char *cp;	if ((lookf = fopen (where, "r")) == NULL)		return (RP_NO);		/* Unknown problem */	while (fgets (entry, sizeof entry, lookf) != NULL) {		cp = entry;		while (*cp != '\n' && *cp != ' ' && *cp != '\t')			cp++;		*cp = 0;		if (lexequ (what, entry)) {			fclose (lookf);			return (RP_OK);		}	}	fclose (lookf);	return (RP_NO);}/*  */char *rtnmessage[] = {	"	Your message has been intercepted trying to access\n",	"a restricted access host (e.g. an ARPANET host).  A copy\n",	"of your message has been sent to the system administrators.\n",	"The text of your message follows.\n\n",	"  --------------- Returned Mail Follows --------------\n",	0};rtnmesg (badadr)char *badadr;{	char **cpp;	fprintf (pipef, "Subject:  Illegal Address (%s)\n\n", badadr);	for (cpp = rtnmessage; *cpp; cpp++)		fputs (*cpp, pipef);}txtcpy (frm, to)FILE *frm, *to;{	char buffer[BUFSIZ];	int nread;	while (!pbroke && (nread = fread (buffer, sizeof (*buffer), BUFSIZ, frm)) > 0)		fwrite (buffer, sizeof (*buffer), nread, to);	return (ferror (frm) ? RP_LIO : RP_OK );}/*  */xsubmit (date, from, to, cc, realto)char *date, *from, *to, *cc, *realto;{    char    cmdstr[LINESIZE],            submit[LINESIZE];    getfpath (pathsubmit, cmddfldir, submit);    sprintf (cmdstr, "%s '-mlti%s*'", submit, UucpChan ());#ifndef RUNALON    if ((pipef = popen (cmdstr, "w")) == NULL)	return (RP_NO);#else    pipef = stdout;    printf ("%s\n", cmdstr);#endif    fprintf (pipef, "%s\n%s\n!\n", from, realto);    if (date) {	fprintf (pipef, "Date:     %s\n", date);	fprintf (pipef, "From:     %s\n", from);    }    if (to) {	fprintf (pipef, "To:       %s", to);	if (index (to, '@'))	    fputc ('\n', pipef);/* Explicit host specified */	else	    fprintf (pipef, "@%s\n", LocalName ());    }    if (cc) {	fprintf (pipef, "Cc:       %s\n", cc);    }    return (RP_OK);}/*  */xuucp (from, to)char *from, *to;{	char	cmdstr[LINESIZE];	sprintf (cmdstr, "/etc/delivermail -r%s -ep -m -s -i %s", from, to);#ifndef RUNALON	if ((pipef = popen (cmdstr, "w")) == NULL)		return (RP_NO);#else	pipef = stdout;	printf ("%s\n", cmdstr);#endif	return (RP_OK);}/*  */brpipe()	/* catch broken-pipe signals */{	signal(SIGPIPE, SIG_IGN);	pbroke = 1;}char *oopsmessage[] = {    "\n\n\tThe system administrators (%s) have been informed of the\n",    "problem, but have not been given a copy of your message.\n",    NULL};/*  */rcpy () {    int     i;    char    buffer[BUFSIZ],	    message[BUFSIZ];    FILE * fp;    ll_log (logptr, LLOGGEN, "Advising %s of failure as %s...", from, usrfrm);    sprintf (buffer, "Problems sending mail:\n\n");    if (ml_1adr (NO, NO, sitesignature, "Problems sending mail", usrfrm)	    != OK)	goto ml_err;    ml_txt (buffer);    if ((fp = fopen (Errtmp, "r")) != NULL) {	ml_file (fp);	if (ftell (fp) == 0L)	    fprintf (pipef, "\tunknown problem\n");	fclose (fp);    }    else	ml_txt ("\tunknown problem\n");    for (i = 0; oopsmessage[i]; i++) {	sprintf (message, oopsmessage[i], supportaddr);	ml_txt (message);    }    fprintf (pipef, "\n\nReturned message follows:\n\n---------------\n\n");    rewind (fromf);    ml_file (fromf);    rewind (msgf);    ml_file (msgf);    if (ml_end (OK) != OK) {	char   *cp;ml_err: ;	if (cp = index (buffer, '\n'))	    *cp = NULL;	ll_log (logptr, LLOGFAT, "Unable to post failure notice");	ll_log (logptr, LLOGFAT, "info: %s", buffer);    }}/*  */zcpy () {    char    buffer[BUFSIZ];    FILE * fp;    ll_log (logptr, LLOGGEN, "Advising %s of failure...", supportaddr);    sprintf (buffer, "Problems sending mail for %s (aka %s):\n\n",	    from, usrfrm);    if (ml_1adr (NO, NO, sitesignature, "Problems sending mail", supportaddr)	    != OK)	goto ml_err;    ml_txt (buffer);    if ((fp = fopen (Errtmp, "r")) != NULL) {	ml_file (fp);	if (ftell (fp) == 0L)	    fprintf (pipef, "\tunknown problem\n");	fclose (fp);    }    else	ml_txt ("\tunable to open error file\n");    if (ml_end (OK) != OK) {	char   *cp;ml_err: ;	if (cp = index (buffer, '\n'))	    *cp = NULL;	ll_log (logptr, LLOGFAT, "Unable to post failure notice");	ll_log (logptr, LLOGFAT, "info: %s", buffer);    }}/*  */mf_get_msg () {    int     i,            fd,            md,            td;    char    buffer[BUFSIZ],            tmpfil[LINESIZE],            mmdfil[LINESIZE];#ifdef	MFDEBUG    FILE * fp;#endif	MFDEBUG    FILE * out;    strcpy (tmpfil, "/tmp/rmailXXXXXX");    unlink (mktemp (tmpfil));    if ((fd = creat (tmpfil, Tmpmode)) == NOTOK)	return NOTOK;    close (fd);    if ((fd = open (tmpfil, 2)) == NOTOK)	return NOTOK;    if ((out = fdopen (fd, "w")) == NULL) {	close (fd);	return NOTOK;    }    if ((td = dup (fd)) == NOTOK) {	close (fd);	return NOTOK;    }    fprintf (out, "From %s %s\n", from, date);    if (rp_isbad (txtcpy (msgf, out))) {	close (fd);	close (td);	return NOTOK;    }    fclose (out);    lseek (td, (off_t)0, 0);    strcpy (mmdfil, "/tmp/mmdfXXXXXX");    unlink (mktemp (mmdfil));    if ((fd = creat (mmdfil, Tmpmode)) == NOTOK) {	close (td);	unlink (tmpfil);	return NOTOK;    }    if ((fd = open (mmdfil, 2)) == NOTOK) {	close (td);	unlink (tmpfil);	return NOTOK;    }    if ((md = dup (fd)) == NOTOK) {	close (td);	unlink (tmpfil);	close (fd);	return NOTOK;    }/*  */    switch (i = uucp_to_mmdf (td, fd, TRUE)) {	case OK: 	    lseek (md, (off_t)0, 0);	    if ((mmdf = fdopen (md, "r")) != NULL)		break;	default: 	    close (md);	    sprintf (buffer, "rmail(%d) filtering failed(%d)\n",		    getpid (), i);	    if (ml_1adr (NO, NO, sitesignature, "MF Failure", supportaddr)		    != OK)		goto ml_err;	    ml_txt (buffer);#ifdef	MFDEBUG	    lseek (td, (off_t)0, 0);	    if ((md = dup (td)) == NOTOK)		ml_txt ("unable to dup() descriptor for message copy\n");	    else		if ((fp = fdopen (md, "r")) == NULL) {		    ml_txt ("unable to fdopen() descriptor for message copy\n");		    close (md);		}		else {		    ml_txt ("\n  --Message Follows--\n");		    ml_file (fp);		    fclose (fp);		}#endif	MFDEBUG	    if (ml_end (OK) != OK) {		char   *cp;	ml_err: ;		if (cp = index (buffer, '\n'))		    *cp = NULL;		ll_log (logptr, LLOGFAT, "Unable to post failure notice");		ll_log (logptr, LLOGFAT, "info: %s", buffer);	    }	    md = NOTOK;	    break;    }    close (td);    unlink (tmpfil);    close (fd);    unlink (mmdfil);    return md;}/*  */mf_get_addr (from, to)char *from,     *to;{    struct adrx *adrxp,               *seekadrx ();    *to = NULL;    if ((adrxp = seekadrx (from)) == NULL)	return;    addr_convert (adrxp, to, TRUE);    while (seekadrx (NULL))	continue;    return;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -