From 9d8f9dea7be5a8d8973198eb5367d9f055f74974 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Mon, 1 Dec 2003 22:51:58 +0000 Subject: Start at fd = 3. 2003-12-01 Jeffrey Stedfast * camel-process.c (camel_process_fork): Start at fd = 3. * camel-gpg-context.c (gpg_ctx_op_start): Same. * camel-filter-driver.c (pipe_to_system): Same. * camel-filter-search.c (run_command): Start at fd = 3. svn path=/trunk/; revision=23549 --- camel/ChangeLog | 10 ++++++++++ camel/camel-filter-driver.c | 8 ++------ camel/camel-filter-search.c | 8 ++------ camel/camel-gpg-context.c | 15 +++++---------- camel/camel-process.c | 6 ++---- 5 files changed, 21 insertions(+), 26 deletions(-) diff --git a/camel/ChangeLog b/camel/ChangeLog index 91bc565225..4300a6a310 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,13 @@ +2003-12-01 Jeffrey Stedfast + + * camel-process.c (camel_process_fork): Start at fd = 3. + + * camel-gpg-context.c (gpg_ctx_op_start): Same. + + * camel-filter-driver.c (pipe_to_system): Same. + + * camel-filter-search.c (run_command): Start at fd = 3. + 2003-12-01 Jeffrey Stedfast * camel-stream-process.c (do_exec_command): Same. diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c index 789ec90cba..75836dea67 100644 --- a/camel/camel-filter-driver.c +++ b/camel/camel-filter-driver.c @@ -692,12 +692,8 @@ pipe_to_system (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFil setsid (); maxfd = sysconf (_SC_OPEN_MAX); - if (maxfd > 0) { - for (fd = 0; fd < maxfd; fd++) { - if (fd != STDIN_FILENO && fd != STDOUT_FILENO && fd != STDERR_FILENO) - fcntl (fd, F_SETFD, FD_CLOEXEC); - } - } + for (fd = 3; fd < maxfd; fd++) + fcntl (fd, F_SETFD, FD_CLOEXEC); args = g_ptr_array_new (); for (i = 0; i < argc; i++) diff --git a/camel/camel-filter-search.c b/camel/camel-filter-search.c index c90bda41a3..42f04b0f22 100644 --- a/camel/camel-filter-search.c +++ b/camel/camel-filter-search.c @@ -530,12 +530,8 @@ run_command (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessa setsid (); maxfd = sysconf (_SC_OPEN_MAX); - if (maxfd > 0) { - for (fd = 0; fd < maxfd; fd++) { - if (fd != STDIN_FILENO && fd != STDOUT_FILENO && fd != STDERR_FILENO) - fcntl (fd, F_SETFD, FD_CLOEXEC); - } - } + for (fd = 3; fd < maxfd; fd++) + fcntl (fd, F_SETFD, FD_CLOEXEC); args = g_ptr_array_new (); for (i = 0; i < argc; i++) diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c index ee9bc4f5d3..4b7f39dd7e 100644 --- a/camel/camel-gpg-context.c +++ b/camel/camel-gpg-context.c @@ -581,16 +581,11 @@ gpg_ctx_op_start (struct _GpgCtx *gpg) setsid (); maxfd = sysconf (_SC_OPEN_MAX); - if (maxfd > 0) { - /* Loop over all fds. */ - for (i = 0; i < maxfd; i++) { - if ((i != STDIN_FILENO) && - (i != STDOUT_FILENO) && - (i != STDERR_FILENO) && - (i != fds[7]) && /* status fd */ - (i != fds[8])) /* passwd fd */ - fcntl (i, F_SETFD, FD_CLOEXEC); - } + /* Loop over all fds. */ + for (i = 3; i < maxfd; i++) { + /* don't close the status-fd or passwd-fd */ + if (i != fds[7] && i != fds[8]) + fcntl (i, F_SETFD, FD_CLOEXEC); } /* run gpg */ diff --git a/camel/camel-process.c b/camel/camel-process.c index 9e2d9657dd..04de281294 100644 --- a/camel/camel-process.c +++ b/camel/camel-process.c @@ -79,10 +79,8 @@ camel_process_fork (const char *path, char **argv, int *infd, int *outfd, int *e setsid (); if ((maxfd = sysconf (_SC_OPEN_MAX)) > 0) { - for (i = 0; i < maxfd; i++) { - if (i != STDIN_FILENO && i != STDOUT_FILENO && i != STDERR_FILENO) - fcntl (i, F_SETFD, FD_CLOEXEC); - } + for (i = 3; i < maxfd; i++) + fcntl (i, F_SETFD, FD_CLOEXEC); } execv (path, argv); -- cgit v1.2.3