Annotation of researchv10no/cmd/uucp/mailst.c, revision 1.1

1.1     ! root        1: /*     @(#)mailst.c    1.3     */
        !             2: 
        !             3: #include "uucp.h"
        !             4: VERSION(@(#)mailst.c   1.3);
        !             5: 
        !             6: /*
        !             7:  * fork and execute a mail command sending 
        !             8:  * string (str) to user (user).
        !             9:  * If file is non-null, the file is also sent.
        !            10:  * (this is used for mail returned to sender.)
        !            11:  *     user     -> user to send mail to
        !            12:  *     str      -> string mailed to user
        !            13:  *     infile   -> optional stdin mailed to user
        !            14:  *     errfile  -> optional stderr mailed to user
        !            15:  *
        !            16:  * a upas-ism -- call rmail and make up our own From line,
        !            17:  * so mail comes from uucp, not some arbitrary user
        !            18:  */
        !            19: char *ctime();
        !            20: long time();
        !            21: 
        !            22: mailst(user, str, infile, errfile)
        !            23: char *user, *str, *infile, *errfile;
        !            24: {
        !            25:        register FILE *fp, *fi;
        !            26:        char cmd[BUFSIZ];
        !            27:        char *c;
        !            28:        long now;
        !            29: 
        !            30:        /* get rid of some stuff that could hurt */
        !            31:        if ( (c = strpbrk(user, ";&|<>^`\\('\"")) != NULL)
        !            32:                *c = NULLCHAR;
        !            33:        (void) sprintf(cmd, "%s rmail %s", PATH, user);
        !            34:        if ((fp = popen(cmd, "w")) == NULL)
        !            35:                return;
        !            36:        now = time((long *)0);
        !            37:        fprintf(fp, "From uucp %.24s remote from %s\n", ctime(&now), Myname);
        !            38:        fprintf(fp, "From: %s!uucp\n", Myname);
        !            39:        (void) fprintf(fp, "%s\n", str);
        !            40: 
        !            41:        /* copy back stderr */
        !            42:        if (*errfile != '\0' && NOTEMPTY(errfile) && (fi = fopen(errfile, "r")) != NULL) {
        !            43:                fputs("\n\t===== stderr was =====\n", fp);
        !            44:                if (xfappend(fi, fp) != SUCCESS)
        !            45:                        fputs("\n\t===== well, i tried =====\n", fp);
        !            46:                (void) fclose(fi);
        !            47:                fputc('\n', fp);
        !            48:        }
        !            49: 
        !            50:        /* copy back stdin */
        !            51:        if (*infile != '\0' && NOTEMPTY(infile) && (fi = fopen(infile, "r")) != NULL) {
        !            52:                fputs("\n\t===== stdin was =====\n", fp);
        !            53:                if (xfappend(fi, fp) != SUCCESS)
        !            54:                        fputs("\n\t===== well, i tried =====\n", fp);
        !            55:                (void) fclose(fi);
        !            56:                fputc('\n', fp);
        !            57:        }
        !            58: 
        !            59:        (void) pclose(fp);
        !            60: }
        !            61: #ifndef        V7
        !            62: static char un[2*NAMESIZE];
        !            63: setuucp(p)
        !            64: char *p;
        !            65: {
        !            66:    char **envp;
        !            67: 
        !            68:     envp = Env;
        !            69:     for ( ; *envp; envp++) {
        !            70:        if(PREFIX("LOGNAME", *envp)) {
        !            71:            (void) sprintf(un, "LOGNAME=%s",p);
        !            72:            envp[0] = &un[0];
        !            73:        }
        !            74:     }
        !            75: }
        !            76: #else
        !            77: /*ARGSUSED*/
        !            78: setuucp(p) char        *p; {}
        !            79: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.