--- /dev/null
+###############################################################################
+# #
+# IPFire.org - A linux based firewall #
+# Copyright (C) 2007, 2008 Michael Tremer & Christian Schmidt #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+###############################################################################
+
+###############################################################################
+# Definitions
+###############################################################################
+
+include $(PKGROOT)/Include
+
+PKG_NAME = expect
+PKG_VER = 5.43
+PKG_REL = 0
+
+PKG_MAINTAINER =
+PKG_GROUP = Development/Languages
+PKG_URL = http://expect.nist.gov/
+PKG_LICENSE = Public Domain
+PKG_SUMMARY = A program-script interaction and testing utility.
+
+PKG_BUILD_DEPS+= autoconf automake
+PKG_DEPS += tcl
+
+define PKG_DESCRIPTION
+ xpect is a tcl application for automating and testing \
+ interactive applications such as telnet, ftp, passwd, fsck, \
+ rlogin, tip, etc. Expect makes it easy for a script to \
+ control another program and interact with it.
+endef
+
+PKG_TARBALL = $(THISAPP).tar.gz
+
+CONFIGURE_OPTIONS = \
+ --mandir=/usr/share/man \
+ --with-tcl=/usr/lib \
+ --with-tclinclude=/usr/include/ \
+ --with-x=no \
+ --disable-nls \
+ --enable-shared
+
+define STAGE_INSTALL
+ cd $(DIR_APP) && make install INSTALL_ROOT=$(BUILDROOT)
+
+ # remove cryptdir/decryptdir, as Linux has no crypt command
+ rm -f $(BUILDROOT)/usr/bin/{cryptdir,decryptdir}
+ rm -f $(BUILDROOT)/usr/share/man1/{cryptdir,decryptdir}.1*
+ rm -f $(BUILDROOT)/usr/bin/autopasswd
+endef
--- /dev/null
+diff -up expect-5.43/example/mkpasswd.random expect-5.43/example/mkpasswd
+--- expect-5.43/example/mkpasswd.random 2004-12-07 00:38:21.000000000 +0100
++++ expect-5.43/example/mkpasswd 2008-09-25 12:27:19.000000000 +0200
+@@ -92,7 +92,14 @@ proc insert {pvar char} {
+ }
+
+ proc rand {m} {
+- expr {int($m*rand())}
++ set device /dev/urandom ;# /dev/random can block
++ set fileId [open $device r]
++ binary scan [read $fileId 4] i1 number
++ set clipped [expr $number % $m]
++# puts "number is $number"
++# puts "clipped is $clipped"
++ close $fileId
++ return $clipped
+ }
+
+ # choose left or right starting hand
--- /dev/null
+diff -up expect-5.43/configure.in.lib-spec expect-5.43/configure.in
+--- expect-5.43/configure.in.lib-spec 2005-02-08 02:45:06.000000000 +0100
++++ expect-5.43/configure.in 2008-09-25 12:23:26.000000000 +0200
+@@ -1141,7 +1141,7 @@ if test $ac_cv_sys_long_file_names = no;
+ fi
+
+ EXP_BUILD_LIB_SPEC="-L`pwd` -lexpect${EXP_LIB_VERSION}${DBGX}"
+-EXP_LIB_SPEC="-L\${INSTALL_ROOT}\${exec_prefix}/lib -lexpect${EXP_LIB_VERSION}${DBGX}"
++EXP_LIB_SPEC="-L\${libdir}/../.. -lexpect${EXP_LIB_VERSION}${DBGX}"
+ EXP_UNSHARED_LIB_FILE=libexpect${EXP_LIB_VERSION}${DBGX}.a
+
+ # The TCL_SHARED_LIB_SUFFIX macro below relies on the DBGX macro,
--- /dev/null
+diff -up expect-5.43/Makefile.in.libdir expect-5.43/Makefile.in
+--- expect-5.43/Makefile.in.libdir 2004-05-07 20:10:30.000000000 +0200
++++ expect-5.43/Makefile.in 2008-09-25 12:24:08.000000000 +0200
+@@ -317,7 +317,7 @@ EXP_AND_TK_LIBS = $(LDFLAGS) @EXP_AND_TK
+ CFLAGS_INT = $(MH_CFLAGS) $(CPPFLAGS) $(XCFLAGS)
+
+ LIB_INSTALL_DIR = $(tcl_libdir)
+-LIB_RUNTIME_DIR = $(tcl_libdir)
++LIB_RUNTIME_DIR = $(subst $(INSTALL_ROOT),,$(tcl_libdir))
+ # I don't understand why Tcl splits these up, but it does. LIB_RUNTIME_DIR
+ # can appear as part of the LD_SEARCH_FLAGS inherited by configure.
+
--- /dev/null
+diff -Nur expect-5.43_old/configure expect-5.43_new/configure
+--- expect-5.43_old/configure 2010-03-10 10:11:41.000000000 +0100
++++ expect-5.43_new/configure 2010-03-10 10:12:01.000000000 +0100
+@@ -9,7 +9,7 @@
+
+ # Defaults:
+ ac_help=
+-ac_default_prefix=/usr/local
++ac_default_prefix=/usr
+ # Any additions from configure.in:
+ ac_help="$ac_help
+ --enable-threads build with threads (not supported)"
--- /dev/null
+Submitted By: LFS Book <lfs-book@linuxfromscratch.org>
+Date: 2003-10-05
+Initial Package Version: 5.38
+Origin: Redhat RPM (Patch by HJ Lu)
+Description: NA
+diff -uNr expect-5.38.orig/exp_chan.c expect-5.38/exp_chan.c
+--- expect-5.38.orig/exp_chan.c 2002-02-12 13:00:55.000000000 +1100
++++ expect-5.38/exp_chan.c 2003-03-01 10:36:18.000000000 +1100
+@@ -519,6 +519,7 @@
+ esPtr->buffer = Tcl_NewStringObj("",0);
+ Tcl_IncrRefCount(esPtr->buffer);
+ esPtr->umsize = exp_default_match_max;
++ esPtr->umsize_changed = exp_default_match_max_changed;
+ /* this will reallocate object with an appropriate sized buffer */
+ expAdjust(esPtr);
+
+diff -uNr expect-5.38.orig/exp_command.h expect-5.38/exp_command.h
+--- expect-5.38.orig/exp_command.h 2002-04-08 08:57:20.000000000 +1000
++++ expect-5.38/exp_command.h 2003-03-01 10:36:18.000000000 +1100
+@@ -25,6 +25,7 @@
+ EXTERN char * exp_get_var _ANSI_ARGS_((Tcl_Interp *,char *));
+
+ EXTERN int exp_default_match_max;
++EXTERN int exp_default_match_max_changed;
+ EXTERN int exp_default_parity;
+ EXTERN int exp_default_rm_nulls;
+
+@@ -97,6 +98,7 @@
+ int msize; /* # of bytes that buffer can hold (max) */
+ int umsize; /* # of bytes (min) that is guaranteed to match */
+ /* this comes from match_max command */
++ int umsize_changed; /* is umsize changed by user? */
+ int printed; /* # of bytes written to stdout (if logging on) */
+ /* but not actually returned via a match yet */
+ int echoed; /* additional # of bytes (beyond "printed" above) */
+diff -uNr expect-5.38.orig/expect.c expect-5.38/expect.c
+--- expect-5.38.orig/expect.c 2002-04-08 09:00:33.000000000 +1000
++++ expect-5.38/expect.c 2003-03-01 10:36:18.000000000 +1100
+@@ -41,8 +41,17 @@
+ #include "tcldbg.h"
+ #endif
+
++/* The initial length is 2000. We increment it by 2000. The maximum
++ is 8MB (0x800000). */
++#define EXP_MATCH_MAX 2000
++#define EXP_MATCH_INC 2000
++#define EXP_MATCH_STEP_LIMIT 0x700000
++#define EXP_MATCH_LIMIT 0x800000
++#define EXP_MATCH_LIMIT_QUOTE "0x800000"
++
+ /* initial length of strings that we can guarantee patterns can match */
+-int exp_default_match_max = 2000;
++int exp_default_match_max = EXP_MATCH_MAX;
++int exp_default_match_max_changed = 0;
+ #define INIT_EXPECT_TIMEOUT_LIT "10" /* seconds */
+ #define INIT_EXPECT_TIMEOUT 10 /* seconds */
+ int exp_default_parity = TRUE;
+@@ -1618,6 +1627,76 @@
+ return newsize;
+ }
+
++/* returns # of bytes until we see a newline at the end or EOF. */
++/*ARGSUSED*/
++static int
++expReadNewLine(interp,esPtr,save_flags) /* INTL */
++Tcl_Interp *interp;
++ExpState *esPtr;
++int save_flags;
++{
++ int size;
++ int exp_size;
++ int full_size;
++ int count;
++ char *str;
++
++ count = 0;
++ for (;;) {
++ exp_size = expSizeGet(esPtr);
++
++ /* When we reach the limit, we will only read one char at a
++ time. */
++ if (esPtr->umsize >= EXP_MATCH_STEP_LIMIT)
++ size = TCL_UTF_MAX;
++ else
++ size = exp_size;
++
++ if (exp_size + TCL_UTF_MAX >= esPtr->msize) {
++ if (esPtr->umsize >= EXP_MATCH_LIMIT) {
++ expDiagLogU("WARNING: interact buffer is full. probably your program\r\n");
++ expDiagLogU("is not interactive or has a very long output line. The\r\n");
++ expDiagLogU("current limit is " EXP_MATCH_LIMIT_QUOTE ".\r\n");
++ expDiagLogU("Dumping first half of buffer in order to continue\r\n");
++ expDiagLogU("Recommend you enlarge the buffer.\r\n");
++ exp_buffer_shuffle(interp,esPtr,save_flags,EXPECT_OUT,"expect");
++ return count;
++ }
++ else {
++ esPtr->umsize += EXP_MATCH_INC;
++ expAdjust(esPtr);
++ }
++ }
++
++ full_size = esPtr->msize - (size / TCL_UTF_MAX);
++ size = Tcl_ReadChars(esPtr->channel,
++ esPtr->buffer,
++ full_size,
++ 1 /* append */);
++ if (size > 0) {
++ count += size;
++ /* We try again if there are more to read and we haven't
++ seen a newline at the end. */
++ if (size == full_size) {
++ str = Tcl_GetStringFromObj(esPtr->buffer, &size);
++ if (str[size - 1] != '\n')
++ continue;
++ }
++ }
++ else {
++ /* It is even trickier. We got an error from read. We have
++ to recover from it. Let's make sure the size of
++ buffer is correct. It can be corrupted. */
++ str = Tcl_GetString(esPtr->buffer);
++ Tcl_SetObjLength(esPtr->buffer, strlen(str));
++ }
++
++ break;
++ }
++
++ return count;
++}
++
+ /* returns # of bytes read or (non-positive) error of form EXP_XXX */
+ /* returns 0 for end of file */
+ /* If timeout is non-zero, set an alarm before doing the read, else assume */
+@@ -1632,6 +1711,8 @@
+ {
+ int cc = EXP_TIMEOUT;
+ int size = expSizeGet(esPtr);
++ int full_size;
++ int count;
+
+ if (size + TCL_UTF_MAX >= esPtr->msize)
+ exp_buffer_shuffle(interp,esPtr,save_flags,EXPECT_OUT,"expect");
+@@ -1648,11 +1729,43 @@
+ }
+ #endif
+
+-
++ /* FIXME: If we ask less than what is available in the tcl buffer
++ when tcl has seen EOF, we will throw away the remaining data
++ since the next read will get EOF. Since expect is line-oriented,
++ we exand our buffer to get EOF or the next newline at the end of
++ the input buffer. I don't know if it is the right fix. H.J. */
++ count = 0;
++ full_size = esPtr->msize - (size / TCL_UTF_MAX);
+ cc = Tcl_ReadChars(esPtr->channel,
+- esPtr->buffer,
+- esPtr->msize - (size / TCL_UTF_MAX),
+- 1 /* append */);
++ esPtr->buffer,
++ full_size,
++ 1 /* append */);
++ if (cc > 0) {
++ count += cc;
++ /* It gets very tricky. There are more to read. We will expand
++ our buffer and get EOF or a newline at the end unless the
++ buffer length has been changed. */
++ if (cc == full_size) {
++ char *str;
++ str = Tcl_GetStringFromObj(esPtr->buffer, &size);
++ if (str[size - 1] != '\n') {
++ if (esPtr->umsize_changed) {
++ char buf[20]; /* big enough for 64bit int in hex. */
++ snprintf(buf,sizeof(buf),"0x%x", esPtr->umsize);
++ expDiagLogU("WARNING: interact buffer is not large enough to hold\r\n");
++ expDiagLogU("all output. probably your program is not interactive or\r\n");
++ expDiagLogU("has a very long output line. The current limit is ");
++ expDiagLogU(buf);
++ expDiagLogU(".\r\n");
++ }
++ else {
++ cc = expReadNewLine(interp,esPtr,save_flags);
++ if (cc > 0)
++ count += cc;
++ }
++ }
++ }
++ }
+ i_read_errno = errno;
+
+ #ifdef SIMPLE_EVENT
+@@ -1673,7 +1786,7 @@
+ }
+ }
+ #endif
+- return cc;
++ return count > 0 ? count : cc;
+ }
+
+ /*
+@@ -2746,8 +2859,14 @@
+ return(TCL_ERROR);
+ }
+
+- if (Default) exp_default_match_max = size;
+- else esPtr->umsize = size;
++ if (Default) {
++ exp_default_match_max = size;
++ exp_default_match_max_changed = 1;
++ }
++ else {
++ esPtr->umsize = size;
++ esPtr->umsize_changed = 1;
++ }
+
+ return(TCL_OK);
+ }
--- /dev/null
+diff -up expect-5.43/exp_command.c_old expect-5.43/exp_command.c
+--- expect-5.43/exp_command.c_old 2009-02-10 16:23:48.000000000 +0100
++++ expect-5.43/exp_command.c 2009-02-10 16:31:38.000000000 +0100
+@@ -2311,12 +2311,11 @@ Tcl_Obj *CONST objv[]; /* Argument objec
+ /* Historical note: we used "close" long before there was a */
+ /* Tcl builtin by the same name. */
+
+- Tcl_CmdInfo info;
++ Tcl_CmdInfo* close_info;
+ Tcl_ResetResult(interp);
+- if (0 == Tcl_GetCommandInfo(interp,"close",&info)) {
+- info.clientData = 0;
+- }
+- return(Tcl_CloseObjCmd(info.clientData,interp,objc_orig,objv_orig));
++
++ close_info = (Tcl_CmdInfo*) Tcl_GetAssocData (interp, EXP_CMDINFO_CLOSE, NULL);
++ return(close_info->objProc(close_info->objClientData,interp,objc,objv));
+ }
+
+ if (chanName) {
+@@ -2961,7 +2960,10 @@ Tcl_Obj *CONST objv[];
+ /* if successful (i.e., TCL_RETURN is returned) */
+ /* modify the result, so that we will handle it specially */
+
+- int result = Tcl_ReturnObjCmd(clientData,interp,objc,objv);
++ Tcl_CmdInfo* return_info = (Tcl_CmdInfo*)
++ Tcl_GetAssocData (interp, EXP_CMDINFO_RETURN, NULL);
++
++ int result = return_info->objProc(return_info->objClientData,interp,objc,objv);
+ if (result == TCL_RETURN)
+ result = EXP_TCL_RETURN;
+ return result;
+diff -up expect-5.43/exp_command.h_old expect-5.43/exp_command.h
+--- expect-5.43/exp_command.h_old 2009-02-10 17:33:19.000000000 +0100
++++ expect-5.43/exp_command.h 2009-02-10 17:33:46.000000000 +0100
+@@ -326,3 +326,6 @@ EXTERN ExpState * expDevttyGet _ANSI_ARG
+ /* generic functions that really should be provided by Tcl */
+ EXTERN int expSizeGet _ANSI_ARGS_((ExpState *));
+ EXTERN int expSizeZero _ANSI_ARGS_((ExpState *));
++
++#define EXP_CMDINFO_CLOSE "expect/cmdinfo/close"
++#define EXP_CMDINFO_RETURN "expect/cmdinfo/return"
--- /dev/null
+diff -up expect-5.43/Dbg.c.tcl8.5 expect-5.43/Dbg.c
+--- expect-5.43/Dbg.c.tcl8.5 2002-03-23 05:11:54.000000000 +0100
++++ expect-5.43/Dbg.c 2008-09-25 12:25:40.000000000 +0200
+@@ -10,6 +10,7 @@ would appreciate credit if this program
+
+ #include <stdio.h>
+
++#include "expect_cf.h"
+ #include "tcldbgcf.h"
+ #if 0
+ /* tclInt.h drags in stdlib. By claiming no-stdlib, force it to drag in */
+diff -up expect-5.43/exp_inter.c.tcl8.5 expect-5.43/exp_inter.c
+--- expect-5.43/exp_inter.c.tcl8.5 2004-08-18 04:03:00.000000000 +0200
++++ expect-5.43/exp_inter.c 2008-09-25 12:25:40.000000000 +0200
+@@ -36,6 +36,7 @@ would appreciate credit if this program
+ #include <ctype.h>
+
+ #include "tcl.h"
++#include "tclInt.h"
+ #include "string.h"
+
+ #include "exp_tty_in.h"