Discussion:
[rancid] expect-hack1 not applied to patched version of expect-5.4.3 on the FTP site?
Matthew J Wilson
2012-08-27 16:25:54 UTC
Permalink
Hi -

My read of the "O/S-specific information" section at
<http://www.shrubbery.net/rancid/#osystems> is that "expect-hack1" should
be already applied to the expect-5.43.0.tar.bz2 file available from
<ftp://ftp.shrubbery.net/pub/rancid/>. But when I download this file and
look at exp_chan.c , I don't see the line
fcntl(esPtr->fdin, F_SETFL, O_NONBLOCK);

added to sub ExpInputProc .

Has the unpatched version of exp_chan.c been incorrectly included in
expect-5.43.0.tar.bz2 ? Or am I missing something?

Thanks!
Matt
heasley
2012-08-28 18:21:39 UTC
Permalink
Post by Matthew J Wilson
My read of the "O/S-specific information" section at
<http://www.shrubbery.net/rancid/#osystems> is that "expect-hack1" should
be already applied to the expect-5.43.0.tar.bz2 file available from
<ftp://ftp.shrubbery.net/pub/rancid/>. But when I download this file and
look at exp_chan.c , I don't see the line
fcntl(esPtr->fdin, F_SETFL, O_NONBLOCK);
added to sub ExpInputProc .
Has the unpatched version of exp_chan.c been incorrectly included in
expect-5.43.0.tar.bz2 ? Or am I missing something?
thats the virgin, iirc,

ftp://ftp.shrubbery.net/pub/rancid/expect-5.43.0_hack.tar.bz2
Matthew J Wilson
2012-08-28 19:17:53 UTC
Permalink
Post by heasley
thats the virgin, iirc,
ftp://ftp.shrubbery.net/pub/rancid/expect-5.43.0_hack.tar.bz2
That tarball (when I download it anyway) has expect-hack2 applied to it
for solaris, not expect-hack1 for linux (diff -u output appended at the
bottom of this email).

When I look at the tarballs from the FTP site:
expect-5.40.1.tar.gz - has linux expect-hack1 applied
expect-5.40.1_hack2.tar.gz - has solaris expect-hack2 applied
expect-5.43.0.tar.bz2 - vanilla: no hack patch applied
expect-5.43.0_hack.tar.bz2 - has solaris expect-hack2 applied

I don't see an expect-5.43 tarball on the FTP site that has the linux
expect-hack1 applied to it.

Thanks for taking a look at this.
Matt



$ diff -u expect-5.43/exp_chan.c.orig expect-5.43/exp_chan.c
--- expect-5.43/exp_chan.c.orig 2005-02-07 20:01:20.000000000 -0600
+++ expect-5.43/exp_chan.c 2010-11-12 15:10:44.000000000 -0600
@@ -12,6 +12,7 @@
#include <errno.h>
#include <ctype.h> /* for isspace */
#include <time.h> /* for time(3) */
+#include <poll.h>

#include "expect_cf.h"

@@ -190,6 +191,7 @@
ExpState *esPtr = (ExpState *) instanceData;
int bytesRead; /* How many bytes were actually
* read from the input device? */
+struct pollfd fds[1];

*errorCodePtr = 0;

@@ -199,6 +201,16 @@
* possible, if the channel is in blocking mode. If the channel is
* nonblocking, the read will never block.
*/
+fds[0].fd = esPtr->fdin;
+fds[0].events = POLLIN | POLLERR | POLLHUP | POLLNVAL;
+bytesRead = poll(fds, 1, 0);
+if (bytesRead <= 0) {
+ *errorCodePtr = EWOULDBLOCK;
+ return(-1);
+} else if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) {
+ *errorCodePtr = EBADF;
+ return(-1);
+}

bytesRead = read(esPtr->fdin, buf, (size_t) toRead);
/*printf("ExpInputProc: read(%d,,) = %d\r\n",esPtr->fdin,bytesRead);*/
heasley
2012-08-28 19:36:48 UTC
Permalink
Post by Matthew J Wilson
Post by heasley
thats the virgin, iirc,
ftp://ftp.shrubbery.net/pub/rancid/expect-5.43.0_hack.tar.bz2
That tarball (when I download it anyway) has expect-hack2 applied to it
for solaris, not expect-hack1 for linux (diff -u output appended at the
bottom of this email).
it should work just fine; the one for solaris is just more "complete" and
avoids a problem that affect bash if an expect timeout followed. it should
compile on linux.
Post by Matthew J Wilson
expect-5.40.1.tar.gz - has linux expect-hack1 applied
expect-5.40.1_hack2.tar.gz - has solaris expect-hack2 applied
expect-5.43.0.tar.bz2 - vanilla: no hack patch applied
expect-5.43.0_hack.tar.bz2 - has solaris expect-hack2 applied
I don't see an expect-5.43 tarball on the FTP site that has the linux
expect-hack1 applied to it.
Thanks for taking a look at this.
Matt
$ diff -u expect-5.43/exp_chan.c.orig expect-5.43/exp_chan.c
--- expect-5.43/exp_chan.c.orig 2005-02-07 20:01:20.000000000 -0600
+++ expect-5.43/exp_chan.c 2010-11-12 15:10:44.000000000 -0600
@@ -12,6 +12,7 @@
#include <errno.h>
#include <ctype.h> /* for isspace */
#include <time.h> /* for time(3) */
+#include <poll.h>
#include "expect_cf.h"
@@ -190,6 +191,7 @@
ExpState *esPtr = (ExpState *) instanceData;
int bytesRead; /* How many bytes were actually
* read from the input device? */
+struct pollfd fds[1];
*errorCodePtr = 0;
@@ -199,6 +201,16 @@
* possible, if the channel is in blocking mode. If the channel is
* nonblocking, the read will never block.
*/
+fds[0].fd = esPtr->fdin;
+fds[0].events = POLLIN | POLLERR | POLLHUP | POLLNVAL;
+bytesRead = poll(fds, 1, 0);
+if (bytesRead <= 0) {
+ *errorCodePtr = EWOULDBLOCK;
+ return(-1);
+} else if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) {
+ *errorCodePtr = EBADF;
+ return(-1);
+}
bytesRead = read(esPtr->fdin, buf, (size_t) toRead);
/*printf("ExpInputProc: read(%d,,) = %d\r\n",esPtr->fdin,bytesRead);*/
Matthew J Wilson
2012-08-28 19:41:40 UTC
Permalink
Post by heasley
Post by Matthew J Wilson
Post by heasley
thats the virgin, iirc,
ftp://ftp.shrubbery.net/pub/rancid/expect-5.43.0_hack.tar.bz2
That tarball (when I download it anyway) has expect-hack2 applied to it
for solaris, not expect-hack1 for linux (diff -u output appended at the
bottom of this email).
it should work just fine; the one for solaris is just more "complete" and
avoids a problem that affect bash if an expect timeout followed. it
should
compile on linux.
That's what I was missing. Thanks! -Matt

Loading...