version 1.37, 2007/04/06 07:24:53 |
version 1.38, 2007/04/06 20:29:18 |
|
|
} |
} |
|
|
int |
int |
editit(char *tmpfile) |
editit(char *pathname) |
{ |
{ |
char *argp[] = {"sh", "-c", NULL, NULL}, *ed, *p; |
char *argp[] = {"sh", "-c", NULL, NULL}, *ed, *p; |
sig_t sighup, sigint, sigquit; |
sig_t sighup, sigint, sigquit; |
|
|
ed = getenv("EDITOR"); |
ed = getenv("EDITOR"); |
if (ed == NULL || ed[0] == '\0') |
if (ed == NULL || ed[0] == '\0') |
ed = _PATH_VI; |
ed = _PATH_VI; |
if (asprintf(&p, "%s %s", ed, tmpfile) == -1) |
if (asprintf(&p, "%s %s", ed, pathname) == -1) |
return (-1); |
return (-1); |
argp[2] = p; |
argp[2] = p; |
|
|
|
|
} |
} |
|
|
int |
int |
sendmail(const char *tmppath) |
sendmail(const char *pathname) |
{ |
{ |
int filedes[2]; |
int filedes[2]; |
|
|
if (pipe(filedes) == -1) { |
if (pipe(filedes) == -1) { |
warn("pipe: unsent report in %s", tmppath); |
warn("pipe: unsent report in %s", pathname); |
return (-1); |
return (-1); |
} |
} |
switch (fork()) { |
switch (fork()) { |
case -1: |
case -1: |
warn("fork error: unsent report in %s", |
warn("fork error: unsent report in %s", |
tmppath); |
pathname); |
return (-1); |
return (-1); |
case 0: |
case 0: |
close(filedes[1]); |
close(filedes[1]); |
if (dup2(filedes[0], STDIN_FILENO) == -1) { |
if (dup2(filedes[0], STDIN_FILENO) == -1) { |
warn("dup2 error: unsent report in %s", |
warn("dup2 error: unsent report in %s", |
tmppath); |
pathname); |
return (-1); |
return (-1); |
} |
} |
close(filedes[0]); |
close(filedes[0]); |
execl("/usr/sbin/sendmail", "sendmail", |
execl("/usr/sbin/sendmail", "sendmail", |
"-oi", "-t", (void *)NULL); |
"-oi", "-t", (void *)NULL); |
warn("sendmail error: unsent report in %s", |
warn("sendmail error: unsent report in %s", |
tmppath); |
pathname); |
return (-1); |
return (-1); |
default: |
default: |
close(filedes[0]); |
close(filedes[0]); |
/* Pipe into sendmail. */ |
/* Pipe into sendmail. */ |
if (send_file(tmppath, filedes[1]) == -1) { |
if (send_file(pathname, filedes[1]) == -1) { |
warn("send_file error: unsent report in %s", |
warn("send_file error: unsent report in %s", |
tmppath); |
pathname); |
return (-1); |
return (-1); |
} |
} |
close(filedes[1]); |
close(filedes[1]); |