[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
20050303: Serious error in pqact in LDM through 6.2.1
- Subject: 20050303: Serious error in pqact in LDM through 6.2.1
- Date: Thu, 03 Mar 2005 09:01:20 -0700
Harry,
You're absolutely right. pqact(1) shouldn't allow decoders to use
the standard error stream if it's not connected to a logfile.
Thanks for the patch. It'll be in the next release.
Must've felt good poking into code again. :-)
Regards,
Steve Emmerson
NOTE: All email exchanges with Unidata User Support are recorded in the
Unidata inquiry tracking system and then made publicly available
through the web. If you do not want to have your interactions made
available in this way, you must let us know in each email you send to us.
------- Original Message
>To: address@hidden
>From: Harry Edmon <address@hidden>
>Subject: Serious error in pqact in LDM through 6.2.1
>Organization: University of Washington
>Keywords: 200503031035.j23AZjv2005120 LDM 6.2.1 pqact
This is a multi-part message in MIME format.
--------------000809090306040709020509
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
There is a serious error in pqact in LDM through version 6.2.1. In
pqact there is code that closes stderr (aka unit 2) if the log file is
not specified or if it is "-". This makes unit 2 available for opening
of files, pipe, etc. The problem is when a EXEC or PIPE action is
executed, whatever is open on unit 2 is inheritted by the forked
program, which would use it as stderr. This may result in programs
writing error information into random LDM files!
My proposed solution is to remember if stderr was closed at the start of
pqact, and in that case open stderr as /dev/null when invoking EXEC or
PIPE actions. Attached is a diff file for my patch to ldm version 6.2.1.
--------------000809090306040709020509
Content-Type: text/plain;
name="patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="patch"
*** pqact/pqact.c.orig Wed Jan 26 13:35:21 2005
--- pqact/pqact.c Thu Mar 3 01:59:30 2005
***************
*** 61,66 ****
--- 61,70 ----
#define DEFAULT_PIPE_TIMEO 60
#endif /* !DEFAULT_PIPE_TIMEO */
int pipe_timeo = DEFAULT_PIPE_TIMEO;
+ /*
+ * Did we close stderr
+ */
+ int stderr_closed = 0;
/*
***************
*** 331,338 ****
*/
(void)fclose(stdin);
(void)fclose(stdout);
! if (NULL == logfname || 0 != strcmp(logfname, "-"))
(void)fclose(stderr);
/*
* Inform the "filel" module about the number of available file
--- 335,344 ----
*/
(void)fclose(stdin);
(void)fclose(stdout);
! if (NULL == logfname || 0 != strcmp(logfname, "-")) {
(void)fclose(stderr);
+ stderr_closed = 1;
+ }
/*
* Inform the "filel" module about the number of available file
*** pqact/action.c.orig Mon Aug 9 07:46:01 2004
--- pqact/action.c Thu Mar 3 02:10:45 2005
***************
*** 60,65 ****
--- 60,66 ----
int argc, char **argv,
const void *xprod, size_t xlen)
{
+ extern stderr_closed;
pid_t pid;
int dontwait = 1; /* default is not to wait */
***************
*** 102,108 ****
(void) close(fd);
}
}
! /* we leave fd 2 (stderr) alone... */
(void)close_all();
--- 103,120 ----
(void) close(fd);
}
}
! /* we leave fd 2 (stderr) alone unless already closed */
! if (stderr_closed) {
! (void)close(2);
! {
! int fd = open("/dev/null", O_WRONLY);
! if(fd > 2)
! {
! (void) dup2(fd, 2);
! (void) close(fd);
! }
! }
! }
(void)close_all();
*** pqact/filel.c.orig Mon Aug 9 12:11:12 2004
--- pqact/filel.c Thu Mar 3 02:10:23 2005
***************
*** 878,883 ****
--- 878,884 ----
static int
pipe_open(fl_entry *entry, int argc, char **argv)
{
+ extern stderr_closed;
int ac = argc;
char **av = argv;
int pfd[2];
***************
*** 943,949 ****
(void) close(fd);
}
}
! /* we leave stderr alone */
endpriv();
--- 944,961 ----
(void) close(fd);
}
}
! /* we leave fd 2 (stderr) alone unless already closed */
! if (stderr_closed) {
! (void)close(2);
! {
! int fd = open("/dev/null", O_WRONLY);
! if(fd > 2)
! {
! (void) dup2(fd, 2);
! (void) close(fd);
! }
! }
! }
endpriv();
--------------000809090306040709020509--
------- End of Original Message