Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/mail set close on exec for all opened files.
details: https://anonhg.NetBSD.org/src/rev/179c34f657e0
branches: trunk
changeset: 779070:179c34f657e0
user: christos <christos%NetBSD.org@localhost>
date: Sun Apr 29 23:50:22 2012 +0000
description:
set close on exec for all opened files.
diffstat:
usr.bin/mail/cmd1.c | 6 +++---
usr.bin/mail/cmd2.c | 6 +++---
usr.bin/mail/cmd3.c | 6 +++---
usr.bin/mail/collect.c | 16 ++++++++--------
usr.bin/mail/edit.c | 8 ++++----
usr.bin/mail/fio.c | 6 +++---
usr.bin/mail/lex.c | 22 ++++++++++------------
usr.bin/mail/list.c | 6 +++---
usr.bin/mail/mime_attach.c | 20 ++++++++++----------
usr.bin/mail/mime_child.c | 8 +++-----
usr.bin/mail/mime_detach.c | 10 +++++-----
usr.bin/mail/names.c | 13 ++++++-------
usr.bin/mail/popen.c | 16 +++++-----------
usr.bin/mail/quit.c | 36 ++++++++++++++++++------------------
usr.bin/mail/send.c | 10 +++++-----
usr.bin/mail/support.c | 8 ++++----
16 files changed, 93 insertions(+), 104 deletions(-)
diffs (truncated from 844 to 300 lines):
diff -r fcc902501711 -r 179c34f657e0 usr.bin/mail/cmd1.c
--- a/usr.bin/mail/cmd1.c Sun Apr 29 22:55:11 2012 +0000
+++ b/usr.bin/mail/cmd1.c Sun Apr 29 23:50:22 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cmd1.c,v 1.31 2011/09/16 15:39:27 joerg Exp $ */
+/* $NetBSD: cmd1.c,v 1.32 2012/04/29 23:50:22 christos Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)cmd1.c 8.2 (Berkeley) 4/20/95";
#else
-__RCSID("$NetBSD: cmd1.c,v 1.31 2011/09/16 15:39:27 joerg Exp $");
+__RCSID("$NetBSD: cmd1.c,v 1.32 2012/04/29 23:50:22 christos Exp $");
#endif
#endif /* not lint */
@@ -461,7 +461,7 @@
goto close_pipe;
sig_check();
- obuf = Popen(cmd, "w");
+ obuf = Popen(cmd, "we");
if (obuf == NULL) {
warn("pipecmd: Popen failed: %s", cmd);
return 1;
diff -r fcc902501711 -r 179c34f657e0 usr.bin/mail/cmd2.c
--- a/usr.bin/mail/cmd2.c Sun Apr 29 22:55:11 2012 +0000
+++ b/usr.bin/mail/cmd2.c Sun Apr 29 23:50:22 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cmd2.c,v 1.24 2009/04/10 13:08:24 christos Exp $ */
+/* $NetBSD: cmd2.c,v 1.25 2012/04/29 23:50:22 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)cmd2.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: cmd2.c,v 1.24 2009/04/10 13:08:24 christos Exp $");
+__RCSID("$NetBSD: cmd2.c,v 1.25 2012/04/29 23:50:22 christos Exp $");
#endif
#endif /* not lint */
@@ -230,7 +230,7 @@
disp = "[Appended]";
else
disp = "[New file]";
- if ((obuf = Fopen(fn, "a")) == NULL) {
+ if ((obuf = Fopen(fn, "ae")) == NULL) {
warn(NULL);
return 1;
}
diff -r fcc902501711 -r 179c34f657e0 usr.bin/mail/cmd3.c
--- a/usr.bin/mail/cmd3.c Sun Apr 29 22:55:11 2012 +0000
+++ b/usr.bin/mail/cmd3.c Sun Apr 29 23:50:22 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cmd3.c,v 1.41 2009/04/11 14:22:32 christos Exp $ */
+/* $NetBSD: cmd3.c,v 1.42 2012/04/29 23:50:22 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)cmd3.c 8.2 (Berkeley) 4/20/95";
#else
-__RCSID("$NetBSD: cmd3.c,v 1.41 2009/04/11 14:22:32 christos Exp $");
+__RCSID("$NetBSD: cmd3.c,v 1.42 2012/04/29 23:50:22 christos Exp $");
#endif
#endif /* not lint */
@@ -501,7 +501,7 @@
(void)snprintf(mailtempname, sizeof(mailtempname),
"%s/mail.RsXXXXXXXXXX", tmpdir);
if ((fd = mkstemp(mailtempname)) == -1 ||
- (obuf = Fdopen(fd, "w+")) == NULL) {
+ (obuf = Fdopen(fd, "we+")) == NULL) {
if (fd != -1)
(void)close(fd);
warn("%s", mailtempname);
diff -r fcc902501711 -r 179c34f657e0 usr.bin/mail/collect.c
--- a/usr.bin/mail/collect.c Sun Apr 29 22:55:11 2012 +0000
+++ b/usr.bin/mail/collect.c Sun Apr 29 23:50:22 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: collect.c,v 1.44 2011/09/16 15:39:27 joerg Exp $ */
+/* $NetBSD: collect.c,v 1.45 2012/04/29 23:50:22 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)collect.c 8.2 (Berkeley) 4/19/94";
#else
-__RCSID("$NetBSD: collect.c,v 1.44 2011/09/16 15:39:27 joerg Exp $");
+__RCSID("$NetBSD: collect.c,v 1.45 2012/04/29 23:50:22 christos Exp $");
#endif
#endif /* not lint */
@@ -97,7 +97,7 @@
(void)fprintf(stderr, "File exists\n");
return -1;
}
- if ((of = Fopen(name, "w")) == NULL) {
+ if ((of = Fopen(name, "we")) == NULL) {
warn("%s", name);
return -1;
}
@@ -165,7 +165,7 @@
(void)snprintf(tempname, sizeof(tempname),
"%s/mail.ReXXXXXXXXXX", tmpdir);
if ((fd = mkstemp(tempname)) == -1 ||
- (nf = Fdopen(fd, "w+")) == NULL) {
+ (nf = Fdopen(fd, "we+")) == NULL) {
if (fd != -1)
(void)close(fd);
warn("%s", tempname);
@@ -286,7 +286,7 @@
return;
cp = getdeadletter();
m = umask(077);
- dbuf = Fopen(cp, "a");
+ dbuf = Fopen(cp, "ae");
(void)umask(m);
if (dbuf == NULL)
return;
@@ -397,7 +397,7 @@
(void)snprintf(mailtempname, sizeof(mailtempname),
"%s/mail.RsXXXXXXXXXX", tmpdir);
if ((fd = mkstemp(mailtempname)) == -1 ||
- (collf = Fdopen(fd, "w+")) == NULL) {
+ (collf = Fdopen(fd, "we+")) == NULL) {
if (fd != -1)
(void)close(fd);
warn("%s", mailtempname);
@@ -628,7 +628,7 @@
(void)snprintf(tempname, sizeof(tempname),
"%s/mail.ReXXXXXXXXXX", tmpdir);
if ((fd = mkstemp(tempname)) == -1 ||
- (fbuf = Fdopen(fd, "w+")) == NULL) {
+ (fbuf = Fdopen(fd, "we+")) == NULL) {
if (fd != -1)
(void)close(fd);
warn("%s", tempname);
@@ -660,7 +660,7 @@
(void)printf("%s: Directory\n", cp);
break;
}
- else if ((fbuf = Fopen(cp, "r")) == NULL) {
+ else if ((fbuf = Fopen(cp, "re")) == NULL) {
warn("%s", cp);
break;
}
diff -r fcc902501711 -r 179c34f657e0 usr.bin/mail/edit.c
--- a/usr.bin/mail/edit.c Sun Apr 29 22:55:11 2012 +0000
+++ b/usr.bin/mail/edit.c Sun Apr 29 23:50:22 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: edit.c,v 1.26 2012/01/16 17:38:16 christos Exp $ */
+/* $NetBSD: edit.c,v 1.27 2012/04/29 23:50:22 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)edit.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: edit.c,v 1.26 2012/01/16 17:38:16 christos Exp $");
+__RCSID("$NetBSD: edit.c,v 1.27 2012/04/29 23:50:22 christos Exp $");
#endif
#endif /* not lint */
@@ -77,7 +77,7 @@
(void)unlink(tempname);
goto out;
}
- if ((nf = Fdopen(t, "w")) == NULL) {
+ if ((nf = Fdopen(t, "we")) == NULL) {
(void)close(t);
warn("%s", tempname);
(void)unlink(tempname);
@@ -134,7 +134,7 @@
/*
* Now switch to new file.
*/
- if ((nf = Fopen(tempname, "a+")) == NULL) {
+ if ((nf = Fopen(tempname, "ae+")) == NULL) {
warn("%s", tempname);
(void)unlink(tempname);
goto out;
diff -r fcc902501711 -r 179c34f657e0 usr.bin/mail/fio.c
--- a/usr.bin/mail/fio.c Sun Apr 29 22:55:11 2012 +0000
+++ b/usr.bin/mail/fio.c Sun Apr 29 23:50:22 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fio.c,v 1.34 2010/01/12 14:45:31 christos Exp $ */
+/* $NetBSD: fio.c,v 1.35 2012/04/29 23:50:22 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)fio.c 8.2 (Berkeley) 4/20/95";
#else
-__RCSID("$NetBSD: fio.c,v 1.34 2010/01/12 14:45:31 christos Exp $");
+__RCSID("$NetBSD: fio.c,v 1.35 2012/04/29 23:50:22 christos Exp $");
#endif
#endif /* not lint */
@@ -189,7 +189,7 @@
/* Get temporary file. */
(void)snprintf(linebuf, LINESIZE, "%s/mail.XXXXXX", tmpdir);
if ((c = mkstemp(linebuf)) == -1 ||
- (mestmp = Fdopen(c, "r+")) == NULL) {
+ (mestmp = Fdopen(c, "re+")) == NULL) {
(void)fprintf(stderr, "mail: can't open %s\n", linebuf);
exit(1);
}
diff -r fcc902501711 -r 179c34f657e0 usr.bin/mail/lex.c
--- a/usr.bin/mail/lex.c Sun Apr 29 22:55:11 2012 +0000
+++ b/usr.bin/mail/lex.c Sun Apr 29 23:50:22 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.40 2011/09/16 15:39:27 joerg Exp $ */
+/* $NetBSD: lex.c,v 1.41 2012/04/29 23:50:22 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)lex.c 8.2 (Berkeley) 4/20/95";
#else
-__RCSID("$NetBSD: lex.c,v 1.40 2011/09/16 15:39:27 joerg Exp $");
+__RCSID("$NetBSD: lex.c,v 1.41 2012/04/29 23:50:22 christos Exp $");
#endif
#endif /* not lint */
@@ -173,7 +173,7 @@
if ((name = expand(name)) == NULL)
return -1;
- if ((ibuf = Fopen(name, "r")) == NULL) {
+ if ((ibuf = Fopen(name, "re")) == NULL) {
if (!isedit && errno == ENOENT)
goto nomail;
warn("Can't open `%s'", name);
@@ -238,12 +238,10 @@
(void)snprintf(tempname, sizeof(tempname),
"%s/mail.RxXXXXXXXXXX", tmpdir);
if ((fd = mkstemp(tempname)) == -1 ||
- (otf = fdopen(fd, "w")) == NULL)
+ (otf = fdopen(fd, "we")) == NULL)
err(EXIT_FAILURE, "Can't create tmp file `%s'", tempname);
- (void)fcntl(fileno(otf), F_SETFD, FD_CLOEXEC);
- if ((itf = fopen(tempname, "r")) == NULL)
+ if ((itf = fopen(tempname, "re")) == NULL)
err(EXIT_FAILURE, "Can't create tmp file `%s'", tempname);
- (void)fcntl(fileno(itf), F_SETFD, FD_CLOEXEC);
(void)rm(tempname);
setptr(ibuf, (off_t)0);
setmsize(get_abs_msgCount());
@@ -279,7 +277,7 @@
omsgCount = get_abs_msgCount();
- ibuf = Fopen(mailname, "r");
+ ibuf = Fopen(mailname, "re");
if (ibuf == NULL)
return -1;
sig_check();
@@ -449,7 +447,7 @@
cp++;
if (c == '|') {
- if ((fout = Popen(cp, "w")) == NULL) {
+ if ((fout = Popen(cp, "we")) == NULL) {
warn("Popen: %s", cp);
return -1;
}
@@ -457,7 +455,7 @@
else {
const char *mode;
assert(c == '>');
- mode = *cp == '>' ? "a" : "w";
+ mode = *cp == '>' ? "ae" : "we";
if (*cp == '>')
cp++;
@@ -475,7 +473,7 @@
if (pager == NULL || *pager == '\0')
pager = _PATH_MORE;
- if ((fout = Popen(pager, "w")) == NULL) {
+ if ((fout = Popen(pager, "we")) == NULL) {
warn("Popen: %s", pager);
return -1;
}
@@ -1097,7 +1095,7 @@
{
FILE *in, *oldin;
- if ((in = Fopen(name, "r")) == NULL)
+ if ((in = Fopen(name, "re")) == NULL)
Home |
Main Index |
Thread Index |
Old Index