[BACK]Return to sendbug.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / sendbug

Annotation of src/usr.bin/sendbug/sendbug.c, Revision 1.45

1.45    ! ray         1: /*     $OpenBSD: sendbug.c,v 1.44 2007/05/06 04:50:26 ray Exp $        */
1.1       ray         2:
                      3: /*
                      4:  * Written by Ray Lai <ray@cyth.net>.
                      5:  * Public domain.
                      6:  */
                      7:
                      8: #include <sys/types.h>
                      9: #include <sys/mman.h>
                     10: #include <sys/param.h>
                     11: #include <sys/stat.h>
                     12: #include <sys/sysctl.h>
                     13: #include <sys/wait.h>
                     14:
1.13      ray        15: #include <ctype.h>
1.1       ray        16: #include <err.h>
                     17: #include <errno.h>
                     18: #include <fcntl.h>
                     19: #include <limits.h>
                     20: #include <paths.h>
                     21: #include <pwd.h>
1.15      deraadt    22: #include <signal.h>
1.1       ray        23: #include <stdio.h>
                     24: #include <stdlib.h>
                     25: #include <string.h>
                     26: #include <unistd.h>
                     27:
                     28: #include "atomicio.h"
                     29:
1.35      ray        30: #define _PATH_DMESG "/var/run/dmesg.boot"
                     31:
1.39      ray        32: int    checkfile(const char *);
1.36      ray        33: void   dmesg(FILE *);
1.42      ray        34: int    editit(const char *);
1.21      deraadt    35: void   init(void);
1.40      ray        36: int    matchline(const char *, const char *, size_t);
1.21      deraadt    37: int    prompt(void);
1.32      ray        38: int    send_file(const char *, int);
1.21      deraadt    39: int    sendmail(const char *);
                     40: void   template(FILE *);
1.1       ray        41:
                     42: const char *categories = "system user library documentation ports kernel "
                     43:     "alpha amd64 arm i386 m68k m88k mips ppc sgi sparc sparc64 vax";
1.11      deraadt    44: char *version = "4.2";
                     45:
                     46: struct passwd *pw;
1.14      deraadt    47: char os[BUFSIZ], rel[BUFSIZ], mach[BUFSIZ], details[BUFSIZ];
1.21      deraadt    48: char *fullname, *tmppath;
1.12      tedu       49: int wantcleanup;
1.11      deraadt    50:
1.12      tedu       51: __dead void
1.3       deraadt    52: usage(void)
                     53: {
1.41      ray        54:        extern char *__progname;
                     55:
                     56:        fprintf(stderr, "usage: %s [-DLPV]\n", __progname);
1.12      tedu       57:        exit(1);
                     58: }
                     59:
                     60: void
                     61: cleanup()
                     62: {
                     63:        if (wantcleanup && tmppath && unlink(tmppath) == -1)
                     64:                warn("unlink");
1.3       deraadt    65: }
                     66:
1.12      tedu       67:
1.1       ray        68: int
                     69: main(int argc, char *argv[])
                     70: {
1.35      ray        71:        int ch, c, Dflag = 0, fd, ret = 1;
1.15      deraadt    72:        const char *tmpdir;
1.19      deraadt    73:        struct stat sb;
1.15      deraadt    74:        char *pr_form;
1.1       ray        75:        time_t mtime;
1.2       deraadt    76:        FILE *fp;
1.3       deraadt    77:
1.35      ray        78:        while ((ch = getopt(argc, argv, "DLPV")) != -1)
1.3       deraadt    79:                switch (ch) {
1.35      ray        80:                case 'D':
                     81:                        Dflag = 1;
                     82:                        break;
1.3       deraadt    83:                case 'L':
                     84:                        printf("Known categories:\n");
                     85:                        printf("%s\n\n", categories);
                     86:                        exit(0);
                     87:                case 'P':
1.12      tedu       88:                        init();
1.3       deraadt    89:                        template(stdout);
                     90:                        exit(0);
1.5       deraadt    91:                case 'V':
                     92:                        printf("%s\n", version);
                     93:                        exit(0);
1.3       deraadt    94:                default:
                     95:                        usage();
1.7       deraadt    96:                }
1.35      ray        97:        argc -= optind;
                     98:        argv += optind;
1.7       deraadt    99:
1.37      ray       100:        if (argc > 0)
1.3       deraadt   101:                usage();
1.1       ray       102:
                    103:        if ((tmpdir = getenv("TMPDIR")) == NULL || tmpdir[0] == '\0')
                    104:                tmpdir = _PATH_TMP;
1.9       ray       105:        if (asprintf(&tmppath, "%s%sp.XXXXXXXXXX", tmpdir,
1.19      deraadt   106:            tmpdir[strlen(tmpdir) - 1] == '/' ? "" : "/") == -1)
1.12      tedu      107:                err(1, "asprintf");
1.1       ray       108:        if ((fd = mkstemp(tmppath)) == -1)
                    109:                err(1, "mkstemp");
1.12      tedu      110:        wantcleanup = 1;
                    111:        atexit(cleanup);
1.19      deraadt   112:        if ((fp = fdopen(fd, "w+")) == NULL)
1.12      tedu      113:                err(1, "fdopen");
1.1       ray       114:
1.12      tedu      115:        init();
1.1       ray       116:
1.10      deraadt   117:        pr_form = getenv("PR_FORM");
                    118:        if (pr_form) {
                    119:                char buf[BUFSIZ];
                    120:                size_t len;
                    121:                FILE *frfp;
                    122:
                    123:                frfp = fopen(pr_form, "r");
                    124:                if (frfp == NULL) {
1.41      ray       125:                        warn("can't seem to read your template file "
                    126:                            "(`%s'), ignoring PR_FORM", pr_form);
1.10      deraadt   127:                        template(fp);
                    128:                } else {
                    129:                        while (!feof(frfp)) {
                    130:                                len = fread(buf, 1, sizeof buf, frfp);
                    131:                                if (len == 0)
                    132:                                        break;
                    133:                                if (fwrite(buf, 1, len, fp) != len)
                    134:                                        break;
                    135:                        }
                    136:                        fclose(frfp);
                    137:                }
1.35      ray       138:        } else {
1.10      deraadt   139:                template(fp);
1.36      ray       140:                if (!Dflag)
                    141:                        dmesg(fp);
1.35      ray       142:        }
1.1       ray       143:
1.19      deraadt   144:        if (fflush(fp) == EOF || fstat(fd, &sb) == -1 || fclose(fp) == EOF)
1.12      tedu      145:                err(1, "error creating template");
1.1       ray       146:        mtime = sb.st_mtime;
                    147:
                    148:  edit:
1.28      ray       149:        if (editit(tmppath) == -1 && errno != ECHILD)
                    150:                err(1, "error running editor");
1.1       ray       151:
1.19      deraadt   152:        if (stat(tmppath, &sb) == -1)
1.12      tedu      153:                err(1, "stat");
1.19      deraadt   154:        if (mtime == sb.st_mtime)
1.12      tedu      155:                errx(1, "report unchanged, nothing sent");
1.1       ray       156:
                    157:  prompt:
1.39      ray       158:        if (!checkfile(tmppath))
                    159:                fprintf(stderr, "fields are blank, must be filled in\n");
1.1       ray       160:        c = prompt();
                    161:        switch (c) {
1.5       deraadt   162:        case 'a':
                    163:        case EOF:
1.12      tedu      164:                wantcleanup = 0;
                    165:                errx(1, "unsent report in %s", tmppath);
1.1       ray       166:        case 'e':
                    167:                goto edit;
                    168:        case 's':
                    169:                if (sendmail(tmppath) == -1)
                    170:                        goto quit;
                    171:                break;
                    172:        default:
                    173:                goto prompt;
                    174:        }
                    175:
                    176:        ret = 0;
1.12      tedu      177: quit:
1.1       ray       178:        return (ret);
1.36      ray       179: }
                    180:
                    181: void
                    182: dmesg(FILE *fp)
                    183: {
                    184:        char buf[BUFSIZ];
                    185:        FILE *dfp;
                    186:        off_t offset = -1;
                    187:
                    188:        dfp = fopen(_PATH_DMESG, "r");
                    189:        if (dfp == NULL) {
                    190:                warn("can't read dmesg");
                    191:                return;
                    192:        }
                    193:
                    194:        fputs("\n"
                    195:            "<dmesg is attached.>\n"
                    196:            "<Feel free to delete or use the -D flag if it contains "
                    197:            "sensitive information.>\n", fp);
                    198:        /* Find last line starting with "OpenBSD". */
                    199:        for (;;) {
                    200:                off_t o;
                    201:
                    202:                o = ftello(dfp);
                    203:                if (fgets(buf, sizeof(buf), dfp) == NULL)
                    204:                        break;
                    205:                if (!strncmp("OpenBSD ", buf, sizeof("OpenBSD ") - 1))
                    206:                        offset = o;
                    207:        }
                    208:        if (offset != -1) {
                    209:                size_t len;
                    210:
                    211:                clearerr(dfp);
                    212:                fseeko(dfp, offset, SEEK_SET);
                    213:                while (offset != -1 && !feof(dfp)) {
                    214:                        len = fread(buf, 1, sizeof buf, dfp);
                    215:                        if (len == 0)
                    216:                                break;
                    217:                        if (fwrite(buf, 1, len, fp) != len)
                    218:                                break;
                    219:                }
                    220:        }
                    221:        fclose(dfp);
1.1       ray       222: }
                    223:
1.15      deraadt   224: int
1.42      ray       225: editit(const char *pathname)
1.15      deraadt   226: {
1.19      deraadt   227:        char *argp[] = {"sh", "-c", NULL, NULL}, *ed, *p;
1.25      ray       228:        sig_t sighup, sigint, sigquit;
1.42      ray       229:        pid_t pid;
1.45    ! ray       230:        int saved_errno, st;
1.15      deraadt   231:
1.26      ray       232:        ed = getenv("VISUAL");
                    233:        if (ed == NULL || ed[0] == '\0')
                    234:                ed = getenv("EDITOR");
                    235:        if (ed == NULL || ed[0] == '\0')
1.15      deraadt   236:                ed = _PATH_VI;
1.38      ray       237:        if (asprintf(&p, "%s %s", ed, pathname) == -1)
1.18      ray       238:                return (-1);
1.15      deraadt   239:        argp[2] = p;
                    240:
1.25      ray       241:        sighup = signal(SIGHUP, SIG_IGN);
                    242:        sigint = signal(SIGINT, SIG_IGN);
                    243:        sigquit = signal(SIGQUIT, SIG_IGN);
1.44      ray       244:  top:
1.23      ray       245:        if ((pid = fork()) == -1) {
1.45    ! ray       246:                saved_errno = errno;
1.16      ray       247:
                    248:                if (saved_errno == EAGAIN) {
1.15      deraadt   249:                        sleep(1);
                    250:                        goto top;
                    251:                }
1.44      ray       252:                (void)signal(SIGHUP, sighup);
                    253:                (void)signal(SIGINT, sigint);
                    254:                (void)signal(SIGQUIT, sigquit);
1.27      ray       255:                free(p);
1.24      ray       256:                errno = saved_errno;
1.18      ray       257:                return (-1);
1.15      deraadt   258:        }
                    259:        if (pid == 0) {
                    260:                execv(_PATH_BSHELL, argp);
                    261:                _exit(127);
                    262:        }
                    263:        free(p);
                    264:        for (;;) {
1.43      ray       265:                if (waitpid(pid, &st, 0) == -1) {
1.45    ! ray       266:                        if (errno != EINTR) {
        !           267:                                saved_errno = errno;
        !           268:                                (void)signal(SIGHUP, sighup);
        !           269:                                (void)signal(SIGINT, sigint);
        !           270:                                (void)signal(SIGQUIT, sigquit);
        !           271:                                errno = saved_errno;
1.21      deraadt   272:                                return (-1);
1.45    ! ray       273:                        }
1.43      ray       274:                } else
1.15      deraadt   275:                        break;
                    276:        }
1.25      ray       277:        (void)signal(SIGHUP, sighup);
                    278:        (void)signal(SIGINT, sigint);
                    279:        (void)signal(SIGQUIT, sigquit);
1.27      ray       280:        if (!WIFEXITED(st) || WEXITSTATUS(st) != 0) {
                    281:                errno = ECHILD;
1.18      ray       282:                return (-1);
1.27      ray       283:        }
1.18      ray       284:        return (0);
1.15      deraadt   285: }
1.12      tedu      286:
1.1       ray       287: int
                    288: prompt(void)
                    289: {
                    290:        int c, ret;
                    291:
                    292:        fpurge(stdin);
                    293:        fprintf(stderr, "a)bort, e)dit, or s)end: ");
                    294:        fflush(stderr);
                    295:        ret = getchar();
                    296:        if (ret == EOF || ret == '\n')
                    297:                return (ret);
                    298:        do {
                    299:                c = getchar();
                    300:        } while (c != EOF && c != '\n');
                    301:        return (ret);
                    302: }
                    303:
                    304: int
1.38      ray       305: sendmail(const char *pathname)
1.1       ray       306: {
                    307:        int filedes[2];
                    308:
                    309:        if (pipe(filedes) == -1) {
1.38      ray       310:                warn("pipe: unsent report in %s", pathname);
1.1       ray       311:                return (-1);
                    312:        }
                    313:        switch (fork()) {
                    314:        case -1:
                    315:                warn("fork error: unsent report in %s",
1.38      ray       316:                    pathname);
1.1       ray       317:                return (-1);
                    318:        case 0:
                    319:                close(filedes[1]);
                    320:                if (dup2(filedes[0], STDIN_FILENO) == -1) {
                    321:                        warn("dup2 error: unsent report in %s",
1.38      ray       322:                            pathname);
1.1       ray       323:                        return (-1);
                    324:                }
                    325:                close(filedes[0]);
                    326:                execl("/usr/sbin/sendmail", "sendmail",
1.2       deraadt   327:                    "-oi", "-t", (void *)NULL);
1.1       ray       328:                warn("sendmail error: unsent report in %s",
1.38      ray       329:                    pathname);
1.1       ray       330:                return (-1);
                    331:        default:
                    332:                close(filedes[0]);
                    333:                /* Pipe into sendmail. */
1.38      ray       334:                if (send_file(pathname, filedes[1]) == -1) {
1.1       ray       335:                        warn("send_file error: unsent report in %s",
1.38      ray       336:                            pathname);
1.1       ray       337:                        return (-1);
                    338:                }
                    339:                close(filedes[1]);
                    340:                wait(NULL);
                    341:                break;
                    342:        }
                    343:        return (0);
                    344: }
                    345:
1.12      tedu      346: void
1.1       ray       347: init(void)
                    348: {
1.33      ray       349:        size_t amp, len, gecoslen, namelen;
1.1       ray       350:        int sysname[2];
1.33      ray       351:        char ch, *cp;
1.1       ray       352:
1.19      deraadt   353:        if ((pw = getpwuid(getuid())) == NULL)
1.12      tedu      354:                err(1, "getpwuid");
1.13      ray       355:        namelen = strlen(pw->pw_name);
1.1       ray       356:
1.31      moritz    357:        /* Count number of '&'. */
1.33      ray       358:        for (amp = 0, cp = pw->pw_gecos; *cp && *cp != ','; ++cp)
                    359:                if (*cp == '&')
1.31      moritz    360:                        ++amp;
1.33      ray       361:
                    362:        /* Truncate gecos to full name. */
                    363:        gecoslen = cp - pw->pw_gecos;
                    364:        pw->pw_gecos[gecoslen] = '\0';
                    365:
1.31      moritz    366:        /* Expanded str = orig str - '&' chars + concatenated logins. */
1.33      ray       367:        len = gecoslen - amp + (amp * namelen) + 1;
                    368:        if ((fullname = malloc(len)) == NULL)
1.12      tedu      369:                err(1, "malloc");
1.19      deraadt   370:
1.33      ray       371:        /* Upper case first char of login. */
                    372:        ch = pw->pw_name[0];
                    373:        pw->pw_name[0] = toupper((unsigned char)pw->pw_name[0]);
                    374:
                    375:        cp = pw->pw_gecos;
                    376:        fullname[0] = '\0';
                    377:        while (cp != NULL) {
                    378:                char *token;
                    379:
                    380:                token = strsep(&cp, "&");
                    381:                if (token != pw->pw_gecos &&
                    382:                    strlcat(fullname, pw->pw_name, len) >= len)
                    383:                        errx(1, "truncated string");
                    384:                if (strlcat(fullname, token, len) >= len)
                    385:                        errx(1, "truncated string");
1.13      ray       386:        }
1.33      ray       387:        /* Restore case of first char of login. */
                    388:        pw->pw_name[0] = ch;
1.1       ray       389:
                    390:        sysname[0] = CTL_KERN;
                    391:        sysname[1] = KERN_OSTYPE;
                    392:        len = sizeof(os) - 1;
1.19      deraadt   393:        if (sysctl(sysname, 2, &os, &len, NULL, 0) == -1)
1.12      tedu      394:                err(1, "sysctl");
1.1       ray       395:
                    396:        sysname[0] = CTL_KERN;
                    397:        sysname[1] = KERN_OSRELEASE;
                    398:        len = sizeof(rel) - 1;
1.19      deraadt   399:        if (sysctl(sysname, 2, &rel, &len, NULL, 0) == -1)
1.12      tedu      400:                err(1, "sysctl");
1.1       ray       401:
1.14      deraadt   402:        sysname[0] = CTL_KERN;
                    403:        sysname[1] = KERN_VERSION;
                    404:        len = sizeof(details) - 1;
1.19      deraadt   405:        if (sysctl(sysname, 2, &details, &len, NULL, 0) == -1)
1.14      deraadt   406:                err(1, "sysctl");
                    407:
                    408:        cp = strchr(details, '\n');
                    409:        if (cp) {
                    410:                cp++;
                    411:                if (*cp)
                    412:                        *cp++ = '\t';
                    413:                if (*cp)
                    414:                        *cp++ = '\t';
                    415:                if (*cp)
                    416:                        *cp++ = '\t';
                    417:        }
                    418:
1.1       ray       419:        sysname[0] = CTL_HW;
                    420:        sysname[1] = HW_MACHINE;
                    421:        len = sizeof(mach) - 1;
1.19      deraadt   422:        if (sysctl(sysname, 2, &mach, &len, NULL, 0) == -1)
1.12      tedu      423:                err(1, "sysctl");
1.1       ray       424: }
                    425:
                    426: int
                    427: send_file(const char *file, int dst)
                    428: {
1.2       deraadt   429:        int blank = 0;
                    430:        size_t len;
                    431:        char *buf;
1.1       ray       432:        FILE *fp;
                    433:
                    434:        if ((fp = fopen(file, "r")) == NULL)
                    435:                return (-1);
                    436:        while ((buf = fgetln(fp, &len))) {
                    437:                /* Skip lines starting with "SENDBUG". */
                    438:                if (len >= sizeof("SENDBUG") - 1 &&
                    439:                    memcmp(buf, "SENDBUG", sizeof("SENDBUG") - 1) == 0)
                    440:                        continue;
                    441:                if (len == 1 && buf[0] == '\n')
                    442:                        blank = 1;
                    443:                /* Skip comments, but only if we encountered a blank line. */
                    444:                while (len) {
1.14      deraadt   445:                        char *sp = NULL, *ep = NULL;
1.1       ray       446:                        size_t copylen;
                    447:
                    448:                        if (blank && (sp = memchr(buf, '<', len)) != NULL)
                    449:                                ep = memchr(sp, '>', len - (sp - buf + 1));
                    450:                        /* Length of string before comment. */
1.4       ray       451:                        if (ep)
                    452:                                copylen = sp - buf;
                    453:                        else
                    454:                                copylen = len;
1.1       ray       455:                        if (atomicio(vwrite, dst, buf, copylen) != copylen) {
                    456:                                int saved_errno = errno;
                    457:
                    458:                                fclose(fp);
                    459:                                errno = saved_errno;
                    460:                                return (-1);
                    461:                        }
                    462:                        if (!ep)
                    463:                                break;
                    464:                        /* Skip comment. */
                    465:                        len -= ep - buf + 1;
                    466:                        buf = ep + 1;
                    467:                }
                    468:        }
                    469:        fclose(fp);
                    470:        return (0);
1.39      ray       471: }
                    472:
                    473: /*
                    474:  * Does line start with `s' and end with non-comment and non-whitespace?
1.40      ray       475:  * Note: Does not treat `line' as a C string.
1.39      ray       476:  */
                    477: int
1.40      ray       478: matchline(const char *s, const char *line, size_t linelen)
1.39      ray       479: {
                    480:        size_t slen;
                    481:        int comment;
                    482:
                    483:        slen = strlen(s);
                    484:        /* Is line shorter than string? */
                    485:        if (linelen <= slen)
                    486:                return (0);
                    487:        /* Does line start with string? */
                    488:        if (memcmp(line, s, slen) != 0)
                    489:                return (0);
                    490:        /* Does line contain anything but comments and whitespace? */
                    491:        line += slen;
                    492:        linelen -= slen;
                    493:        comment = 0;
                    494:        while (linelen) {
                    495:                if (comment) {
                    496:                        if (*line == '>')
                    497:                                comment = 0;
                    498:                } else if (*line == '<')
                    499:                        comment = 1;
1.40      ray       500:                else if (!isspace((unsigned char)*line))
1.39      ray       501:                        return (1);
                    502:                ++line;
                    503:                --linelen;
                    504:        }
                    505:        return (0);
                    506: }
                    507:
                    508: /*
                    509:  * Are all required fields filled out?
                    510:  */
                    511: int
                    512: checkfile(const char *pathname)
                    513: {
                    514:        FILE *fp;
                    515:        size_t len;
                    516:        int category, class, priority, release, severity, synopsis;
                    517:        char *buf;
                    518:
                    519:        if ((fp = fopen(pathname, "r")) == NULL) {
                    520:                warn("%s", pathname);
                    521:                return (0);
                    522:        }
                    523:        category = class = priority = release = severity = synopsis = 0;
                    524:        while ((buf = fgetln(fp, &len))) {
                    525:                if (matchline(">Category:", buf, len))
                    526:                        category = 1;
                    527:                else if (matchline(">Class:", buf, len))
                    528:                        class = 1;
                    529:                else if (matchline(">Priority:", buf, len))
                    530:                        priority = 1;
                    531:                else if (matchline(">Release:", buf, len))
                    532:                        release = 1;
                    533:                else if (matchline(">Severity:", buf, len))
                    534:                        severity = 1;
                    535:                else if (matchline(">Synopsis:", buf, len))
                    536:                        synopsis = 1;
                    537:        }
                    538:        fclose(fp);
                    539:        return (category && class && priority && release && severity &&
                    540:            synopsis);
1.1       ray       541: }
                    542:
                    543: void
                    544: template(FILE *fp)
                    545: {
                    546:        fprintf(fp, "SENDBUG: -*- sendbug -*-\n");
1.19      deraadt   547:        fprintf(fp, "SENDBUG: Lines starting with `SENDBUG' will"
                    548:            " be removed automatically, as\n");
                    549:        fprintf(fp, "SENDBUG: will all comments (text enclosed in `<' and `>').\n");
1.1       ray       550:        fprintf(fp, "SENDBUG:\n");
                    551:        fprintf(fp, "SENDBUG: Choose from the following categories:\n");
                    552:        fprintf(fp, "SENDBUG:\n");
                    553:        fprintf(fp, "SENDBUG: %s\n", categories);
                    554:        fprintf(fp, "SENDBUG:\n");
                    555:        fprintf(fp, "SENDBUG:\n");
                    556:        fprintf(fp, "To: %s\n", "gnats@openbsd.org");
                    557:        fprintf(fp, "Subject: \n");
                    558:        fprintf(fp, "From: %s\n", pw->pw_name);
1.34      ray       559:        fprintf(fp, "Cc: %s\n", pw->pw_name);
1.1       ray       560:        fprintf(fp, "Reply-To: %s\n", pw->pw_name);
1.5       deraadt   561:        fprintf(fp, "X-sendbug-version: %s\n", version);
1.1       ray       562:        fprintf(fp, "\n");
                    563:        fprintf(fp, "\n");
                    564:        fprintf(fp, ">Submitter-Id:\tnet\n");
                    565:        fprintf(fp, ">Originator:\t%s\n", fullname);
                    566:        fprintf(fp, ">Organization:\n");
                    567:        fprintf(fp, "net\n");
                    568:        fprintf(fp, ">Synopsis:\t<synopsis of the problem (one line)>\n");
1.19      deraadt   569:        fprintf(fp, ">Severity:\t"
                    570:            "<[ non-critical | serious | critical ] (one line)>\n");
1.1       ray       571:        fprintf(fp, ">Priority:\t<[ low | medium | high ] (one line)>\n");
                    572:        fprintf(fp, ">Category:\t<PR category (one line)>\n");
1.19      deraadt   573:        fprintf(fp, ">Class:\t\t"
                    574:            "<[ sw-bug | doc-bug | change-request | support ] (one line)>\n");
1.1       ray       575:        fprintf(fp, ">Release:\t<release number or tag (one line)>\n");
                    576:        fprintf(fp, ">Environment:\n");
                    577:        fprintf(fp, "\t<machine, os, target, libraries (multiple lines)>\n");
                    578:        fprintf(fp, "\tSystem      : %s %s\n", os, rel);
1.14      deraadt   579:        fprintf(fp, "\tDetails     : %s\n", details);
1.1       ray       580:        fprintf(fp, "\tArchitecture: %s.%s\n", os, mach);
                    581:        fprintf(fp, "\tMachine     : %s\n", mach);
                    582:        fprintf(fp, ">Description:\n");
                    583:        fprintf(fp, "\t<precise description of the problem (multiple lines)>\n");
                    584:        fprintf(fp, ">How-To-Repeat:\n");
1.19      deraadt   585:        fprintf(fp, "\t<code/input/activities to reproduce the problem"
                    586:            " (multiple lines)>\n");
1.1       ray       587:        fprintf(fp, ">Fix:\n");
1.19      deraadt   588:        fprintf(fp, "\t<how to correct or work around the problem,"
                    589:            " if known (multiple lines)>\n");
1.1       ray       590: }