version 1.18, 2007/03/25 23:23:29 |
version 1.19, 2007/03/25 23:27:38 |
|
|
int |
int |
main(int argc, char *argv[]) |
main(int argc, char *argv[]) |
{ |
{ |
const char *tmpdir; |
|
char *pr_form; |
|
int ch, c, fd, ret = 1; |
int ch, c, fd, ret = 1; |
|
const char *tmpdir; |
struct stat sb; |
struct stat sb; |
|
char *pr_form; |
time_t mtime; |
time_t mtime; |
FILE *fp; |
FILE *fp; |
|
|
|
|
if ((tmpdir = getenv("TMPDIR")) == NULL || tmpdir[0] == '\0') |
if ((tmpdir = getenv("TMPDIR")) == NULL || tmpdir[0] == '\0') |
tmpdir = _PATH_TMP; |
tmpdir = _PATH_TMP; |
if (asprintf(&tmppath, "%s%sp.XXXXXXXXXX", tmpdir, |
if (asprintf(&tmppath, "%s%sp.XXXXXXXXXX", tmpdir, |
tmpdir[strlen(tmpdir) - 1] == '/' ? "" : "/") == -1) { |
tmpdir[strlen(tmpdir) - 1] == '/' ? "" : "/") == -1) |
err(1, "asprintf"); |
err(1, "asprintf"); |
} |
|
if ((fd = mkstemp(tmppath)) == -1) |
if ((fd = mkstemp(tmppath)) == -1) |
err(1, "mkstemp"); |
err(1, "mkstemp"); |
wantcleanup = 1; |
wantcleanup = 1; |
atexit(cleanup); |
atexit(cleanup); |
if ((fp = fdopen(fd, "w+")) == NULL) { |
if ((fp = fdopen(fd, "w+")) == NULL) |
err(1, "fdopen"); |
err(1, "fdopen"); |
} |
|
|
|
init(); |
init(); |
|
|
|
|
} else |
} else |
template(fp); |
template(fp); |
|
|
if (fflush(fp) == EOF || fstat(fd, &sb) == -1 || fclose(fp) == EOF) { |
if (fflush(fp) == EOF || fstat(fd, &sb) == -1 || fclose(fp) == EOF) |
err(1, "error creating template"); |
err(1, "error creating template"); |
} |
|
mtime = sb.st_mtime; |
mtime = sb.st_mtime; |
|
|
edit: |
edit: |
editit(tmppath); |
editit(tmppath); |
|
|
if (stat(tmppath, &sb) == -1) { |
if (stat(tmppath, &sb) == -1) |
err(1, "stat"); |
err(1, "stat"); |
} |
if (mtime == sb.st_mtime) |
if (mtime == sb.st_mtime) { |
|
errx(1, "report unchanged, nothing sent"); |
errx(1, "report unchanged, nothing sent"); |
} |
|
|
|
prompt: |
prompt: |
c = prompt(); |
c = prompt(); |
|
|
int |
int |
editit(char *tmpfile) |
editit(char *tmpfile) |
{ |
{ |
|
char *argp[] = {"sh", "-c", NULL, NULL}, *ed, *p; |
pid_t pid, xpid; |
pid_t pid, xpid; |
char *argp[] = {"sh", "-c", NULL, NULL}; |
|
char *ed, *p; |
|
int stat; |
int stat; |
|
|
if ((ed = getenv("EDITOR")) == (char *)0) |
if ((ed = getenv("EDITOR")) == (char *)0) |
|
|
init(void) |
init(void) |
{ |
{ |
size_t len = 0, namelen; |
size_t len = 0, namelen; |
int sysname[2]; |
|
const char *src; |
const char *src; |
|
int sysname[2]; |
char *dst, *cp; |
char *dst, *cp; |
|
|
if ((pw = getpwuid(getuid())) == NULL) { |
if ((pw = getpwuid(getuid())) == NULL) |
err(1, "getpwuid"); |
err(1, "getpwuid"); |
} |
|
namelen = strlen(pw->pw_name); |
namelen = strlen(pw->pw_name); |
|
|
/* Add length of expanded '&', minus existing '&'. */ |
/* Add length of expanded '&', minus existing '&'. */ |
|
|
} |
} |
/* Add full name length, including all those '&' we skipped. */ |
/* Add full name length, including all those '&' we skipped. */ |
len += src - pw->pw_gecos; |
len += src - pw->pw_gecos; |
if ((fullname = malloc(len + 1)) == NULL) { |
if ((fullname = malloc(len + 1)) == NULL) |
err(1, "malloc"); |
err(1, "malloc"); |
} |
|
dst = fullname; |
dst = fullname; |
src = pw->pw_gecos; |
src = pw->pw_gecos; |
while (*src != ',' && *src != '\0') { |
while (*src != ',' && *src != '\0') { |
|
|
sysname[0] = CTL_KERN; |
sysname[0] = CTL_KERN; |
sysname[1] = KERN_OSTYPE; |
sysname[1] = KERN_OSTYPE; |
len = sizeof(os) - 1; |
len = sizeof(os) - 1; |
if (sysctl(sysname, 2, &os, &len, NULL, 0) == -1) { |
if (sysctl(sysname, 2, &os, &len, NULL, 0) == -1) |
err(1, "sysctl"); |
err(1, "sysctl"); |
} |
|
|
|
sysname[0] = CTL_KERN; |
sysname[0] = CTL_KERN; |
sysname[1] = KERN_OSRELEASE; |
sysname[1] = KERN_OSRELEASE; |
len = sizeof(rel) - 1; |
len = sizeof(rel) - 1; |
if (sysctl(sysname, 2, &rel, &len, NULL, 0) == -1) { |
if (sysctl(sysname, 2, &rel, &len, NULL, 0) == -1) |
err(1, "sysctl"); |
err(1, "sysctl"); |
} |
|
|
|
sysname[0] = CTL_KERN; |
sysname[0] = CTL_KERN; |
sysname[1] = KERN_VERSION; |
sysname[1] = KERN_VERSION; |
len = sizeof(details) - 1; |
len = sizeof(details) - 1; |
if (sysctl(sysname, 2, &details, &len, NULL, 0) == -1) { |
if (sysctl(sysname, 2, &details, &len, NULL, 0) == -1) |
err(1, "sysctl"); |
err(1, "sysctl"); |
} |
|
|
|
cp = strchr(details, '\n'); |
cp = strchr(details, '\n'); |
if (cp) { |
if (cp) { |
|
|
sysname[0] = CTL_HW; |
sysname[0] = CTL_HW; |
sysname[1] = HW_MACHINE; |
sysname[1] = HW_MACHINE; |
len = sizeof(mach) - 1; |
len = sizeof(mach) - 1; |
if (sysctl(sysname, 2, &mach, &len, NULL, 0) == -1) { |
if (sysctl(sysname, 2, &mach, &len, NULL, 0) == -1) |
err(1, "sysctl"); |
err(1, "sysctl"); |
} |
|
|
|
} |
} |
|
|
int |
int |
|
|
template(FILE *fp) |
template(FILE *fp) |
{ |
{ |
fprintf(fp, "SENDBUG: -*- sendbug -*-\n"); |
fprintf(fp, "SENDBUG: -*- sendbug -*-\n"); |
fprintf(fp, "SENDBUG: Lines starting with `SENDBUG' will be removed automatically, as\n"); |
fprintf(fp, "SENDBUG: Lines starting with `SENDBUG' will" |
fprintf(fp, "SENDBUG: will all comments (text enclosed in `<' and `>'). \n"); |
" be removed automatically, as\n"); |
|
fprintf(fp, "SENDBUG: will all comments (text enclosed in `<' and `>').\n"); |
fprintf(fp, "SENDBUG:\n"); |
fprintf(fp, "SENDBUG:\n"); |
fprintf(fp, "SENDBUG: Choose from the following categories:\n"); |
fprintf(fp, "SENDBUG: Choose from the following categories:\n"); |
fprintf(fp, "SENDBUG:\n"); |
fprintf(fp, "SENDBUG:\n"); |
|
|
fprintf(fp, ">Organization:\n"); |
fprintf(fp, ">Organization:\n"); |
fprintf(fp, "net\n"); |
fprintf(fp, "net\n"); |
fprintf(fp, ">Synopsis:\t<synopsis of the problem (one line)>\n"); |
fprintf(fp, ">Synopsis:\t<synopsis of the problem (one line)>\n"); |
fprintf(fp, ">Severity:\t<[ non-critical | serious | critical ] (one line)>\n"); |
fprintf(fp, ">Severity:\t" |
|
"<[ non-critical | serious | critical ] (one line)>\n"); |
fprintf(fp, ">Priority:\t<[ low | medium | high ] (one line)>\n"); |
fprintf(fp, ">Priority:\t<[ low | medium | high ] (one line)>\n"); |
fprintf(fp, ">Category:\t<PR category (one line)>\n"); |
fprintf(fp, ">Category:\t<PR category (one line)>\n"); |
fprintf(fp, ">Class:\t\t<[ sw-bug | doc-bug | change-request | support ] (one line)>\n"); |
fprintf(fp, ">Class:\t\t" |
|
"<[ sw-bug | doc-bug | change-request | support ] (one line)>\n"); |
fprintf(fp, ">Release:\t<release number or tag (one line)>\n"); |
fprintf(fp, ">Release:\t<release number or tag (one line)>\n"); |
fprintf(fp, ">Environment:\n"); |
fprintf(fp, ">Environment:\n"); |
fprintf(fp, "\t<machine, os, target, libraries (multiple lines)>\n"); |
fprintf(fp, "\t<machine, os, target, libraries (multiple lines)>\n"); |
|
|
fprintf(fp, ">Description:\n"); |
fprintf(fp, ">Description:\n"); |
fprintf(fp, "\t<precise description of the problem (multiple lines)>\n"); |
fprintf(fp, "\t<precise description of the problem (multiple lines)>\n"); |
fprintf(fp, ">How-To-Repeat:\n"); |
fprintf(fp, ">How-To-Repeat:\n"); |
fprintf(fp, "\t<code/input/activities to reproduce the problem (multiple lines)>\n"); |
fprintf(fp, "\t<code/input/activities to reproduce the problem" |
|
" (multiple lines)>\n"); |
fprintf(fp, ">Fix:\n"); |
fprintf(fp, ">Fix:\n"); |
fprintf(fp, "\t<how to correct or work around the problem, if known (multiple lines)>\n"); |
fprintf(fp, "\t<how to correct or work around the problem," |
|
" if known (multiple lines)>\n"); |
} |
} |