Merge various changes from OpenBSD and NetBSD.
o remove panic() in favor of err(3) and use err(3) functions consistently throughout o use stat(2)'s S_IS* macros rather than S_IF* o [r]index -> str[r]chr o convert some static buffers to dynamic ones o use real tempfiles rather than reopening the same templates o rename some functions that clash with libc o convert wait_status from union to int and use wait(2) status macros o fix multiple potential buffer overflows o fix a few comments o add $FreeBSD$ Reviewed by: nra, nectar (earlier version)
This commit is contained in:
parent
afd190c224
commit
e51e7e067d
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)aux.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "rcv.h"
|
||||
@ -80,38 +84,6 @@ save2str(str, old)
|
||||
return new;
|
||||
}
|
||||
|
||||
/*
|
||||
* Announce a fatal error and die.
|
||||
*/
|
||||
#if __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
void
|
||||
#if __STDC__
|
||||
panic(const char *fmt, ...)
|
||||
#else
|
||||
panic(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
(void)fprintf(stderr, "panic: ");
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
fflush(stderr);
|
||||
abort();
|
||||
}
|
||||
|
||||
/*
|
||||
* Touch the named message by setting its MTOUCH flag.
|
||||
* Touched messages have the effect of not being sent
|
||||
@ -139,7 +111,7 @@ isdir(name)
|
||||
|
||||
if (stat(name, &sbuf) < 0)
|
||||
return(0);
|
||||
return((sbuf.st_mode & S_IFMT) == S_IFDIR);
|
||||
return(S_ISDIR(sbuf.st_mode));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -269,19 +241,18 @@ ishfield(linebuf, colon, field)
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy a string, lowercasing it as we go.
|
||||
* Copy a string and lowercase the result.
|
||||
* dsize: space left in buffer (including space for NULL)
|
||||
*/
|
||||
void
|
||||
istrcpy(dest, src)
|
||||
istrncpy(dest, src, dsize)
|
||||
register char *dest, *src;
|
||||
size_t dsize;
|
||||
{
|
||||
|
||||
do {
|
||||
if (isupper(*src))
|
||||
*dest++ = tolower(*src);
|
||||
else
|
||||
*dest++ = *src;
|
||||
} while (*src++ != 0);
|
||||
strlcpy(dest, src, dsize);
|
||||
while (*dest)
|
||||
*dest++ = tolower(*dest);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -314,7 +285,7 @@ source(arglist)
|
||||
if ((cp = expand(*arglist)) == NOSTR)
|
||||
return(1);
|
||||
if ((fi = Fopen(cp, "r")) == NULL) {
|
||||
perror(cp);
|
||||
warn("%s", cp);
|
||||
return(1);
|
||||
}
|
||||
if (ssp >= SSTACK_SIZE - 1) {
|
||||
@ -377,22 +348,6 @@ alter(name)
|
||||
(void)utimes(name, tv);
|
||||
}
|
||||
|
||||
/*
|
||||
* Examine the passed line buffer and
|
||||
* return true if it is all blanks and tabs.
|
||||
*/
|
||||
int
|
||||
blankline(linebuf)
|
||||
char linebuf[];
|
||||
{
|
||||
register char *cp;
|
||||
|
||||
for (cp = linebuf; *cp; cp++)
|
||||
if (*cp != ' ' && *cp != '\t')
|
||||
return(0);
|
||||
return(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get sender's name from this message. If the message has
|
||||
* a bunch of arpanet stuff in it, we may have to skin the name
|
||||
@ -408,7 +363,7 @@ nameof(mp, reptype)
|
||||
cp = skin(name1(mp, reptype));
|
||||
if (reptype != 0 || charcount(cp, '!') < 2)
|
||||
return(cp);
|
||||
cp2 = rindex(cp, '!');
|
||||
cp2 = strrchr(cp, '!');
|
||||
cp2--;
|
||||
while (cp2 > cp && *cp2 != '!')
|
||||
cp2--;
|
||||
@ -454,15 +409,18 @@ skin(name)
|
||||
{
|
||||
register int c;
|
||||
register char *cp, *cp2;
|
||||
char *bufend;
|
||||
char *bufend, *nbuf;
|
||||
int gotlt, lastsp;
|
||||
char nbuf[BUFSIZ];
|
||||
|
||||
if (name == NOSTR)
|
||||
return(NOSTR);
|
||||
if (index(name, '(') == NOSTR && index(name, '<') == NOSTR
|
||||
&& index(name, ' ') == NOSTR)
|
||||
if (strchr(name, '(') == NOSTR && strchr(name, '<') == NOSTR
|
||||
&& strchr(name, ' ') == NOSTR)
|
||||
return(name);
|
||||
|
||||
/* We assume that length(input) <= length(output) */
|
||||
if ((nbuf = (char *)malloc(strlen(name) + 1)) == NULL)
|
||||
err(1, "Out of memory");
|
||||
gotlt = 0;
|
||||
lastsp = 0;
|
||||
bufend = nbuf;
|
||||
@ -546,7 +504,9 @@ skin(name)
|
||||
}
|
||||
*cp2 = 0;
|
||||
|
||||
return(savestr(nbuf));
|
||||
if ((nbuf = (char *)realloc(nbuf, strlen(nbuf) + 1)) == NULL)
|
||||
err(1, "Out of memory");
|
||||
return(nbuf);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -586,24 +546,25 @@ name1(mp, reptype)
|
||||
*cp2 = '\0';
|
||||
if (readline(ibuf, linebuf, LINESIZE) < 0)
|
||||
return(savestr(namebuf));
|
||||
if ((cp = index(linebuf, 'F')) == NULL)
|
||||
if ((cp = strchr(linebuf, 'F')) == NULL)
|
||||
return(savestr(namebuf));
|
||||
if (strncmp(cp, "From", 4) != 0)
|
||||
return(savestr(namebuf));
|
||||
while ((cp = index(cp, 'r')) != NULL) {
|
||||
while ((cp = strchr(cp, 'r')) != NULL) {
|
||||
if (strncmp(cp, "remote", 6) == 0) {
|
||||
if ((cp = index(cp, 'f')) == NULL)
|
||||
if ((cp = strchr(cp, 'f')) == NULL)
|
||||
break;
|
||||
if (strncmp(cp, "from", 4) != 0)
|
||||
break;
|
||||
if ((cp = index(cp, ' ')) == NULL)
|
||||
if ((cp = strchr(cp, ' ')) == NULL)
|
||||
break;
|
||||
cp++;
|
||||
if (first) {
|
||||
strcpy(namebuf, cp);
|
||||
cp2 = namebuf;
|
||||
first = 0;
|
||||
} else
|
||||
strcpy(rindex(namebuf, '!')+1, cp);
|
||||
cp2 = strrchr(namebuf, '!') + 1;
|
||||
strlcpy(cp2, cp, sizeof(namebuf) - (cp2 - namebuf) - 1);
|
||||
strcat(namebuf, "!");
|
||||
goto newname;
|
||||
}
|
||||
@ -629,46 +590,6 @@ charcount(str, c)
|
||||
return(i);
|
||||
}
|
||||
|
||||
/*
|
||||
* Are any of the characters in the two strings the same?
|
||||
*/
|
||||
int
|
||||
anyof(s1, s2)
|
||||
register char *s1, *s2;
|
||||
{
|
||||
|
||||
while (*s1)
|
||||
if (index(s2, *s1++))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert c to upper case
|
||||
*/
|
||||
int
|
||||
raise(c)
|
||||
register int c;
|
||||
{
|
||||
|
||||
if (islower(c))
|
||||
return toupper(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy s1 to s2, return pointer to null in s2.
|
||||
*/
|
||||
char *
|
||||
copy(s1, s2)
|
||||
register char *s1, *s2;
|
||||
{
|
||||
|
||||
while (*s2++ = *s1++)
|
||||
;
|
||||
return s2 - 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* See if the given header field is supposed to be ignored.
|
||||
*/
|
||||
@ -677,7 +598,7 @@ isign(field, ignore)
|
||||
char *field;
|
||||
struct ignoretab ignore[2];
|
||||
{
|
||||
char realfld[BUFSIZ];
|
||||
char realfld[LINESIZE];
|
||||
|
||||
if (ignore == ignoreall)
|
||||
return 1;
|
||||
@ -685,7 +606,7 @@ isign(field, ignore)
|
||||
* Lower-case the string, so that "Status" and "status"
|
||||
* will hash to the same place.
|
||||
*/
|
||||
istrcpy(realfld, field);
|
||||
istrncpy(realfld, field, sizeof(realfld));
|
||||
if (ignore[1].i_count > 0)
|
||||
return (!member(realfld, ignore + 1));
|
||||
else
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cmd1.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "rcv.h"
|
||||
@ -316,7 +320,7 @@ type1(msgvec, doign, page)
|
||||
cp = _PATH_MORE;
|
||||
obuf = Popen(cp, "w");
|
||||
if (obuf == NULL) {
|
||||
perror(cp);
|
||||
warnx("%s", cp);
|
||||
obuf = stdout;
|
||||
} else
|
||||
signal(SIGPIPE, brokpipe);
|
||||
@ -328,7 +332,7 @@ type1(msgvec, doign, page)
|
||||
dot = mp;
|
||||
if (value("quiet") == NOSTR)
|
||||
fprintf(obuf, "Message %d:\n", *ip);
|
||||
(void) send(mp, obuf, doign ? ignore : 0, NOSTR);
|
||||
(void) sendmessage(mp, obuf, doign ? ignore : 0, NOSTR);
|
||||
}
|
||||
close_pipe:
|
||||
if (obuf != stdout) {
|
||||
@ -387,10 +391,10 @@ top(msgvec)
|
||||
if (!lineb)
|
||||
printf("\n");
|
||||
for (lines = 0; lines < c && lines <= topl; lines++) {
|
||||
if (readline(ibuf, linebuf, LINESIZE) < 0)
|
||||
if (readline(ibuf, linebuf, sizeof(linebuf)) < 0)
|
||||
break;
|
||||
puts(linebuf);
|
||||
lineb = blankline(linebuf);
|
||||
lineb = strspn(linebuf, " \t") == strlen(linebuf);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
@ -437,10 +441,10 @@ mboxit(msgvec)
|
||||
int
|
||||
folders()
|
||||
{
|
||||
char dirname[BUFSIZ];
|
||||
char dirname[PATHSIZE];
|
||||
char *cmd;
|
||||
|
||||
if (getfold(dirname) < 0) {
|
||||
if (getfold(dirname, sizeof(dirname)) < 0) {
|
||||
printf("No value set for \"folder\"\n");
|
||||
return 1;
|
||||
}
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cmd2.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "rcv.h"
|
||||
@ -187,14 +191,14 @@ save1(str, mark, cmd, ignore)
|
||||
else
|
||||
disp = "[New file]";
|
||||
if ((obuf = Fopen(file, "a")) == NULL) {
|
||||
perror(NOSTR);
|
||||
warn(NOSTR);
|
||||
return(1);
|
||||
}
|
||||
for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) {
|
||||
mp = &message[*ip - 1];
|
||||
touch(mp);
|
||||
if (send(mp, obuf, ignore, NOSTR) < 0) {
|
||||
perror(file);
|
||||
if (sendmessage(mp, obuf, ignore, NOSTR) < 0) {
|
||||
warnx("%s", file);
|
||||
Fclose(obuf);
|
||||
return(1);
|
||||
}
|
||||
@ -203,7 +207,7 @@ save1(str, mark, cmd, ignore)
|
||||
}
|
||||
fflush(obuf);
|
||||
if (ferror(obuf))
|
||||
perror(file);
|
||||
warn("%s", file);
|
||||
Fclose(obuf);
|
||||
printf("%s\n", disp);
|
||||
return(0);
|
||||
@ -367,11 +371,11 @@ int
|
||||
core()
|
||||
{
|
||||
int pid;
|
||||
extern union wait wait_status;
|
||||
extern int wait_status;
|
||||
|
||||
switch (pid = fork()) {
|
||||
case -1:
|
||||
perror("fork");
|
||||
warn("fork");
|
||||
return(1);
|
||||
case 0:
|
||||
abort();
|
||||
@ -380,7 +384,7 @@ core()
|
||||
printf("Okie dokie");
|
||||
fflush(stdout);
|
||||
wait_child(pid);
|
||||
if (wait_status.w_coredump)
|
||||
if (WIFSIGNALED(wait_status) && WCOREDUMP(wait_status))
|
||||
printf(" -- Core dumped.\n");
|
||||
else
|
||||
printf(" -- Can't dump core.\n");
|
||||
@ -467,7 +471,7 @@ ignore1(list, tab, which)
|
||||
struct ignoretab *tab;
|
||||
char *which;
|
||||
{
|
||||
char field[BUFSIZ];
|
||||
char field[LINESIZE];
|
||||
register int h;
|
||||
register struct ignore *igp;
|
||||
char **ap;
|
||||
@ -475,7 +479,7 @@ ignore1(list, tab, which)
|
||||
if (*list == NOSTR)
|
||||
return igshow(tab, which);
|
||||
for (ap = list; *ap != 0; ap++) {
|
||||
istrcpy(field, *ap);
|
||||
istrncpy(field, *ap, sizeof(field));
|
||||
if (member(field, tab))
|
||||
continue;
|
||||
h = hash(field);
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cmd3.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "rcv.h"
|
||||
@ -56,8 +60,9 @@ shell(str)
|
||||
char *shell;
|
||||
char cmd[BUFSIZ];
|
||||
|
||||
(void) strcpy(cmd, str);
|
||||
if (bangexp(cmd) < 0)
|
||||
if (strlcpy(cmd, str, sizeof(cmd)) >= sizeof(cmd))
|
||||
return 1;
|
||||
if (bangexp(cmd, sizeof(cmd)) < 0)
|
||||
return 1;
|
||||
if ((shell = value("SHELL")) == NOSTR)
|
||||
shell = _PATH_CSHELL;
|
||||
@ -90,21 +95,20 @@ dosh(str)
|
||||
* Expand the shell escape by expanding unescaped !'s into the
|
||||
* last issued command where possible.
|
||||
*/
|
||||
|
||||
char lastbang[128];
|
||||
|
||||
int
|
||||
bangexp(str)
|
||||
bangexp(str, strsize)
|
||||
char *str;
|
||||
size_t strsize;
|
||||
{
|
||||
char bangbuf[BUFSIZ];
|
||||
static char lastbang[BUFSIZ];
|
||||
register char *cp, *cp2;
|
||||
register int n;
|
||||
int changed = 0;
|
||||
|
||||
cp = str;
|
||||
cp2 = bangbuf;
|
||||
n = BUFSIZ;
|
||||
n = sizeof(bangbuf);
|
||||
while (*cp) {
|
||||
if (*cp == '!') {
|
||||
if (n < strlen(lastbang)) {
|
||||
@ -113,7 +117,9 @@ bangexp(str)
|
||||
return(-1);
|
||||
}
|
||||
changed++;
|
||||
strcpy(cp2, lastbang);
|
||||
if (strlcpy(cp2, lastbang, sizeof(bangbuf) - (cp2 - bangbuf))
|
||||
>= sizeof(bangbuf) - (cp2 - bangbuf))
|
||||
goto overf;
|
||||
cp2 += strlen(lastbang);
|
||||
n -= strlen(lastbang);
|
||||
cp++;
|
||||
@ -135,9 +141,10 @@ bangexp(str)
|
||||
printf("!%s\n", bangbuf);
|
||||
fflush(stdout);
|
||||
}
|
||||
strcpy(str, bangbuf);
|
||||
strncpy(lastbang, bangbuf, 128);
|
||||
lastbang[127] = 0;
|
||||
if (strlcpy(str, bangbuf, strsize) >= strsize)
|
||||
goto overf;
|
||||
if (strlcpy(lastbang, bangbuf, sizeof(lastbang)) >= sizeof(lastbang))
|
||||
goto overf;
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -152,7 +159,7 @@ help()
|
||||
register FILE *f;
|
||||
|
||||
if ((f = Fopen(_PATH_HELP, "r")) == NULL) {
|
||||
perror(_PATH_HELP);
|
||||
warn("%s", _PATH_HELP);
|
||||
return(1);
|
||||
}
|
||||
while ((c = getc(f)) != EOF)
|
||||
@ -170,13 +177,15 @@ schdir(arglist)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
if (*arglist == NOSTR)
|
||||
if (*arglist == NOSTR) {
|
||||
if (homedir == NOSTR)
|
||||
return(1);
|
||||
cp = homedir;
|
||||
else
|
||||
} else
|
||||
if ((cp = expand(*arglist)) == NOSTR)
|
||||
return(1);
|
||||
if (chdir(cp) < 0) {
|
||||
perror(cp);
|
||||
warn("%s", cp);
|
||||
return(1);
|
||||
}
|
||||
return 0;
|
||||
@ -276,8 +285,7 @@ reedit(subj)
|
||||
subj[2] == ':')
|
||||
return subj;
|
||||
newsubj = salloc(strlen(subj) + 5);
|
||||
strcpy(newsubj, "Re: ");
|
||||
strcpy(newsubj + 4, subj);
|
||||
sprintf(newsubj, "Re: %s", subj);
|
||||
return newsubj;
|
||||
}
|
||||
|
||||
@ -386,7 +394,7 @@ set(arglist)
|
||||
for (ap = arglist; *ap != NOSTR; ap++) {
|
||||
cp = *ap;
|
||||
cp2 = varbuf;
|
||||
while (*cp != '=' && *cp != '\0')
|
||||
while (cp2 < varbuf + sizeof(varbuf) - 1 && *cp != '=' && *cp != '\0')
|
||||
*cp2++ = *cp++;
|
||||
*cp2 = '\0';
|
||||
if (*cp == '\0')
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "def.h"
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)collect.c 8.2 (Berkeley) 4/19/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -74,10 +78,9 @@ collect(hp, printheaders)
|
||||
int printheaders;
|
||||
{
|
||||
FILE *fbuf;
|
||||
int lc, cc, escape, eofcount;
|
||||
int lc, cc, escape, eofcount, fd;
|
||||
register int c, t;
|
||||
char linebuf[LINESIZE], *cp;
|
||||
extern char *tempMail;
|
||||
char linebuf[LINESIZE], tempname[PATHSIZE], *cp;
|
||||
char getsub;
|
||||
int omask;
|
||||
void collint(), collhup(), collstop();
|
||||
@ -96,17 +99,19 @@ collect(hp, printheaders)
|
||||
savettou = signal(SIGTTOU, collstop);
|
||||
savettin = signal(SIGTTIN, collstop);
|
||||
if (setjmp(collabort) || setjmp(colljmp)) {
|
||||
rm(tempMail);
|
||||
rm(tempname);
|
||||
goto err;
|
||||
}
|
||||
sigsetmask(omask & ~(sigmask(SIGINT) | sigmask(SIGHUP)));
|
||||
|
||||
noreset++;
|
||||
if ((collf = Fopen(tempMail, "w+")) == NULL) {
|
||||
perror(tempMail);
|
||||
snprintf(tempname, sizeof(tempname), "%s/mail.RsXXXXXXXXXX", tmpdir);
|
||||
if ((fd = mkstemp(tempname)) == -1 ||
|
||||
(collf = Fdopen(fd, "w+")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
goto err;
|
||||
}
|
||||
unlink(tempMail);
|
||||
rm(tempname);
|
||||
|
||||
/*
|
||||
* If we are going to prompt for a subject,
|
||||
@ -261,7 +266,11 @@ collect(hp, printheaders)
|
||||
hp->h_bcc = cat(hp->h_bcc, extract(&linebuf[2], GBCC));
|
||||
break;
|
||||
case 'd':
|
||||
strcpy(linebuf + 2, getdeadletter());
|
||||
if (strlcpy(linebuf + 2, getdeadletter(), sizeof(linebuf) - 2)
|
||||
>= sizeof(linebuf) - 2) {
|
||||
printf("Line buffer overflow\n");
|
||||
break;
|
||||
}
|
||||
/* fall into . . . */
|
||||
case 'r':
|
||||
/*
|
||||
@ -284,7 +293,7 @@ collect(hp, printheaders)
|
||||
break;
|
||||
}
|
||||
if ((fbuf = Fopen(cp, "r")) == NULL) {
|
||||
perror(cp);
|
||||
warn("%s", cp);
|
||||
break;
|
||||
}
|
||||
printf("\"%s\" ", cp);
|
||||
@ -328,12 +337,12 @@ collect(hp, printheaders)
|
||||
* standard list processing garbage.
|
||||
* If ~f is given, we don't shift over.
|
||||
*/
|
||||
if (forward(linebuf + 2, collf, c) < 0)
|
||||
if (forward(linebuf + 2, collf, tempname, c) < 0)
|
||||
goto err;
|
||||
goto cont;
|
||||
case '?':
|
||||
if ((fbuf = Fopen(_PATH_TILDE, "r")) == NULL) {
|
||||
perror(_PATH_TILDE);
|
||||
warn("%s", _PATH_TILDE);
|
||||
break;
|
||||
}
|
||||
while ((t = getc(fbuf)) != EOF)
|
||||
@ -410,14 +419,14 @@ exwrite(name, fp, f)
|
||||
printf("\"%s\" ", name);
|
||||
fflush(stdout);
|
||||
}
|
||||
if (stat(name, &junk) >= 0 && (junk.st_mode & S_IFMT) == S_IFREG) {
|
||||
if (stat(name, &junk) >= 0 && S_ISREG(junk.st_mode)) {
|
||||
if (!f)
|
||||
fprintf(stderr, "%s: ", name);
|
||||
fprintf(stderr, "File exists\n");
|
||||
return(-1);
|
||||
}
|
||||
if ((of = Fopen(name, "w")) == NULL) {
|
||||
perror(NOSTR);
|
||||
warn(NOSTR);
|
||||
return(-1);
|
||||
}
|
||||
lc = 0;
|
||||
@ -428,7 +437,7 @@ exwrite(name, fp, f)
|
||||
lc++;
|
||||
(void) putc(c, of);
|
||||
if (ferror(of)) {
|
||||
perror(name);
|
||||
warnx("%s", name);
|
||||
Fclose(of);
|
||||
return(-1);
|
||||
}
|
||||
@ -471,15 +480,17 @@ mespipe(fp, cmd)
|
||||
char cmd[];
|
||||
{
|
||||
FILE *nf;
|
||||
int fd;
|
||||
sig_t sigint = signal(SIGINT, SIG_IGN);
|
||||
extern char *tempEdit;
|
||||
char *shell;
|
||||
char *shell, tempname[PATHSIZE];
|
||||
|
||||
if ((nf = Fopen(tempEdit, "w+")) == NULL) {
|
||||
perror(tempEdit);
|
||||
snprintf(tempname, sizeof(tempname), "%s/mail.ReXXXXXXXXXX", tmpdir);
|
||||
if ((fd = mkstemp(tempname)) == -1 ||
|
||||
(nf = Fdopen(fd, "w+")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
goto out;
|
||||
}
|
||||
(void) unlink(tempEdit);
|
||||
(void) rm(tempname);
|
||||
/*
|
||||
* stdin = current message.
|
||||
* stdout = new message.
|
||||
@ -515,13 +526,13 @@ mespipe(fp, cmd)
|
||||
* should shift over and 'f' if not.
|
||||
*/
|
||||
int
|
||||
forward(ms, fp, f)
|
||||
forward(ms, fp, fn, f)
|
||||
char ms[];
|
||||
FILE *fp;
|
||||
char *fn;
|
||||
int f;
|
||||
{
|
||||
register int *msgvec;
|
||||
extern char *tempMail;
|
||||
struct ignoretab *ig;
|
||||
char *tabst;
|
||||
|
||||
@ -549,8 +560,8 @@ forward(ms, fp, f)
|
||||
|
||||
touch(mp);
|
||||
printf(" %d", *msgvec);
|
||||
if (send(mp, fp, ig, tabst) < 0) {
|
||||
perror(tempMail);
|
||||
if (sendmessage(mp, fp, ig, tabst) < 0) {
|
||||
warnx("%s", fn);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <string.h>
|
||||
#include "pathnames.h"
|
||||
|
||||
|
@ -34,7 +34,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)edit.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "rcv.h"
|
||||
@ -125,7 +129,7 @@ edit1(msgvec, type)
|
||||
break;
|
||||
}
|
||||
if (ferror(otf))
|
||||
perror("/tmp");
|
||||
warnx("/tmp");
|
||||
(void) Fclose(fp);
|
||||
}
|
||||
(void) signal(SIGINT, sigint);
|
||||
@ -148,17 +152,18 @@ run_editor(fp, size, type, readonly)
|
||||
register FILE *nf = NULL;
|
||||
register int t;
|
||||
time_t modtime;
|
||||
char *edit;
|
||||
char *edit, tempname[PATHSIZE];
|
||||
struct stat statb;
|
||||
extern char *tempEdit;
|
||||
|
||||
if ((t = creat(tempEdit, readonly ? 0400 : 0600)) < 0) {
|
||||
perror(tempEdit);
|
||||
snprintf(tempname, sizeof(tempname), "%s/mail.ReXXXXXXXXXX", tmpdir);
|
||||
if ((t = mkstemp(tempname)) == -1 ||
|
||||
(nf = Fdopen(t, "w")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
goto out;
|
||||
}
|
||||
if ((nf = Fdopen(t, "w")) == NULL) {
|
||||
perror(tempEdit);
|
||||
(void) unlink(tempEdit);
|
||||
if (readonly && fchmod(t, 0400) == -1) {
|
||||
warn("%s", tempname);
|
||||
(void) rm(tempname);
|
||||
goto out;
|
||||
}
|
||||
if (size >= 0)
|
||||
@ -174,22 +179,22 @@ run_editor(fp, size, type, readonly)
|
||||
modtime = statb.st_mtime;
|
||||
if (ferror(nf)) {
|
||||
(void) Fclose(nf);
|
||||
perror(tempEdit);
|
||||
(void) unlink(tempEdit);
|
||||
warnx("%s", tempname);
|
||||
(void) rm(tempname);
|
||||
nf = NULL;
|
||||
goto out;
|
||||
}
|
||||
if (Fclose(nf) < 0) {
|
||||
perror(tempEdit);
|
||||
(void) unlink(tempEdit);
|
||||
warn("%s", tempname);
|
||||
(void) rm(tempname);
|
||||
nf = NULL;
|
||||
goto out;
|
||||
}
|
||||
nf = NULL;
|
||||
if ((edit = value(type == 'e' ? "EDITOR" : "VISUAL")) == NOSTR)
|
||||
edit = type == 'e' ? _PATH_EX : _PATH_VI;
|
||||
if (run_command(edit, 0, -1, -1, tempEdit, NOSTR, NOSTR) < 0) {
|
||||
(void) unlink(tempEdit);
|
||||
if (run_command(edit, 0, -1, -1, tempname, NOSTR, NOSTR) < 0) {
|
||||
(void) rm(tempname);
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
@ -197,26 +202,26 @@ run_editor(fp, size, type, readonly)
|
||||
* temporary and return.
|
||||
*/
|
||||
if (readonly) {
|
||||
(void) unlink(tempEdit);
|
||||
(void) rm(tempname);
|
||||
goto out;
|
||||
}
|
||||
if (stat(tempEdit, &statb) < 0) {
|
||||
perror(tempEdit);
|
||||
if (stat(tempname, &statb) < 0) {
|
||||
warn("%s", tempname);
|
||||
goto out;
|
||||
}
|
||||
if (modtime == statb.st_mtime) {
|
||||
(void) unlink(tempEdit);
|
||||
(void) rm(tempname);
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
* Now switch to new file.
|
||||
*/
|
||||
if ((nf = Fopen(tempEdit, "a+")) == NULL) {
|
||||
perror(tempEdit);
|
||||
(void) unlink(tempEdit);
|
||||
if ((nf = Fopen(tempname, "a+")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
(void) rm(tempname);
|
||||
goto out;
|
||||
}
|
||||
(void) unlink(tempEdit);
|
||||
(void) rm(tempname);
|
||||
out:
|
||||
return nf;
|
||||
}
|
||||
|
@ -31,6 +31,8 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)extern.h 8.1 (Berkeley) 6/6/93
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
struct name *cat __P((struct name *, struct name *));
|
||||
@ -47,7 +49,6 @@ FILE *Fdopen __P((int, char *));
|
||||
FILE *Fopen __P((char *, char *));
|
||||
FILE *Popen __P((char *, char *));
|
||||
FILE *collect __P((struct header *, int));
|
||||
char *copy __P((char *, char *));
|
||||
char *copyin __P((char *, char **));
|
||||
char *detract __P((struct name *, int));
|
||||
char *expand __P((char *));
|
||||
@ -82,12 +83,10 @@ int dorespond __P((int *));
|
||||
void alter __P((char *));
|
||||
int alternates __P((char **));
|
||||
void announce __P((void));
|
||||
int anyof __P((char *, char *));
|
||||
int append __P((struct message *, FILE *));
|
||||
int argcount __P((char **));
|
||||
void assign __P((char [], char []));
|
||||
int bangexp __P((char *));
|
||||
int blankline __P((char []));
|
||||
int bangexp __P((char *, size_t));
|
||||
void brokpipe __P((int));
|
||||
int charcount __P((char *, int));
|
||||
int check __P((int, int));
|
||||
@ -121,16 +120,16 @@ void fail __P((char [], char []));
|
||||
int file __P((char **));
|
||||
struct grouphead *
|
||||
findgroup __P((char []));
|
||||
void findmail __P((char *, char *));
|
||||
void findmail __P((char *, char *, int));
|
||||
int first __P((int, int));
|
||||
void fixhead __P((struct header *, struct name *));
|
||||
void fmt __P((char *, struct name *, FILE *, int));
|
||||
int folders __P((void));
|
||||
int forward __P((char [], FILE *, int));
|
||||
int forward __P((char [], FILE *, char *, int));
|
||||
void free_child __P((int));
|
||||
int from __P((int *));
|
||||
off_t fsize __P((FILE *));
|
||||
int getfold __P((char *));
|
||||
int getfold __P((char *, int));
|
||||
int gethfield __P((FILE *, char [], int, char **));
|
||||
int getmsglist __P((char *, int *, int));
|
||||
int getrawlist __P((char [], char **, int));
|
||||
@ -155,7 +154,7 @@ int isfileaddr __P((char *));
|
||||
int ishead __P((char []));
|
||||
int isign __P((char *, struct ignoretab []));
|
||||
int isprefix __P((char *, char *));
|
||||
void istrcpy __P((char *, char *));
|
||||
void istrncpy __P((char *, char *, size_t));
|
||||
struct cmd *
|
||||
lex __P((char []));
|
||||
void load __P((char *));
|
||||
@ -179,7 +178,6 @@ int more __P((int *));
|
||||
int newfileinfo __P((void));
|
||||
int next __P((int *));
|
||||
int null __P((int));
|
||||
void panic __P((const char *, ...));
|
||||
void parse __P((char [], struct headline *, char []));
|
||||
int pcmdlist __P((void));
|
||||
int pdot __P((void));
|
||||
@ -193,7 +191,6 @@ int putline __P((FILE *, char *));
|
||||
int pversion __P((int));
|
||||
void quit __P((void));
|
||||
int quitcmd __P((void));
|
||||
int raise __P((int));
|
||||
int readline __P((FILE *, char *, int));
|
||||
void register_file __P((FILE *, int, int));
|
||||
void regret __P((int));
|
||||
@ -214,7 +211,7 @@ void scaninit __P((void));
|
||||
int schdir __P((char **));
|
||||
int screensize __P((void));
|
||||
int scroll __P((char []));
|
||||
int send __P((struct message *, FILE *, struct ignoretab *, char *));
|
||||
int sendmessage __P((struct message *, FILE *, struct ignoretab *, char *));
|
||||
int sendmail __P((char *));
|
||||
int set __P((char **));
|
||||
int setfile __P((char *));
|
||||
@ -251,3 +248,6 @@ int visual __P((int *));
|
||||
int wait_child __P((int));
|
||||
int wait_command __P((int));
|
||||
int writeback __P((FILE *));
|
||||
|
||||
extern char *__progname;
|
||||
extern char *tmpdir;
|
||||
|
@ -34,7 +34,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)fio.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "rcv.h"
|
||||
@ -59,22 +63,19 @@ void
|
||||
setptr(ibuf)
|
||||
register FILE *ibuf;
|
||||
{
|
||||
extern char *tmpdir;
|
||||
register int c, count;
|
||||
register char *cp, *cp2;
|
||||
struct message this;
|
||||
FILE *mestmp;
|
||||
off_t offset;
|
||||
int maybe, inhead;
|
||||
char linebuf[LINESIZE];
|
||||
char linebuf[LINESIZE], pathbuf[PATHSIZE];
|
||||
|
||||
/* Get temporary file. */
|
||||
(void)sprintf(linebuf, "%s/mail.XXXXXX", tmpdir);
|
||||
if ((c = mkstemp(linebuf)) == -1 ||
|
||||
(mestmp = Fdopen(c, "r+")) == NULL) {
|
||||
errx(1, "can't open %s", linebuf);
|
||||
}
|
||||
(void)unlink(linebuf);
|
||||
(void)snprintf(pathbuf, sizeof(pathbuf), "%s/mail.XXXXXXXXXX", tmpdir);
|
||||
if ((c = mkstemp(pathbuf)) == -1 || (mestmp = Fdopen(c, "r+")) == NULL)
|
||||
err(1, "can't open %s", pathbuf);
|
||||
(void) rm(pathbuf);
|
||||
|
||||
msgCount = 0;
|
||||
maybe = 1;
|
||||
@ -86,27 +87,22 @@ setptr(ibuf)
|
||||
this.m_block = 0;
|
||||
this.m_offset = 0;
|
||||
for (;;) {
|
||||
if (fgets(linebuf, LINESIZE, ibuf) == NULL) {
|
||||
if (append(&this, mestmp)) {
|
||||
perror("temporary file");
|
||||
exit(1);
|
||||
}
|
||||
if (fgets(linebuf, sizeof(linebuf), ibuf) == NULL) {
|
||||
if (append(&this, mestmp))
|
||||
errx(1, "temporary file");
|
||||
makemessage(mestmp);
|
||||
return;
|
||||
}
|
||||
count = strlen(linebuf);
|
||||
(void) fwrite(linebuf, sizeof *linebuf, count, otf);
|
||||
if (ferror(otf)) {
|
||||
perror("/tmp");
|
||||
exit(1);
|
||||
}
|
||||
linebuf[count - 1] = 0;
|
||||
if (ferror(otf))
|
||||
errx(1, "/tmp");
|
||||
if (count)
|
||||
linebuf[count - 1] = '\0';
|
||||
if (maybe && linebuf[0] == 'F' && ishead(linebuf)) {
|
||||
msgCount++;
|
||||
if (append(&this, mestmp)) {
|
||||
perror("temporary file");
|
||||
exit(1);
|
||||
}
|
||||
if (append(&this, mestmp))
|
||||
errx(1, "temporary file");
|
||||
this.m_flag = MUSED|MNEW;
|
||||
this.m_size = 0;
|
||||
this.m_lines = 0;
|
||||
@ -193,10 +189,8 @@ setinput(mp)
|
||||
{
|
||||
|
||||
fflush(otf);
|
||||
if (fseek(itf, (long)positionof(mp->m_block, mp->m_offset), 0) < 0) {
|
||||
perror("fseek");
|
||||
panic("Temporary file seek");
|
||||
}
|
||||
if (fseek(itf, (long)positionof(mp->m_block, mp->m_offset), 0) < 0)
|
||||
err(1, "fseek");
|
||||
return (itf);
|
||||
}
|
||||
|
||||
@ -213,13 +207,13 @@ makemessage(f)
|
||||
if (message != 0)
|
||||
free((char *) message);
|
||||
if ((message = (struct message *) malloc((unsigned) size)) == 0)
|
||||
panic("Insufficient memory for %d messages", msgCount);
|
||||
err(1, "Out of memory");
|
||||
dot = message;
|
||||
size -= sizeof (struct message);
|
||||
fflush(f);
|
||||
(void) lseek(fileno(f), (off_t)sizeof *message, 0);
|
||||
if (read(fileno(f), (char *) message, size) != size)
|
||||
panic("Message temporary file corrupted");
|
||||
errx(1, "Message temporary file corrupted");
|
||||
message[msgCount].m_size = 0;
|
||||
message[msgCount].m_lines = 0;
|
||||
Fclose(f);
|
||||
@ -315,7 +309,7 @@ expand(name)
|
||||
register char *cp, *shell;
|
||||
int pivec[2];
|
||||
struct stat sbuf;
|
||||
extern union wait wait_status;
|
||||
extern int wait_status;
|
||||
|
||||
/*
|
||||
* The order of evaluation is "%" and "#" expand into constants.
|
||||
@ -325,7 +319,7 @@ expand(name)
|
||||
*/
|
||||
switch (*name) {
|
||||
case '%':
|
||||
findmail(name[1] ? name + 1 : myname, xname);
|
||||
findmail(name[1] ? name + 1 : myname, xname, sizeof(xname));
|
||||
return savestr(xname);
|
||||
case '#':
|
||||
if (name[1] != 0)
|
||||
@ -340,22 +334,23 @@ expand(name)
|
||||
name = "~/mbox";
|
||||
/* fall through */
|
||||
}
|
||||
if (name[0] == '+' && getfold(cmdbuf) >= 0) {
|
||||
sprintf(xname, "%s/%s", cmdbuf, name + 1);
|
||||
if (name[0] == '+' && getfold(cmdbuf, sizeof(cmdbuf)) >= 0) {
|
||||
snprintf(xname, sizeof(xname), "%s/%s", cmdbuf, name + 1);
|
||||
name = savestr(xname);
|
||||
}
|
||||
/* catch the most common shell meta character */
|
||||
if (name[0] == '~' && (name[1] == '/' || name[1] == '\0')) {
|
||||
sprintf(xname, "%s%s", homedir, name + 1);
|
||||
if (name[0] == '~' && homedir != NULL &&
|
||||
(name[1] == '/' || name[1] == '\0')) {
|
||||
snprintf(xname, sizeof(xname), "%s%s", homedir, name + 1);
|
||||
name = savestr(xname);
|
||||
}
|
||||
if (!anyof(name, "~{[*?$`'\"\\"))
|
||||
if (!strpbrk(name, "~{[*?$`'\"\\"))
|
||||
return name;
|
||||
if (pipe(pivec) < 0) {
|
||||
perror("pipe");
|
||||
warn("pipe");
|
||||
return name;
|
||||
}
|
||||
sprintf(cmdbuf, "echo %s", name);
|
||||
snprintf(cmdbuf, sizeof(cmdbuf), "echo %s", name);
|
||||
if ((shell = value("SHELL")) == NOSTR)
|
||||
shell = _PATH_CSHELL;
|
||||
pid = start_command(shell, 0, -1, pivec[1], "-c", cmdbuf, NOSTR);
|
||||
@ -367,12 +362,12 @@ expand(name)
|
||||
close(pivec[1]);
|
||||
l = read(pivec[0], xname, BUFSIZ);
|
||||
close(pivec[0]);
|
||||
if (wait_child(pid) < 0 && wait_status.w_termsig != SIGPIPE) {
|
||||
if (wait_child(pid) < 0 && WIFSIGNALED(wait_status) && WTERMSIG(wait_status) != SIGPIPE) {
|
||||
fprintf(stderr, "\"%s\": Expansion failed.\n", name);
|
||||
return NOSTR;
|
||||
}
|
||||
if (l < 0) {
|
||||
perror("read");
|
||||
warn("read");
|
||||
return NOSTR;
|
||||
}
|
||||
if (l == 0) {
|
||||
@ -383,11 +378,11 @@ expand(name)
|
||||
fprintf(stderr, "\"%s\": Expansion buffer overflow.\n", name);
|
||||
return NOSTR;
|
||||
}
|
||||
xname[l] = 0;
|
||||
xname[l] = '\0';
|
||||
for (cp = &xname[l-1]; *cp == '\n' && cp > xname; cp--)
|
||||
;
|
||||
cp[1] = '\0';
|
||||
if (index(xname, ' ') && stat(xname, &sbuf) < 0) {
|
||||
if (strchr(xname, ' ') && stat(xname, &sbuf) < 0) {
|
||||
fprintf(stderr, "\"%s\": Ambiguous.\n", name);
|
||||
return NOSTR;
|
||||
}
|
||||
@ -398,18 +393,20 @@ expand(name)
|
||||
* Determine the current folder directory name.
|
||||
*/
|
||||
int
|
||||
getfold(name)
|
||||
getfold(name, namelen)
|
||||
char *name;
|
||||
int namelen;
|
||||
{
|
||||
char *folder;
|
||||
int copylen;
|
||||
|
||||
if ((folder = value("folder")) == NOSTR)
|
||||
return (-1);
|
||||
if (*folder == '/')
|
||||
strcpy(name, folder);
|
||||
copylen = strlcpy(name, folder, namelen);
|
||||
else
|
||||
sprintf(name, "%s/%s", homedir, folder);
|
||||
return (0);
|
||||
copylen = snprintf(name, namelen, "%s/%s", homedir ? homedir : ".", folder);
|
||||
return copylen >= namelen ? (-1) : (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -425,7 +422,7 @@ getdeadletter()
|
||||
else if (*cp != '/') {
|
||||
char buf[PATHSIZE];
|
||||
|
||||
(void) sprintf(buf, "~/%s", cp);
|
||||
(void) snprintf(buf, sizeof(buf), "~/%s", cp);
|
||||
cp = expand(buf);
|
||||
}
|
||||
return cp;
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)getname.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "rcv.h"
|
||||
@ -42,8 +46,8 @@ static char sccsid[] = "@(#)getname.c 8.1 (Berkeley) 6/6/93";
|
||||
/* Getname / getuserid for those with hashed passwd data base). */
|
||||
|
||||
/*
|
||||
* Search the passwd file for a uid. Return name through ref parameter
|
||||
* if found, indicating success with 0 return. Return -1 on error.
|
||||
* Search the passwd file for a uid. Return name on success,
|
||||
* NOSTR on failure
|
||||
*/
|
||||
char *
|
||||
getname(uid)
|
||||
|
@ -31,6 +31,8 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)glob.h 8.1 (Berkeley) 6/6/93
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)head.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "rcv.h"
|
||||
@ -53,13 +57,10 @@ int
|
||||
ishead(linebuf)
|
||||
char linebuf[];
|
||||
{
|
||||
register char *cp;
|
||||
struct headline hl;
|
||||
char parbuf[BUFSIZ];
|
||||
|
||||
cp = linebuf;
|
||||
if (*cp++ != 'F' || *cp++ != 'r' || *cp++ != 'o' || *cp++ != 'm' ||
|
||||
*cp++ != ' ')
|
||||
if (strncmp(linebuf, "From ", 5))
|
||||
return (0);
|
||||
parse(linebuf, &hl, parbuf);
|
||||
if (hl.l_from == NOSTR || hl.l_date == NOSTR) {
|
||||
|
@ -34,7 +34,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lex.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "rcv.h"
|
||||
@ -61,12 +65,12 @@ setfile(name)
|
||||
char *name;
|
||||
{
|
||||
FILE *ibuf;
|
||||
int i;
|
||||
int i, fd;
|
||||
struct stat stb;
|
||||
char isedit = *name != '%';
|
||||
char *who = name[1] ? name + 1 : myname;
|
||||
char tempname[PATHSIZE];
|
||||
static int shudclob;
|
||||
extern char *tempMesg;
|
||||
|
||||
if ((name = expand(name)) == NOSTR)
|
||||
return -1;
|
||||
@ -74,30 +78,20 @@ setfile(name)
|
||||
if ((ibuf = Fopen(name, "r")) == NULL) {
|
||||
if (!isedit && errno == ENOENT)
|
||||
goto nomail;
|
||||
perror(name);
|
||||
warn("%s", name);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (fstat(fileno(ibuf), &stb) < 0) {
|
||||
perror("fstat");
|
||||
warn("fstat");
|
||||
Fclose(ibuf);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
switch (stb.st_mode & S_IFMT) {
|
||||
case S_IFDIR:
|
||||
if (S_ISDIR(stb.st_mode) || !S_ISREG(stb.st_mode)) {
|
||||
Fclose(ibuf);
|
||||
errno = EISDIR;
|
||||
perror(name);
|
||||
return (-1);
|
||||
|
||||
case S_IFREG:
|
||||
break;
|
||||
|
||||
default:
|
||||
Fclose(ibuf);
|
||||
errno = EINVAL;
|
||||
perror(name);
|
||||
errno = S_ISDIR(stb.st_mode) ? EISDIR : EINVAL;
|
||||
warn("%s", name);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@ -128,21 +122,18 @@ setfile(name)
|
||||
}
|
||||
shudclob = 1;
|
||||
edit = isedit;
|
||||
strcpy(prevfile, mailname);
|
||||
strlcpy(prevfile, mailname, sizeof(prevfile));
|
||||
if (name != mailname)
|
||||
strcpy(mailname, name);
|
||||
strlcpy(mailname, name, sizeof(mailname));
|
||||
mailsize = fsize(ibuf);
|
||||
if ((otf = fopen(tempMesg, "w")) == NULL) {
|
||||
perror(tempMesg);
|
||||
exit(1);
|
||||
}
|
||||
snprintf(tempname, sizeof(tempname), "%s/mail.RxXXXXXXXXXX", tmpdir);
|
||||
if ((fd = mkstemp(tempname)) == -1 || (otf = fdopen(fd, "w")) == NULL)
|
||||
err(1, "%s", tempname);
|
||||
(void) fcntl(fileno(otf), F_SETFD, 1);
|
||||
if ((itf = fopen(tempMesg, "r")) == NULL) {
|
||||
perror(tempMesg);
|
||||
exit(1);
|
||||
}
|
||||
if ((itf = fopen(tempname, "r")) == NULL)
|
||||
err(1, "%s", tempname);
|
||||
(void) fcntl(fileno(itf), F_SETFD, 1);
|
||||
rm(tempMesg);
|
||||
rm(tempname);
|
||||
setptr(ibuf);
|
||||
setmsize(msgCount);
|
||||
Fclose(ibuf);
|
||||
@ -273,7 +264,7 @@ execute(linebuf, contxt)
|
||||
return(0);
|
||||
}
|
||||
cp2 = word;
|
||||
while (*cp && index(" \t0123456789$^.:/-+*'\"", *cp) == NOSTR)
|
||||
while (*cp && strchr(" \t0123456789$^.:/-+*'\"", *cp) == NOSTR)
|
||||
*cp2++ = *cp++;
|
||||
*cp2 = '\0';
|
||||
|
||||
@ -405,7 +396,7 @@ execute(linebuf, contxt)
|
||||
break;
|
||||
|
||||
default:
|
||||
panic("Unknown argtype");
|
||||
errx(1, "Unknown argtype");
|
||||
}
|
||||
|
||||
out:
|
||||
@ -463,7 +454,7 @@ lex(word)
|
||||
* ignore trailing chars after `#'
|
||||
*
|
||||
* lines with beginning `#' are comments
|
||||
* spaces befor `#' are ignored in execute()
|
||||
* spaces before `#' are ignored in execute()
|
||||
*/
|
||||
|
||||
if (*word == '#')
|
||||
@ -588,7 +579,7 @@ newfileinfo()
|
||||
{
|
||||
register struct message *mp;
|
||||
register int u, n, mdot, d, s;
|
||||
char fname[BUFSIZ], zname[BUFSIZ], *ename;
|
||||
char fname[PATHSIZE+1], zname[PATHSIZE+1], *ename;
|
||||
|
||||
for (mp = &message[0]; mp < &message[msgCount]; mp++)
|
||||
if (mp->m_flag & MNEW)
|
||||
@ -613,10 +604,10 @@ newfileinfo()
|
||||
s++;
|
||||
}
|
||||
ename = mailname;
|
||||
if (getfold(fname) >= 0) {
|
||||
if (getfold(fname, sizeof(fname) - 1) >= 0) {
|
||||
strcat(fname, "/");
|
||||
if (strncmp(fname, mailname, strlen(fname)) == 0) {
|
||||
sprintf(zname, "+%s", mailname + strlen(fname));
|
||||
snprintf(zname, sizeof(zname), "+%s", mailname + strlen(fname));
|
||||
ename = zname;
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)list.c 8.2 (Berkeley) 4/19/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "rcv.h"
|
||||
@ -391,7 +395,11 @@ getrawlist(line, argv, argc)
|
||||
{
|
||||
register char c, *cp, *cp2, quotec;
|
||||
int argn;
|
||||
char linebuf[BUFSIZ];
|
||||
char *linebuf;
|
||||
size_t linebufsize = BUFSIZ;
|
||||
|
||||
if ((linebuf = (char *)malloc(linebufsize)) == NULL)
|
||||
err(1, "Out of memory");
|
||||
|
||||
argn = 0;
|
||||
cp = line;
|
||||
@ -408,6 +416,13 @@ getrawlist(line, argv, argc)
|
||||
cp2 = linebuf;
|
||||
quotec = '\0';
|
||||
while ((c = *cp) != '\0') {
|
||||
/* Allocate more space if necessary */
|
||||
if (cp2 - linebuf == linebufsize - 1) {
|
||||
linebufsize += BUFSIZ;
|
||||
if ((linebuf = realloc(linebuf, linebufsize)) == NULL)
|
||||
err(1, "Out of memory");
|
||||
cp2 = linebuf + linebufsize - BUFSIZ - 1;
|
||||
}
|
||||
cp++;
|
||||
if (quotec != '\0') {
|
||||
if (c == quotec)
|
||||
@ -473,6 +488,7 @@ getrawlist(line, argv, argc)
|
||||
argv[argn++] = savestr(linebuf);
|
||||
}
|
||||
argv[argn] = NOSTR;
|
||||
free(linebuf);
|
||||
return argn;
|
||||
}
|
||||
|
||||
@ -605,7 +621,7 @@ regret(token)
|
||||
int token;
|
||||
{
|
||||
if (++regretp >= REGDEP)
|
||||
panic("Too many regrets");
|
||||
errx(1, "Too many regrets");
|
||||
regretstack[regretp] = token;
|
||||
lexstring[STRINGLEN-1] = '\0';
|
||||
string_stack[regretp] = savestr(lexstring);
|
||||
@ -662,7 +678,7 @@ matchsender(str, mesg)
|
||||
while (*cp2) {
|
||||
if (*cp == 0)
|
||||
return(1);
|
||||
if (raise(*cp++) != raise(*cp2++)) {
|
||||
if (toupper(*cp++) != toupper(*cp2++)) {
|
||||
cp2 = ++backup;
|
||||
cp = str;
|
||||
}
|
||||
@ -678,7 +694,7 @@ matchsender(str, mesg)
|
||||
* previous search string.
|
||||
*/
|
||||
|
||||
char lastscan[128];
|
||||
char lastscan[STRINGLEN];
|
||||
int
|
||||
matchsubj(str, mesg)
|
||||
char *str;
|
||||
@ -688,17 +704,17 @@ matchsubj(str, mesg)
|
||||
register char *cp, *cp2, *backup;
|
||||
|
||||
str++;
|
||||
if (strlen(str) == 0)
|
||||
if (*str == '\0')
|
||||
str = lastscan;
|
||||
else
|
||||
strcpy(lastscan, str);
|
||||
strlcpy(lastscan, str, sizeof(lastscan));
|
||||
mp = &message[mesg-1];
|
||||
|
||||
/*
|
||||
* Now look, ignoring case, for the word in the string.
|
||||
*/
|
||||
|
||||
if (value("searchheaders") && (cp = index(str, ':'))) {
|
||||
if (value("searchheaders") && (cp = strchr(str, ':'))) {
|
||||
*cp++ = '\0';
|
||||
cp2 = hfield(str, mp);
|
||||
cp[-1] = ':';
|
||||
@ -713,7 +729,7 @@ matchsubj(str, mesg)
|
||||
while (*cp2) {
|
||||
if (*cp == 0)
|
||||
return(1);
|
||||
if (raise(*cp++) != raise(*cp2++)) {
|
||||
if (toupper(*cp++) != toupper(*cp2++)) {
|
||||
cp2 = ++backup;
|
||||
cp = str;
|
||||
}
|
||||
@ -732,7 +748,7 @@ mark(mesg)
|
||||
|
||||
i = mesg;
|
||||
if (i < 1 || i > msgCount)
|
||||
panic("Bad message number to mark");
|
||||
errx(1, "Bad message number to mark");
|
||||
message[i-1].m_flag |= MMARK;
|
||||
}
|
||||
|
||||
@ -747,7 +763,7 @@ unmark(mesg)
|
||||
|
||||
i = mesg;
|
||||
if (i < 1 || i > msgCount)
|
||||
panic("Bad message number to unmark");
|
||||
errx(1, "Bad message number to unmark");
|
||||
message[i-1].m_flag &= ~MMARK;
|
||||
}
|
||||
|
||||
|
@ -38,11 +38,14 @@ static char copyright[] =
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "rcv.h"
|
||||
#include <err.h>
|
||||
#include <fcntl.h>
|
||||
#include "extern.h"
|
||||
|
||||
@ -99,10 +102,9 @@ main(argc, argv)
|
||||
* articles have been read/deleted for netnews.
|
||||
*/
|
||||
Tflag = optarg;
|
||||
if ((i = creat(Tflag, 0600)) < 0) {
|
||||
perror(Tflag);
|
||||
exit(1);
|
||||
}
|
||||
if ((i = open(Tflag, O_CREAT | O_TRUNC | O_WRONLY,
|
||||
0600)) < 0)
|
||||
err(1, "%s", Tflag);
|
||||
close(i);
|
||||
break;
|
||||
case 'u':
|
||||
@ -181,12 +183,12 @@ main(argc, argv)
|
||||
bcc = cat(bcc, nalloc(optarg, GBCC));
|
||||
break;
|
||||
case '?':
|
||||
fputs("\
|
||||
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...\n\
|
||||
[- sendmail-options ...]\n\
|
||||
mail [-iInNv] -f [name]\n\
|
||||
mail [-iInNv] [-u user]\n",
|
||||
stderr);
|
||||
fprintf(stderr, "\
|
||||
Usage: %s [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...\n\
|
||||
%*s [- sendmail-options ...]\n\
|
||||
%s [-iInNv] -f [name]\n\
|
||||
%s [-iInNv] [-u user]\n",__progname, strlen(__progname), "", __progname,
|
||||
__progname);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -197,14 +199,10 @@ Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...\n\
|
||||
/*
|
||||
* Check for inconsistent arguments.
|
||||
*/
|
||||
if (to == NIL && (subject != NOSTR || cc != NIL || bcc != NIL)) {
|
||||
fputs("You must specify direct recipients with -s, -c, or -b.\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
if (ef != NOSTR && to != NIL) {
|
||||
fprintf(stderr, "Cannot give -f and people to send to.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (to == NIL && (subject != NOSTR || cc != NIL || bcc != NIL))
|
||||
errx(1, "You must specify direct recipients with -s, -c, or -b.");
|
||||
if (ef != NOSTR && to != NIL)
|
||||
errx(1, "Cannot give -f and people to send to.");
|
||||
tinit();
|
||||
setscreensize();
|
||||
input = stdin;
|
||||
@ -213,9 +211,8 @@ Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...\n\
|
||||
if (!nosrc) {
|
||||
char *s, *path_rc;
|
||||
|
||||
path_rc = malloc(sizeof(_PATH_MASTER_RC));
|
||||
if (path_rc == NULL)
|
||||
errx(1, "malloc(path_rc) failed");
|
||||
if ((path_rc = malloc(sizeof(_PATH_MASTER_RC))) == NULL)
|
||||
err(1, "malloc(path_rc) failed");
|
||||
|
||||
strcpy(path_rc, _PATH_MASTER_RC);
|
||||
while ((s = strsep(&path_rc, ":")) != NULL)
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)names.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -94,10 +98,12 @@ extract(line, ntype)
|
||||
{
|
||||
register char *cp;
|
||||
register struct name *top, *np, *t;
|
||||
char nbuf[BUFSIZ];
|
||||
char *nbuf;
|
||||
|
||||
if (line == NOSTR || *line == '\0')
|
||||
return NIL;
|
||||
if ((nbuf = (char *)malloc(strlen(line) + 1)) == NULL)
|
||||
err(1, "Out of memory");
|
||||
top = NIL;
|
||||
np = NIL;
|
||||
cp = line;
|
||||
@ -110,6 +116,7 @@ extract(line, ntype)
|
||||
t->n_blink = np;
|
||||
np = t;
|
||||
}
|
||||
free(nbuf);
|
||||
return top;
|
||||
}
|
||||
|
||||
@ -148,14 +155,14 @@ detract(np, ntype)
|
||||
for (p = np; p != NIL; p = p->n_flink) {
|
||||
if (ntype && (p->n_type & GMASK) != ntype)
|
||||
continue;
|
||||
cp = copy(p->n_name, cp);
|
||||
cp += strlcpy(cp, p->n_name, strlen(p->n_name) + 1);
|
||||
if (comma && p->n_flink != NIL)
|
||||
*cp++ = ',';
|
||||
*cp++ = ' ';
|
||||
}
|
||||
*--cp = 0;
|
||||
*--cp = '\0';
|
||||
if (comma && *--cp == ',')
|
||||
*cp = 0;
|
||||
*cp = '\0';
|
||||
return(top);
|
||||
}
|
||||
|
||||
@ -197,7 +204,7 @@ yankword(ap, wbuf)
|
||||
for (cp2 = wbuf; *cp && (*cp2++ = *cp++) != '>';)
|
||||
;
|
||||
else
|
||||
for (cp2 = wbuf; *cp && !index(" \t,(", *cp); *cp2++ = *cp++)
|
||||
for (cp2 = wbuf; *cp && !strchr(" \t,(", *cp); *cp2++ = *cp++)
|
||||
;
|
||||
*cp2 = '\0';
|
||||
return cp;
|
||||
@ -223,7 +230,6 @@ outof(names, fo, hp)
|
||||
char *date, *fname, *ctime();
|
||||
FILE *fout, *fin;
|
||||
int ispipe;
|
||||
extern char *tempEdit;
|
||||
|
||||
top = names;
|
||||
np = names;
|
||||
@ -246,15 +252,21 @@ outof(names, fo, hp)
|
||||
*/
|
||||
|
||||
if (image < 0) {
|
||||
if ((fout = Fopen(tempEdit, "a")) == NULL) {
|
||||
perror(tempEdit);
|
||||
int fd;
|
||||
char tempname[PATHSIZE];
|
||||
|
||||
snprintf(tempname, sizeof(tempname),
|
||||
"%s/mail.ReXXXXXXXXXX", tmpdir);
|
||||
if ((fd = mkstemp(tempname)) == -1 ||
|
||||
(fout = Fdopen(fd, "a")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
senderr++;
|
||||
goto cant;
|
||||
}
|
||||
image = open(tempEdit, 2);
|
||||
(void) unlink(tempEdit);
|
||||
image = open(tempname, O_RDWR);
|
||||
(void) rm(tempname);
|
||||
if (image < 0) {
|
||||
perror(tempEdit);
|
||||
warn("%s", tempname);
|
||||
senderr++;
|
||||
(void) Fclose(fout);
|
||||
goto cant;
|
||||
@ -268,8 +280,12 @@ outof(names, fo, hp)
|
||||
rewind(fo);
|
||||
(void) putc('\n', fout);
|
||||
(void) fflush(fout);
|
||||
if (ferror(fout))
|
||||
perror(tempEdit);
|
||||
if (ferror(fout)) {
|
||||
warn("%s", tempname);
|
||||
senderr++;
|
||||
Fclose(fout);
|
||||
goto cant;
|
||||
}
|
||||
(void) Fclose(fout);
|
||||
}
|
||||
|
||||
@ -303,12 +319,12 @@ outof(names, fo, hp)
|
||||
} else {
|
||||
int f;
|
||||
if ((fout = Fopen(fname, "a")) == NULL) {
|
||||
perror(fname);
|
||||
warn("%s", fname);
|
||||
senderr++;
|
||||
goto cant;
|
||||
}
|
||||
if ((f = dup(image)) < 0) {
|
||||
perror("dup");
|
||||
warn("dup");
|
||||
fin = NULL;
|
||||
} else
|
||||
fin = Fdopen(f, "r");
|
||||
@ -321,8 +337,13 @@ outof(names, fo, hp)
|
||||
rewind(fin);
|
||||
while ((c = getc(fin)) != EOF)
|
||||
(void) putc(c, fout);
|
||||
if (ferror(fout))
|
||||
senderr++, perror(fname);
|
||||
if (ferror(fout)) {
|
||||
warnx("%s", fname);
|
||||
senderr++;
|
||||
Fclose(fout);
|
||||
Fclose(fin);
|
||||
goto cant;
|
||||
}
|
||||
(void) Fclose(fout);
|
||||
(void) Fclose(fin);
|
||||
}
|
||||
@ -483,7 +504,7 @@ unpack(np)
|
||||
|
||||
n = np;
|
||||
if ((t = count(n)) == 0)
|
||||
panic("No names to unpack");
|
||||
errx(1, "No names to unpack");
|
||||
/*
|
||||
* Compute the number of extra arguments we will need.
|
||||
* We need at least two extra -- one for "mail" and one for
|
||||
|
@ -31,6 +31,8 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)pathnames.h 8.1 (Berkeley) 6/6/93
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <paths.h>
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)popen.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "rcv.h"
|
||||
@ -55,12 +59,13 @@ struct child {
|
||||
int pid;
|
||||
char done;
|
||||
char free;
|
||||
union wait status;
|
||||
int status;
|
||||
struct child *link;
|
||||
};
|
||||
static struct child *child;
|
||||
static struct child *findchild __P((int));
|
||||
static void delchild __P((struct child *));
|
||||
static int file_pid __P((FILE *));
|
||||
|
||||
FILE *
|
||||
Fopen(file, mode)
|
||||
@ -166,7 +171,7 @@ register_file(fp, pipe, pid)
|
||||
struct fp *fpp;
|
||||
|
||||
if ((fpp = (struct fp *) malloc(sizeof *fpp)) == NULL)
|
||||
panic("Out of memory");
|
||||
err(1, "Out of memory");
|
||||
fpp->fp = fp;
|
||||
fpp->pipe = pipe;
|
||||
fpp->pid = pid;
|
||||
@ -186,9 +191,11 @@ unregister_file(fp)
|
||||
free((char *) p);
|
||||
return;
|
||||
}
|
||||
panic("Invalid file pointer");
|
||||
errx(1, "Invalid file pointer");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
int
|
||||
file_pid(fp)
|
||||
FILE *fp;
|
||||
{
|
||||
@ -197,7 +204,7 @@ file_pid(fp)
|
||||
for (p = fp_head; p; p = p->link)
|
||||
if (p->fp == fp)
|
||||
return (p->pid);
|
||||
panic("Invalid file pointer");
|
||||
errx(1, "Invalid file pointer");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
@ -232,7 +239,7 @@ start_command(cmd, mask, infd, outfd, a0, a1, a2)
|
||||
int pid;
|
||||
|
||||
if ((pid = fork()) < 0) {
|
||||
perror("fork");
|
||||
warn("fork");
|
||||
return -1;
|
||||
}
|
||||
if (pid == 0) {
|
||||
@ -245,7 +252,7 @@ start_command(cmd, mask, infd, outfd, a0, a1, a2)
|
||||
argv[i] = NOSTR;
|
||||
prepare_child(mask, infd, outfd);
|
||||
execvp(argv[0], argv);
|
||||
perror(argv[0]);
|
||||
warn("%s", argv[0]);
|
||||
_exit(1);
|
||||
}
|
||||
return pid;
|
||||
@ -296,6 +303,8 @@ findchild(pid)
|
||||
;
|
||||
if (*cpp == NULL) {
|
||||
*cpp = (struct child *) malloc(sizeof (struct child));
|
||||
if (*cpp == NULL)
|
||||
err(1, "Out of memory");
|
||||
(*cpp)->pid = pid;
|
||||
(*cpp)->done = (*cpp)->free = 0;
|
||||
(*cpp)->link = NULL;
|
||||
@ -320,11 +329,10 @@ sigchild(signo)
|
||||
int signo;
|
||||
{
|
||||
int pid;
|
||||
union wait status;
|
||||
int status;
|
||||
register struct child *cp;
|
||||
|
||||
while ((pid =
|
||||
wait3((int *)&status, WNOHANG, (struct rusage *)0)) > 0) {
|
||||
while ((pid = waitpid((pid_t)-1, &status, WNOHANG)) > 0) {
|
||||
cp = findchild(pid);
|
||||
if (cp->free)
|
||||
delchild(cp);
|
||||
@ -335,7 +343,7 @@ sigchild(signo)
|
||||
}
|
||||
}
|
||||
|
||||
union wait wait_status;
|
||||
int wait_status;
|
||||
|
||||
/*
|
||||
* Wait for a specific child to die.
|
||||
@ -352,7 +360,7 @@ wait_child(pid)
|
||||
wait_status = cp->status;
|
||||
delchild(cp);
|
||||
sigsetmask(mask);
|
||||
return wait_status.w_status ? -1 : 0;
|
||||
return((WIFEXITED(wait_status) && WEXITSTATUS(wait_status)) ? -1 : 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)quit.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "rcv.h"
|
||||
@ -72,9 +76,9 @@ quit()
|
||||
FILE *ibuf, *obuf, *fbuf, *rbuf, *readstat, *abuf;
|
||||
register struct message *mp;
|
||||
register int c;
|
||||
extern char *tempQuit, *tempResid;
|
||||
int fd;
|
||||
struct stat minfo;
|
||||
char *mbox;
|
||||
char *mbox, tempname[PATHSIZE];
|
||||
|
||||
/*
|
||||
* If we are read only, we can't do anything,
|
||||
@ -108,8 +112,9 @@ quit()
|
||||
rbuf = NULL;
|
||||
if (fstat(fileno(fbuf), &minfo) >= 0 && minfo.st_size > mailsize) {
|
||||
printf("New mail has arrived.\n");
|
||||
rbuf = Fopen(tempResid, "w");
|
||||
if (rbuf == NULL || fbuf == NULL)
|
||||
snprintf(tempname, sizeof(tempname), "%s/mail.RqXXXXXXXXXX", tmpdir);
|
||||
if ((fd = mkstemp(tempname)) == -1 ||
|
||||
(rbuf = Fdopen(fd, "w")) == NULL)
|
||||
goto newmail;
|
||||
#ifdef APPEND
|
||||
fseek(fbuf, (long)mailsize, 0);
|
||||
@ -125,9 +130,9 @@ quit()
|
||||
}
|
||||
#endif
|
||||
Fclose(rbuf);
|
||||
if ((rbuf = Fopen(tempResid, "r")) == NULL)
|
||||
if ((rbuf = Fopen(tempname, "r")) == NULL)
|
||||
goto newmail;
|
||||
rm(tempResid);
|
||||
rm(tempname);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -198,35 +203,37 @@ quit()
|
||||
mbox = expand("&");
|
||||
mcount = c;
|
||||
if (value("append") == NOSTR) {
|
||||
if ((obuf = Fopen(tempQuit, "w")) == NULL) {
|
||||
perror(tempQuit);
|
||||
snprintf(tempname, sizeof(tempname), "%s/mail.RmXXXXXXXXXX", tmpdir);
|
||||
if ((fd = mkstemp(tempname)) == -1 ||
|
||||
(obuf = Fdopen(fd, "w")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
Fclose(fbuf);
|
||||
return;
|
||||
}
|
||||
if ((ibuf = Fopen(tempQuit, "r")) == NULL) {
|
||||
perror(tempQuit);
|
||||
rm(tempQuit);
|
||||
if ((ibuf = Fopen(tempname, "r")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
rm(tempname);
|
||||
Fclose(obuf);
|
||||
Fclose(fbuf);
|
||||
return;
|
||||
}
|
||||
rm(tempQuit);
|
||||
rm(tempname);
|
||||
if ((abuf = Fopen(mbox, "r")) != NULL) {
|
||||
while ((c = getc(abuf)) != EOF)
|
||||
(void) putc(c, obuf);
|
||||
Fclose(abuf);
|
||||
}
|
||||
if (ferror(obuf)) {
|
||||
perror(tempQuit);
|
||||
warnx("%s", tempname);
|
||||
Fclose(ibuf);
|
||||
Fclose(obuf);
|
||||
Fclose(fbuf);
|
||||
return;
|
||||
}
|
||||
Fclose(obuf);
|
||||
close(creat(mbox, 0600));
|
||||
close(open(mbox, O_CREAT | O_TRUNC | O_WRONLY, 0600));
|
||||
if ((obuf = Fopen(mbox, "r+")) == NULL) {
|
||||
perror(mbox);
|
||||
warn("%s", mbox);
|
||||
Fclose(ibuf);
|
||||
Fclose(fbuf);
|
||||
return;
|
||||
@ -234,7 +241,7 @@ quit()
|
||||
}
|
||||
if (value("append") != NOSTR) {
|
||||
if ((obuf = Fopen(mbox, "a")) == NULL) {
|
||||
perror(mbox);
|
||||
warn("%s", mbox);
|
||||
Fclose(fbuf);
|
||||
return;
|
||||
}
|
||||
@ -242,8 +249,8 @@ quit()
|
||||
}
|
||||
for (mp = &message[0]; mp < &message[msgCount]; mp++)
|
||||
if (mp->m_flag & MBOX)
|
||||
if (send(mp, obuf, saveignore, NOSTR) < 0) {
|
||||
perror(mbox);
|
||||
if (sendmessage(mp, obuf, saveignore, NOSTR) < 0) {
|
||||
warnx("%s", mbox);
|
||||
Fclose(ibuf);
|
||||
Fclose(obuf);
|
||||
Fclose(fbuf);
|
||||
@ -270,7 +277,7 @@ quit()
|
||||
}
|
||||
trunc(obuf);
|
||||
if (ferror(obuf)) {
|
||||
perror(mbox);
|
||||
warn("%s", mbox);
|
||||
Fclose(obuf);
|
||||
Fclose(fbuf);
|
||||
return;
|
||||
@ -337,7 +344,7 @@ writeback(res)
|
||||
|
||||
p = 0;
|
||||
if ((obuf = Fopen(mailname, "r+")) == NULL) {
|
||||
perror(mailname);
|
||||
warn("%s", mailname);
|
||||
return(-1);
|
||||
}
|
||||
#ifndef APPEND
|
||||
@ -348,8 +355,8 @@ writeback(res)
|
||||
for (mp = &message[0]; mp < &message[msgCount]; mp++)
|
||||
if ((mp->m_flag&MPRESERVE)||(mp->m_flag&MTOUCH)==0) {
|
||||
p++;
|
||||
if (send(mp, obuf, (struct ignoretab *)0, NOSTR) < 0) {
|
||||
perror(mailname);
|
||||
if (sendmessage(mp, obuf, (struct ignoretab *)0, NOSTR) < 0) {
|
||||
warnx("%s", mailname);
|
||||
Fclose(obuf);
|
||||
return(-1);
|
||||
}
|
||||
@ -362,7 +369,7 @@ writeback(res)
|
||||
fflush(obuf);
|
||||
trunc(obuf);
|
||||
if (ferror(obuf)) {
|
||||
perror(mailname);
|
||||
warn("%s", mailname);
|
||||
Fclose(obuf);
|
||||
return(-1);
|
||||
}
|
||||
@ -384,13 +391,11 @@ writeback(res)
|
||||
void
|
||||
edstop()
|
||||
{
|
||||
extern char *tmpdir;
|
||||
register int gotcha, c;
|
||||
register struct message *mp;
|
||||
FILE *obuf, *ibuf, *readstat;
|
||||
struct stat statb;
|
||||
char tempname[30];
|
||||
char *mktemp();
|
||||
char tempname[PATHSIZE];
|
||||
|
||||
if (readonly)
|
||||
return;
|
||||
@ -419,16 +424,16 @@ edstop()
|
||||
goto done;
|
||||
ibuf = NULL;
|
||||
if (stat(mailname, &statb) >= 0 && statb.st_size > mailsize) {
|
||||
strcpy(tempname, tmpdir);
|
||||
strcat(tempname, "mboxXXXXXX");
|
||||
mktemp(tempname);
|
||||
if ((obuf = Fopen(tempname, "w")) == NULL) {
|
||||
perror(tempname);
|
||||
int fd;
|
||||
|
||||
snprintf(tempname, sizeof(tempname), "%s/mbox.XXXXXXXXXX", tmpdir);
|
||||
if ((fd = mkstemp(tempname)) == -1 || (obuf = Fdopen(fd, "w")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
relsesigs();
|
||||
reset(0);
|
||||
}
|
||||
if ((ibuf = Fopen(mailname, "r")) == NULL) {
|
||||
perror(mailname);
|
||||
warn("%s", mailname);
|
||||
Fclose(obuf);
|
||||
rm(tempname);
|
||||
relsesigs();
|
||||
@ -440,7 +445,7 @@ edstop()
|
||||
Fclose(ibuf);
|
||||
Fclose(obuf);
|
||||
if ((ibuf = Fopen(tempname, "r")) == NULL) {
|
||||
perror(tempname);
|
||||
warn("%s", tempname);
|
||||
rm(tempname);
|
||||
relsesigs();
|
||||
reset(0);
|
||||
@ -450,7 +455,7 @@ edstop()
|
||||
printf("\"%s\" ", mailname);
|
||||
fflush(stdout);
|
||||
if ((obuf = Fopen(mailname, "r+")) == NULL) {
|
||||
perror(mailname);
|
||||
warn("%s", mailname);
|
||||
relsesigs();
|
||||
reset(0);
|
||||
}
|
||||
@ -460,8 +465,8 @@ edstop()
|
||||
if ((mp->m_flag & MDELETED) != 0)
|
||||
continue;
|
||||
c++;
|
||||
if (send(mp, obuf, (struct ignoretab *) NULL, NOSTR) < 0) {
|
||||
perror(mailname);
|
||||
if (sendmessage(mp, obuf, (struct ignoretab *) NULL, NOSTR) < 0) {
|
||||
warnx("%s", mailname);
|
||||
relsesigs();
|
||||
reset(0);
|
||||
}
|
||||
@ -474,7 +479,7 @@ edstop()
|
||||
}
|
||||
fflush(obuf);
|
||||
if (ferror(obuf)) {
|
||||
perror(mailname);
|
||||
warn("%s", mailname);
|
||||
relsesigs();
|
||||
reset(0);
|
||||
}
|
||||
|
@ -31,6 +31,8 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)rcv.h 8.1 (Berkeley) 6/6/93
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)send.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "rcv.h"
|
||||
@ -52,7 +56,7 @@ static char sccsid[] = "@(#)send.c 8.1 (Berkeley) 6/6/93";
|
||||
* prefix is a string to prepend to each output line.
|
||||
*/
|
||||
int
|
||||
send(mp, obuf, doign, prefix)
|
||||
sendmessage(mp, obuf, doign, prefix)
|
||||
register struct message *mp;
|
||||
FILE *obuf;
|
||||
struct ignoretab *doign;
|
||||
@ -87,7 +91,7 @@ send(mp, obuf, doign, prefix)
|
||||
* Process headers first
|
||||
*/
|
||||
while (count > 0 && ishead) {
|
||||
if (fgets(line, LINESIZE, ibuf) == NULL)
|
||||
if (fgets(line, sizeof(line), ibuf) == NULL)
|
||||
break;
|
||||
count -= length = strlen(line);
|
||||
if (firstline) {
|
||||
@ -172,12 +176,13 @@ send(mp, obuf, doign, prefix)
|
||||
* Strip trailing whitespace from prefix
|
||||
* if line is blank.
|
||||
*/
|
||||
if (prefix != NOSTR)
|
||||
if (prefix != NOSTR) {
|
||||
if (length > 1)
|
||||
fputs(prefix, obuf);
|
||||
else
|
||||
(void) fwrite(prefix, sizeof *prefix,
|
||||
prefixlen, obuf);
|
||||
}
|
||||
(void) fwrite(line, sizeof *line, length, obuf);
|
||||
if (ferror(obuf))
|
||||
return -1;
|
||||
@ -190,7 +195,7 @@ send(mp, obuf, doign, prefix)
|
||||
count--; /* skip final blank line */
|
||||
if (prefix != NOSTR)
|
||||
while (count > 0) {
|
||||
if (fgets(line, LINESIZE, ibuf) == NULL) {
|
||||
if (fgets(line, sizeof(line), ibuf) == NULL) {
|
||||
c = 0;
|
||||
break;
|
||||
}
|
||||
@ -312,18 +317,20 @@ mail1(hp, printheaders)
|
||||
*/
|
||||
if ((mtf = collect(hp, printheaders)) == NULL)
|
||||
return;
|
||||
if (value("interactive") != NOSTR)
|
||||
if (value("interactive") != NOSTR) {
|
||||
if (value("askcc") != NOSTR)
|
||||
grabh(hp, GCC);
|
||||
else {
|
||||
printf("EOT\n");
|
||||
(void) fflush(stdout);
|
||||
}
|
||||
if (fsize(mtf) == 0)
|
||||
}
|
||||
if (fsize(mtf) == 0) {
|
||||
if (hp->h_subject == NOSTR)
|
||||
printf("No message, no subject; hope that's ok\n");
|
||||
else
|
||||
printf("Null message body; hope that's ok\n");
|
||||
}
|
||||
/*
|
||||
* Now, take the user names from the combined
|
||||
* to and cc lists and do all the alias
|
||||
@ -369,7 +376,7 @@ mail1(hp, printheaders)
|
||||
*/
|
||||
pid = fork();
|
||||
if (pid == -1) {
|
||||
perror("fork");
|
||||
warn("fork");
|
||||
savedeadletter(mtf);
|
||||
goto out;
|
||||
}
|
||||
@ -382,7 +389,7 @@ mail1(hp, printheaders)
|
||||
else
|
||||
cp = _PATH_SENDMAIL;
|
||||
execv(cp, namelist);
|
||||
perror(cp);
|
||||
warn("%s", cp);
|
||||
_exit(1);
|
||||
}
|
||||
if (value("verbose") != NOSTR)
|
||||
@ -428,20 +435,24 @@ infix(hp, fi)
|
||||
struct header *hp;
|
||||
FILE *fi;
|
||||
{
|
||||
extern char *tempMail;
|
||||
register FILE *nfo, *nfi;
|
||||
register int c;
|
||||
int fd;
|
||||
char tempname[PATHSIZE];
|
||||
|
||||
if ((nfo = Fopen(tempMail, "w")) == NULL) {
|
||||
perror(tempMail);
|
||||
snprintf(tempname, sizeof(tempname), "%s/mail.RsXXXXXXXXXX", tmpdir);
|
||||
if ((fd = mkstemp(tempname)) == -1 ||
|
||||
(nfo = Fdopen(fd, "w")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
return(fi);
|
||||
}
|
||||
if ((nfi = Fopen(tempMail, "r")) == NULL) {
|
||||
perror(tempMail);
|
||||
if ((nfi = Fopen(tempname, "r")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
(void) Fclose(nfo);
|
||||
(void) rm(tempname);
|
||||
return(fi);
|
||||
}
|
||||
(void) rm(tempMail);
|
||||
(void) rm(tempname);
|
||||
(void) puthead(hp, nfo,
|
||||
GTO|GSUBJECT|GCC|GBCC|GREPLYTO|GINREPLYTO|GNL|GCOMMA);
|
||||
c = getc(fi);
|
||||
@ -450,13 +461,13 @@ infix(hp, fi)
|
||||
c = getc(fi);
|
||||
}
|
||||
if (ferror(fi)) {
|
||||
perror("read");
|
||||
warnx("read");
|
||||
rewind(fi);
|
||||
return(fi);
|
||||
}
|
||||
(void) fflush(nfo);
|
||||
if (ferror(nfo)) {
|
||||
perror(tempMail);
|
||||
warn("%s", tempname);
|
||||
(void) Fclose(nfo);
|
||||
(void) Fclose(nfi);
|
||||
rewind(fi);
|
||||
@ -549,7 +560,7 @@ savemail(name, fi)
|
||||
char *ctime();
|
||||
|
||||
if ((fo = Fopen(name, "a")) == NULL) {
|
||||
perror(name);
|
||||
warn("%s", name);
|
||||
return (-1);
|
||||
}
|
||||
(void) time(&now);
|
||||
@ -559,7 +570,7 @@ savemail(name, fi)
|
||||
(void) putc('\n', fo);
|
||||
(void) fflush(fo);
|
||||
if (ferror(fo))
|
||||
perror(name);
|
||||
warn("%s", name);
|
||||
(void) Fclose(fo);
|
||||
rewind(fi);
|
||||
return (0);
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)strings.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -75,14 +79,11 @@ salloc(size)
|
||||
index++;
|
||||
}
|
||||
if (sp >= &stringdope[NSPACE])
|
||||
panic("String too large");
|
||||
errx(1, "String too large");
|
||||
if (sp->s_topFree == NOSTR) {
|
||||
index = sp - &stringdope[0];
|
||||
sp->s_topFree = malloc(STRINGSIZE << index);
|
||||
if (sp->s_topFree == NOSTR) {
|
||||
fprintf(stderr, "No room for space %d\n", index);
|
||||
panic("Internal error");
|
||||
}
|
||||
if ((sp->s_topFree = malloc(STRINGSIZE << index)) == NOSTR)
|
||||
err(1, "No room for space %d", index);
|
||||
sp->s_nextFree = sp->s_topFree;
|
||||
sp->s_nleft = STRINGSIZE << index;
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ static const char rcsid[] =
|
||||
#endif /* not lint */
|
||||
|
||||
#include "rcv.h"
|
||||
#include <err.h>
|
||||
#include "extern.h"
|
||||
|
||||
/*
|
||||
@ -49,75 +48,45 @@ static const char rcsid[] =
|
||||
* Give names to all the temporary files that we will need.
|
||||
*/
|
||||
|
||||
char *tempMail;
|
||||
char *tempQuit;
|
||||
char *tempEdit;
|
||||
char *tempResid;
|
||||
char *tempMesg;
|
||||
char *tmpdir;
|
||||
|
||||
void
|
||||
tinit()
|
||||
{
|
||||
register char *cp;
|
||||
int len;
|
||||
|
||||
if ((tmpdir = getenv("TMPDIR")) == NULL)
|
||||
if ((tmpdir = getenv("TMPDIR")) == NULL || *tmpdir == '\0')
|
||||
tmpdir = _PATH_TMP;
|
||||
else {
|
||||
len = strlen(tmpdir);
|
||||
if ((cp = malloc(len + 2)) == NULL)
|
||||
panic("Out of memory");
|
||||
(void)strcpy(cp, tmpdir);
|
||||
cp[len] = '/';
|
||||
cp[len + 1] = '\0';
|
||||
tmpdir = cp;
|
||||
if ((tmpdir = strdup(tmpdir)) == NULL)
|
||||
errx(1, "Out of memory");
|
||||
/* Strip trailing '/' if necessary */
|
||||
cp = tmpdir + strlen(tmpdir) - 1;
|
||||
while (cp > tmpdir && *cp == '/') {
|
||||
*cp = '\0';
|
||||
cp--;
|
||||
}
|
||||
len = strlen(tmpdir);
|
||||
if ((tempMail = malloc(len + sizeof("RsXXXXXX"))) == NULL)
|
||||
panic("Out of memory");
|
||||
strcpy(tempMail, tmpdir);
|
||||
mktemp(strcat(tempMail, "RsXXXXXX"));
|
||||
if ((tempResid = malloc(len + sizeof("RqXXXXXX"))) == NULL)
|
||||
panic("Out of memory");
|
||||
strcpy(tempResid, tmpdir);
|
||||
mktemp(strcat(tempResid, "RqXXXXXX"));
|
||||
if ((tempQuit = malloc(len + sizeof("RmXXXXXX"))) == NULL)
|
||||
panic("Out of memory");
|
||||
strcpy(tempQuit, tmpdir);
|
||||
mktemp(strcat(tempQuit, "RmXXXXXX"));
|
||||
if ((tempEdit = malloc(len + sizeof("ReXXXXXX"))) == NULL)
|
||||
panic("Out of memory");
|
||||
strcpy(tempEdit, tmpdir);
|
||||
mktemp(strcat(tempEdit, "ReXXXXXX"));
|
||||
if ((tempMesg = malloc(len + sizeof("RxXXXXXX"))) == NULL)
|
||||
panic("Out of memory");
|
||||
strcpy(tempMesg, tmpdir);
|
||||
mktemp(strcat(tempMesg, "RxXXXXXX"));
|
||||
|
||||
/*
|
||||
* It's okay to call savestr in here because main will
|
||||
* do a spreserve() after us.
|
||||
*/
|
||||
if (myname != NOSTR) {
|
||||
if (getuserid(myname) < 0) {
|
||||
printf("\"%s\" is not a user of this system\n",
|
||||
myname);
|
||||
exit(1);
|
||||
}
|
||||
if (getuserid(myname) < 0)
|
||||
errx(1, "\"%s\" is not a user of this system", myname);
|
||||
} else {
|
||||
if ((cp = username()) == NOSTR) {
|
||||
myname = "ubluit";
|
||||
if (rcvmode) {
|
||||
printf("Who are you!?\n");
|
||||
exit(1);
|
||||
}
|
||||
if (rcvmode)
|
||||
errx(1, "Who are you!?");
|
||||
} else
|
||||
myname = savestr(cp);
|
||||
}
|
||||
if ((cp = getenv("HOME")) == NOSTR)
|
||||
cp = ".";
|
||||
homedir = savestr(cp);
|
||||
if ((cp = getenv("HOME")) == NOSTR || *cp == '\0' ||
|
||||
strlen(cp) >= PATHSIZE)
|
||||
homedir = NULL;
|
||||
else
|
||||
homedir = savestr(cp);
|
||||
if (debug)
|
||||
printf("user = %s, homedir = %s\n", myname, homedir);
|
||||
printf("user = %s, homedir = %s\n", myname,
|
||||
homedir ? homedir : "NONE");
|
||||
}
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -80,7 +84,7 @@ grabh(hp, gflags)
|
||||
ttyset = 0;
|
||||
#endif
|
||||
if (tcgetattr(fileno(stdin), &tio) < 0) {
|
||||
perror("tcgetattr(stdin)");
|
||||
warn("tcgetattr(stdin)");
|
||||
return(-1);
|
||||
}
|
||||
c_erase = tio.c_cc[VERASE];
|
||||
@ -167,9 +171,9 @@ readtty(pr, src)
|
||||
}
|
||||
#ifndef TIOCSTI
|
||||
if (src != NOSTR)
|
||||
cp = copy(src, canonb);
|
||||
strlcpy(canonb, src, sizeof(canonb));
|
||||
else
|
||||
cp = copy("", canonb);
|
||||
*canonb = '\0';
|
||||
fputs(canonb, stdout);
|
||||
fflush(stdout);
|
||||
#else
|
||||
@ -183,11 +187,11 @@ readtty(pr, src)
|
||||
ioctl(0, TIOCSTI, &ch);
|
||||
}
|
||||
cp = canonb;
|
||||
*cp = 0;
|
||||
*cp = '\0';
|
||||
#endif
|
||||
cp2 = cp;
|
||||
while (cp2 < canonb + BUFSIZ)
|
||||
*cp2++ = 0;
|
||||
*cp2++ = '\0';
|
||||
cp2 = cp;
|
||||
if (setjmp(rewrite))
|
||||
goto redo;
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)v7.local.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -52,15 +56,16 @@ static char sccsid[] = "@(#)v7.local.c 8.1 (Berkeley) 6/6/93";
|
||||
* mail is queued).
|
||||
*/
|
||||
void
|
||||
findmail(user, buf)
|
||||
findmail(user, buf, buflen)
|
||||
char *user, *buf;
|
||||
int buflen;
|
||||
{
|
||||
char *tmp = getenv("MAIL");
|
||||
|
||||
if (tmp == NULL)
|
||||
(void)sprintf(buf, "%s/%s", _PATH_MAILDIR, user);
|
||||
(void)snprintf(buf, buflen, "%s/%s", _PATH_MAILDIR, user);
|
||||
else
|
||||
(void)strcpy(buf, tmp);
|
||||
(void)strlcpy(buf, tmp, buflen);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -71,7 +76,7 @@ demail()
|
||||
{
|
||||
|
||||
if (value("keep") != NOSTR || rm(mailname) < 0)
|
||||
close(creat(mailname, 0600));
|
||||
close(open(mailname, O_CREAT | O_TRUNC | O_WRONLY, 0600));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -81,8 +86,14 @@ char *
|
||||
username()
|
||||
{
|
||||
char *np;
|
||||
uid_t uid;
|
||||
|
||||
if ((np = getenv("USER")) != NOSTR)
|
||||
return np;
|
||||
return getname(getuid());
|
||||
if ((np = getenv("LOGNAME")) != NOSTR)
|
||||
return np;
|
||||
if ((np = getname(uid = getuid())) != NOSTR)
|
||||
return np;
|
||||
printf("Cannot associate a name with uid %u\n", (unsigned)uid);
|
||||
return NOSTR;
|
||||
}
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)vars.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "rcv.h"
|
||||
@ -96,7 +100,7 @@ vcopy(str)
|
||||
return "";
|
||||
len = strlen(str) + 1;
|
||||
if ((new = malloc(len)) == NULL)
|
||||
panic("Out of memory");
|
||||
err(1, "Out of memory");
|
||||
bcopy(str, new, (int) len);
|
||||
return new;
|
||||
}
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)version.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user