(sendmail_send_message): Don't close the descriptor if it happens to make part of tunnel pipe.
Showing
1 changed file
with
6 additions
and
3 deletions
... | @@ -166,6 +166,9 @@ sendmail_close (mailer_t mailer) | ... | @@ -166,6 +166,9 @@ sendmail_close (mailer_t mailer) |
166 | return 0; | 166 | return 0; |
167 | } | 167 | } |
168 | 168 | ||
169 | /* Close FD unless it is part of pipe P */ | ||
170 | #define SCLOSE(fd,p) if (p[0]!=fd&&p[1]!=fd) close(fd) | ||
171 | |||
169 | static int | 172 | static int |
170 | sendmail_send_message (mailer_t mailer, message_t msg, address_t from, | 173 | sendmail_send_message (mailer_t mailer, message_t msg, address_t from, |
171 | address_t to) | 174 | address_t to) |
... | @@ -299,9 +302,9 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from, | ... | @@ -299,9 +302,9 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from, |
299 | sendmail->pid = vfork (); | 302 | sendmail->pid = vfork (); |
300 | if (sendmail->pid == 0) /* Child. */ | 303 | if (sendmail->pid == 0) /* Child. */ |
301 | { | 304 | { |
302 | close (STDIN_FILENO); | 305 | SCLOSE (STDIN_FILENO, tunnel); |
303 | close (STDOUT_FILENO); | 306 | SCLOSE (STDOUT_FILENO, tunnel); |
304 | close (STDERR_FILENO); | 307 | SCLOSE (STDERR_FILENO, tunnel); |
305 | close (tunnel[1]); | 308 | close (tunnel[1]); |
306 | dup2 (tunnel[0], STDIN_FILENO); | 309 | dup2 (tunnel[0], STDIN_FILENO); |
307 | execv (sendmail->path, argvec); | 310 | execv (sendmail->path, argvec); | ... | ... |
-
Please register or sign in to post a comment