5113562 [rkeene@sledge /home/rkeene/projects/libssh-win32/v0.11]$ cat -n libssh-0.11-win32-1.patch
   1 diff -uNr libssh-0.11-orig/Makefile.in libssh-0.11-rsk/Makefile.in
   2 --- libssh-0.11-orig/Makefile.in    2005-03-04 13:54:59.000000000 -0600
   3 +++ libssh-0.11-rsk/Makefile.in 2005-06-23 17:18:19.000000000 -0500
   4 @@ -15,7 +15,7 @@
   5  CC = @CC@
   6  CFLAGS = @CFLAGS@ -Iinclude/ -Wall -g
   7  LDFLAGS = @LDFLAGS@ 
   8 -LIBS = -lssh -Llibssh/
   9 +LIBS = -Llibssh/ -lssh  @LIBS@
  10  INSTALL = @INSTALL@
  11  LN= @LN_S@
  12  OBJECTS= sample.o samplesshd.o
  13 diff -uNr libssh-0.11-orig/config.h.in libssh-0.11-rsk/config.h.in
  14 --- libssh-0.11-orig/config.h.in    2005-03-04 13:54:59.000000000 -0600
  15 +++ libssh-0.11-rsk/config.h.in 2005-06-24 10:42:32.000000000 -0500
  16 @@ -18,18 +18,18 @@
  17  /* Define to 1 if you have the `getpass' function. */
  18  #undef HAVE_GETPASS
  19  
  20 +/* Define to 1 if you have the `getpwent' function. */
  21 +#undef HAVE_GETPWENT
  22 +
  23 +/* Define to 1 if you have the `getuid' function. */
  24 +#undef HAVE_GETUID
  25 +
  26  /* Define to 1 if you have the <inttypes.h> header file. */
  27  #undef HAVE_INTTYPES_H
  28  
  29  /* Define to 1 if you have the `crypto' library (-lcrypto). */
  30  #undef HAVE_LIBCRYPTO
  31  
  32 -/* Define to 1 if you have the `nsl' library (-lnsl). */
  33 -#undef HAVE_LIBNSL
  34 -
  35 -/* Define to 1 if you have the `resolv' library (-lresolv). */
  36 -#undef HAVE_LIBRESOLV
  37 -
  38  /* Define to 1 if you have the `z' library (-lz). */
  39  #undef HAVE_LIBZ
  40  
  41 @@ -61,13 +61,21 @@
  42  /* Define to 1 if you have the `poll' function. */
  43  #undef HAVE_POLL
  44  
  45 -/* Define to 1 if your system has a GNU libc compatible `realloc' function,
  46 -   and to 0 otherwise. */
  47 -#undef HAVE_REALLOC
  48 +/* Define to 1 if you have the <pty.h> header file. */
  49 +#undef HAVE_PTY_H
  50 +
  51 +/* Define to 1 if you have the <pwd.h> header file. */
  52 +#undef HAVE_PWD_H
  53  
  54  /* Define to 1 if you have the `select' function. */
  55  #undef HAVE_SELECT
  56  
  57 +/* Define to 1 if you have the `signal' function. */
  58 +#undef HAVE_SIGNAL
  59 +
  60 +/* Define to 1 if you have the <signal.h> header file. */
  61 +#undef HAVE_SIGNAL_H
  62 +
  63  /* Define to 1 if you have the `socket' function. */
  64  #undef HAVE_SOCKET
  65  
  66 @@ -113,6 +121,12 @@
  67  /* Define to 1 if you have the <sys/types.h> header file. */
  68  #undef HAVE_SYS_TYPES_H
  69  
  70 +/* Define to 1 if you have the `tcgetattr' function. */
  71 +#undef HAVE_TCGETATTR
  72 +
  73 +/* Define to 1 if you have the `tcsetattr' function. */
  74 +#undef HAVE_TCSETATTR
  75 +
  76  /* Define to 1 if you have the <termios.h> header file. */
  77  #undef HAVE_TERMIOS_H
  78  
  79 @@ -122,6 +136,9 @@
  80  /* Define to 1 if you have the `vprintf' function. */
  81  #undef HAVE_VPRINTF
  82  
  83 +/* Define to 1 if you have the <windows.h> header file. */
  84 +#undef HAVE_WINDOWS_H
  85 +
  86  /* Define to 1 if you have the <zlib.h> header file. */
  87  #undef HAVE_ZLIB_H
  88  
  89 @@ -167,6 +184,3 @@
  90  
  91  /* Define to rpl_malloc if the replacement function should be used. */
  92  #undef malloc
  93 -
  94 -/* Define to rpl_realloc if the replacement function should be used. */
  95 -#undef realloc
  96 diff -uNr libssh-0.11-orig/configure libssh-0.11-rsk/configure
  97 --- libssh-0.11-orig/configure  2005-03-04 13:54:59.000000000 -0600
  98 +++ libssh-0.11-rsk/configure   2005-06-24 10:50:26.000000000 -0500
  99 @@ -1,6 +1,6 @@
 100  #! /bin/sh
 101  # Guess values for system-dependent variables and create Makefiles.
 102 -# Generated by GNU Autoconf 2.59 for libssh 0.11-dev .
 103 +# Generated by GNU Autoconf 2.59 for libssh 0.11 .
 104  #
 105  # Report bugs to <aris@0xbadc0de.be>.
 106  #
 107 @@ -269,8 +269,8 @@
 108  # Identity of this package.
 109  PACKAGE_NAME='libssh'
 110  PACKAGE_TARNAME='libssh'
 111 -PACKAGE_VERSION='0.11-dev '
 112 -PACKAGE_STRING='libssh 0.11-dev '
 113 +PACKAGE_VERSION='0.11 '
 114 +PACKAGE_STRING='libssh 0.11 '
 115  PACKAGE_BUGREPORT='aris@0xbadc0de.be'
 116  
 117  ac_unique_file="sample.c"
 118 @@ -780,7 +780,7 @@
 119    # Omit some internal or obsolete options to make the list less imposing.
 120    # This message is too long to be a string in the A/UX 3.1 sh.
 121    cat <<_ACEOF
 122 -\`configure' configures libssh 0.11-dev  to adapt to many kinds of systems.
 123 +\`configure' configures libssh 0.11  to adapt to many kinds of systems.
 124  
 125  Usage: $0 [OPTION]... [VAR=VALUE]...
 126  
 127 @@ -841,7 +841,7 @@
 128  
 129  if test -n "$ac_init_help"; then
 130    case $ac_init_help in
 131 -     short | recursive ) echo "Configuration of libssh 0.11-dev :";;
 132 +     short | recursive ) echo "Configuration of libssh 0.11 :";;
 133     esac
 134    cat <<\_ACEOF
 135  
 136 @@ -953,7 +953,7 @@
 137  test -n "$ac_init_help" && exit 0
 138  if $ac_init_version; then
 139    cat <<\_ACEOF
 140 -libssh configure 0.11-dev
 141 +libssh configure 0.11
 142  generated by GNU Autoconf 2.59
 143  
 144  Copyright (C) 2003 Free Software Foundation, Inc.
 145 @@ -967,7 +967,7 @@
 146  This file contains any messages produced by compilers while
 147  running configure, to aid debugging if configure makes a mistake.
 148  
 149 -It was created by libssh $as_me 0.11-dev , which was
 150 +It was created by libssh $as_me 0.11 , which was
 151  generated by GNU Autoconf 2.59.  Invocation command line was
 152  
 153    $ $0 $@
 154 @@ -1392,6 +1392,11 @@
 155     DYLIB_EXTENSION="dylib"
 156     LIBSSH_LDFLAGS="-dynamiclib -prebind -seg1addr 0x3a000000 -install_name \"${libdir}/libssh.dylib\"
	-headerpad_max_install_names -current_version 0.1"
 157     ;;
 158 +   *-mingw32msvc*)
 159 +   DYLIB_EXTENSION="dll"
 160 +   LIBSSH_LDFLAGS="-shared"
 161 +   LIBS="$LIBS -lwsock32 -lgdi32"
 162 +   ;;
 163     *)
 164     DYLIB_EXTENSION="so"
 165     LIBSSH_LDFLAGS="-shared"
 166 @@ -2911,14 +2916,13 @@
 167  
 168  fi
 169  
 170 -
 171 -echo "$as_me:$LINENO: checking for gethostbyname in -lresolv" >&5
 172 -echo $ECHO_N "checking for gethostbyname in -lresolv... $ECHO_C" >&6
 173 -if test "${ac_cv_lib_resolv_gethostbyname+set}" = set; then
 174 +echo "$as_me:$LINENO: checking for library containing inet_ntoa" >&5
 175 +echo $ECHO_N "checking for library containing inet_ntoa... $ECHO_C" >&6
 176 +if test "${ac_cv_search_inet_ntoa+set}" = set; then
 177    echo $ECHO_N "(cached) $ECHO_C" >&6
 178  else
 179 -  ac_check_lib_save_LIBS=$LIBS
 180 -LIBS="-lresolv  $LIBS"
 181 +  ac_func_search_save_LIBS=$LIBS
 182 +ac_cv_search_inet_ntoa=no
 183  cat >conftest.$ac_ext <<_ACEOF
 184  /* confdefs.h.  */
 185  _ACEOF
 186 @@ -2932,11 +2936,11 @@
 187  #endif
 188  /* We use char because int might match the return type of a gcc2
 189     builtin and then its argument prototype would still apply.  */
 190 -char gethostbyname ();
 191 +char inet_ntoa ();
 192  int
 193  main ()
 194  {
 195 -gethostbyname ();
 196 +inet_ntoa ();
 197    ;
 198    return 0;
 199  }
 200 @@ -2963,36 +2967,91 @@
 201    ac_status=$?
 202    echo "$as_me:$LINENO: \$? = $ac_status" >&5
 203    (exit $ac_status); }; }; then
 204 -  ac_cv_lib_resolv_gethostbyname=yes
 205 +  ac_cv_search_inet_ntoa="none required"
 206  else
 207    echo "$as_me: failed program was:" >&5
 208  sed 's/^/| /' conftest.$ac_ext >&5
 209  
 210 -ac_cv_lib_resolv_gethostbyname=no
 211  fi
 212  rm -f conftest.err conftest.$ac_objext \
 213        conftest$ac_exeext conftest.$ac_ext
 214 -LIBS=$ac_check_lib_save_LIBS
 215 -fi
 216 -echo "$as_me:$LINENO: result: $ac_cv_lib_resolv_gethostbyname" >&5
 217 -echo "${ECHO_T}$ac_cv_lib_resolv_gethostbyname" >&6
 218 -if test $ac_cv_lib_resolv_gethostbyname = yes; then
 219 -  cat >>confdefs.h <<_ACEOF
 220 -#define HAVE_LIBRESOLV 1
 221 +if test "$ac_cv_search_inet_ntoa" = no; then
 222 +  for ac_lib in socket resolv nsl ws2_32 wsock32; do
 223 +    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
 224 +    cat >conftest.$ac_ext <<_ACEOF
 225 +/* confdefs.h.  */
 226  _ACEOF
 227 +cat confdefs.h >>conftest.$ac_ext
 228 +cat >>conftest.$ac_ext <<_ACEOF
 229 +/* end confdefs.h.  */
 230  
 231 -  LIBS="-lresolv $LIBS"
 232 +/* Override any gcc2 internal prototype to avoid an error.  */
 233 +#ifdef __cplusplus
 234 +extern "C"
 235 +#endif
 236 +/* We use char because int might match the return type of a gcc2
 237 +   builtin and then its argument prototype would still apply.  */
 238 +char inet_ntoa ();
 239 +int
 240 +main ()
 241 +{
 242 +inet_ntoa ();
 243 +  ;
 244 +  return 0;
 245 +}
 246 +_ACEOF
 247 +rm -f conftest.$ac_objext conftest$ac_exeext
 248 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
 249 +  (eval $ac_link) 2>conftest.er1
 250 +  ac_status=$?
 251 +  grep -v '^ *+' conftest.er1 >conftest.err
 252 +  rm -f conftest.er1
 253 +  cat conftest.err >&5
 254 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 255 +  (exit $ac_status); } &&
 256 +    { ac_try='test -z "$ac_c_werror_flag"
 257 +            || test ! -s conftest.err'
 258 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
 259 +  (eval $ac_try) 2>&5
 260 +  ac_status=$?
 261 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 262 +  (exit $ac_status); }; } &&
 263 +    { ac_try='test -s conftest$ac_exeext'
 264 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
 265 +  (eval $ac_try) 2>&5
 266 +  ac_status=$?
 267 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 268 +  (exit $ac_status); }; }; then
 269 +  ac_cv_search_inet_ntoa="-l$ac_lib"
 270 +break
 271 +else
 272 +  echo "$as_me: failed program was:" >&5
 273 +sed 's/^/| /' conftest.$ac_ext >&5
 274  
 275  fi
 276 +rm -f conftest.err conftest.$ac_objext \
 277 +      conftest$ac_exeext conftest.$ac_ext
 278 +  done
 279 +fi
 280 +LIBS=$ac_func_search_save_LIBS
 281 +fi
 282 +echo "$as_me:$LINENO: result: $ac_cv_search_inet_ntoa" >&5
 283 +echo "${ECHO_T}$ac_cv_search_inet_ntoa" >&6
 284 +if test "$ac_cv_search_inet_ntoa" != no; then
 285 +  test "$ac_cv_search_inet_ntoa" = "none required" || LIBS="$ac_cv_search_inet_ntoa $LIBS"
 286  
 287 +else
 288 +   { echo "$as_me:$LINENO: WARNING: Couldn't find inet_ntoa" >&5
 289 +echo "$as_me: WARNING: Couldn't find inet_ntoa" >&2;}
 290 +fi
 291  
 292 -echo "$as_me:$LINENO: checking for gethostbyname in -lnsl" >&5
 293 -echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6
 294 -if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then
 295 +echo "$as_me:$LINENO: checking for library containing gethostbyname" >&5
 296 +echo $ECHO_N "checking for library containing gethostbyname... $ECHO_C" >&6
 297 +if test "${ac_cv_search_gethostbyname+set}" = set; then
 298    echo $ECHO_N "(cached) $ECHO_C" >&6
 299  else
 300 -  ac_check_lib_save_LIBS=$LIBS
 301 -LIBS="-lnsl  $LIBS"
 302 +  ac_func_search_save_LIBS=$LIBS
 303 +ac_cv_search_gethostbyname=no
 304  cat >conftest.$ac_ext <<_ACEOF
 305  /* confdefs.h.  */
 306  _ACEOF
 307 @@ -3037,27 +3096,212 @@
 308    ac_status=$?
 309    echo "$as_me:$LINENO: \$? = $ac_status" >&5
 310    (exit $ac_status); }; }; then
 311 -  ac_cv_lib_nsl_gethostbyname=yes
 312 +  ac_cv_search_gethostbyname="none required"
 313  else
 314    echo "$as_me: failed program was:" >&5
 315  sed 's/^/| /' conftest.$ac_ext >&5
 316  
 317 -ac_cv_lib_nsl_gethostbyname=no
 318  fi
 319  rm -f conftest.err conftest.$ac_objext \
 320        conftest$ac_exeext conftest.$ac_ext
 321 -LIBS=$ac_check_lib_save_LIBS
 322 +if test "$ac_cv_search_gethostbyname" = no; then
 323 +  for ac_lib in socket resolv nsl ws2_32 wsock32; do
 324 +    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
 325 +    cat >conftest.$ac_ext <<_ACEOF
 326 +/* confdefs.h.  */
 327 +_ACEOF
 328 +cat confdefs.h >>conftest.$ac_ext
 329 +cat >>conftest.$ac_ext <<_ACEOF
 330 +/* end confdefs.h.  */
 331 +
 332 +/* Override any gcc2 internal prototype to avoid an error.  */
 333 +#ifdef __cplusplus
 334 +extern "C"
 335 +#endif
 336 +/* We use char because int might match the return type of a gcc2
 337 +   builtin and then its argument prototype would still apply.  */
 338 +char gethostbyname ();
 339 +int
 340 +main ()
 341 +{
 342 +gethostbyname ();
 343 +  ;
 344 +  return 0;
 345 +}
 346 +_ACEOF
 347 +rm -f conftest.$ac_objext conftest$ac_exeext
 348 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
 349 +  (eval $ac_link) 2>conftest.er1
 350 +  ac_status=$?
 351 +  grep -v '^ *+' conftest.er1 >conftest.err
 352 +  rm -f conftest.er1
 353 +  cat conftest.err >&5
 354 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 355 +  (exit $ac_status); } &&
 356 +    { ac_try='test -z "$ac_c_werror_flag"
 357 +            || test ! -s conftest.err'
 358 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
 359 +  (eval $ac_try) 2>&5
 360 +  ac_status=$?
 361 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 362 +  (exit $ac_status); }; } &&
 363 +    { ac_try='test -s conftest$ac_exeext'
 364 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
 365 +  (eval $ac_try) 2>&5
 366 +  ac_status=$?
 367 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 368 +  (exit $ac_status); }; }; then
 369 +  ac_cv_search_gethostbyname="-l$ac_lib"
 370 +break
 371 +else
 372 +  echo "$as_me: failed program was:" >&5
 373 +sed 's/^/| /' conftest.$ac_ext >&5
 374 +
 375  fi
 376 -echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_gethostbyname" >&5
 377 -echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6
 378 -if test $ac_cv_lib_nsl_gethostbyname = yes; then
 379 -  cat >>confdefs.h <<_ACEOF
 380 -#define HAVE_LIBNSL 1
 381 +rm -f conftest.err conftest.$ac_objext \
 382 +      conftest$ac_exeext conftest.$ac_ext
 383 +  done
 384 +fi
 385 +LIBS=$ac_func_search_save_LIBS
 386 +fi
 387 +echo "$as_me:$LINENO: result: $ac_cv_search_gethostbyname" >&5
 388 +echo "${ECHO_T}$ac_cv_search_gethostbyname" >&6
 389 +if test "$ac_cv_search_gethostbyname" != no; then
 390 +  test "$ac_cv_search_gethostbyname" = "none required" || LIBS="$ac_cv_search_gethostbyname $LIBS"
 391 +
 392 +else
 393 +   { echo "$as_me:$LINENO: WARNING: Couldn't find gethostbyname" >&5
 394 +echo "$as_me: WARNING: Couldn't find gethostbyname" >&2;}
 395 +fi
 396 +
 397 +echo "$as_me:$LINENO: checking for library containing gethostbyaddr" >&5
 398 +echo $ECHO_N "checking for library containing gethostbyaddr... $ECHO_C" >&6
 399 +if test "${ac_cv_search_gethostbyaddr+set}" = set; then
 400 +  echo $ECHO_N "(cached) $ECHO_C" >&6
 401 +else
 402 +  ac_func_search_save_LIBS=$LIBS
 403 +ac_cv_search_gethostbyaddr=no
 404 +cat >conftest.$ac_ext <<_ACEOF
 405 +/* confdefs.h.  */
 406  _ACEOF
 407 +cat confdefs.h >>conftest.$ac_ext
 408 +cat >>conftest.$ac_ext <<_ACEOF
 409 +/* end confdefs.h.  */
 410  
 411 -  LIBS="-lnsl $LIBS"
 412 +/* Override any gcc2 internal prototype to avoid an error.  */
 413 +#ifdef __cplusplus
 414 +extern "C"
 415 +#endif
 416 +/* We use char because int might match the return type of a gcc2
 417 +   builtin and then its argument prototype would still apply.  */
 418 +char gethostbyaddr ();
 419 +int
 420 +main ()
 421 +{
 422 +gethostbyaddr ();
 423 +  ;
 424 +  return 0;
 425 +}
 426 +_ACEOF
 427 +rm -f conftest.$ac_objext conftest$ac_exeext
 428 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
 429 +  (eval $ac_link) 2>conftest.er1
 430 +  ac_status=$?
 431 +  grep -v '^ *+' conftest.er1 >conftest.err
 432 +  rm -f conftest.er1
 433 +  cat conftest.err >&5
 434 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 435 +  (exit $ac_status); } &&
 436 +    { ac_try='test -z "$ac_c_werror_flag"
 437 +            || test ! -s conftest.err'
 438 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
 439 +  (eval $ac_try) 2>&5
 440 +  ac_status=$?
 441 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 442 +  (exit $ac_status); }; } &&
 443 +    { ac_try='test -s conftest$ac_exeext'
 444 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
 445 +  (eval $ac_try) 2>&5
 446 +  ac_status=$?
 447 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 448 +  (exit $ac_status); }; }; then
 449 +  ac_cv_search_gethostbyaddr="none required"
 450 +else
 451 +  echo "$as_me: failed program was:" >&5
 452 +sed 's/^/| /' conftest.$ac_ext >&5
 453  
 454  fi
 455 +rm -f conftest.err conftest.$ac_objext \
 456 +      conftest$ac_exeext conftest.$ac_ext
 457 +if test "$ac_cv_search_gethostbyaddr" = no; then
 458 +  for ac_lib in socket resolv nsl ws2_32 wsock32; do
 459 +    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
 460 +    cat >conftest.$ac_ext <<_ACEOF
 461 +/* confdefs.h.  */
 462 +_ACEOF
 463 +cat confdefs.h >>conftest.$ac_ext
 464 +cat >>conftest.$ac_ext <<_ACEOF
 465 +/* end confdefs.h.  */
 466 +
 467 +/* Override any gcc2 internal prototype to avoid an error.  */
 468 +#ifdef __cplusplus
 469 +extern "C"
 470 +#endif
 471 +/* We use char because int might match the return type of a gcc2
 472 +   builtin and then its argument prototype would still apply.  */
 473 +char gethostbyaddr ();
 474 +int
 475 +main ()
 476 +{
 477 +gethostbyaddr ();
 478 +  ;
 479 +  return 0;
 480 +}
 481 +_ACEOF
 482 +rm -f conftest.$ac_objext conftest$ac_exeext
 483 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
 484 +  (eval $ac_link) 2>conftest.er1
 485 +  ac_status=$?
 486 +  grep -v '^ *+' conftest.er1 >conftest.err
 487 +  rm -f conftest.er1
 488 +  cat conftest.err >&5
 489 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 490 +  (exit $ac_status); } &&
 491 +    { ac_try='test -z "$ac_c_werror_flag"
 492 +            || test ! -s conftest.err'
 493 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
 494 +  (eval $ac_try) 2>&5
 495 +  ac_status=$?
 496 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 497 +  (exit $ac_status); }; } &&
 498 +    { ac_try='test -s conftest$ac_exeext'
 499 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
 500 +  (eval $ac_try) 2>&5
 501 +  ac_status=$?
 502 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 503 +  (exit $ac_status); }; }; then
 504 +  ac_cv_search_gethostbyaddr="-l$ac_lib"
 505 +break
 506 +else
 507 +  echo "$as_me: failed program was:" >&5
 508 +sed 's/^/| /' conftest.$ac_ext >&5
 509 +
 510 +fi
 511 +rm -f conftest.err conftest.$ac_objext \
 512 +      conftest$ac_exeext conftest.$ac_ext
 513 +  done
 514 +fi
 515 +LIBS=$ac_func_search_save_LIBS
 516 +fi
 517 +echo "$as_me:$LINENO: result: $ac_cv_search_gethostbyaddr" >&5
 518 +echo "${ECHO_T}$ac_cv_search_gethostbyaddr" >&6
 519 +if test "$ac_cv_search_gethostbyaddr" != no; then
 520 +  test "$ac_cv_search_gethostbyaddr" = "none required" || LIBS="$ac_cv_search_gethostbyaddr $LIBS"
 521 +
 522 +else
 523 +   { echo "$as_me:$LINENO: WARNING: Couldn't find gethostbyaddr" >&5
 524 +echo "$as_me: WARNING: Couldn't find gethostbyaddr" >&2;}
 525 +fi
 526  
 527  
 528  # Checks for header files.
 529 @@ -3562,9 +3806,18 @@
 530  
 531  
 532  
 533 +
 534 +
 535 +
 536 +
 537 +
 538 +
 539 +
 540 +
 541  for ac_header in fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h \
 542  sys/time.h termios.h unistd.h openssl/aes.h openssl/blowfish.h zlib.h \
 543 -sys/poll.h
 544 +sys/poll.h sys/select.h netdb.h windows.h pty.h pwd.h signal.h inttypes.h \
 545 +stdint.h
 546  do
 547  as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 548  if eval "test \"\${$as_ac_Header+set}\" = set"; then
 549 @@ -4202,237 +4455,6 @@
 550  
 551  
 552  
 553 -for ac_header in stdlib.h
 554 -do
 555 -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 556 -if eval "test \"\${$as_ac_Header+set}\" = set"; then
 557 -  echo "$as_me:$LINENO: checking for $ac_header" >&5
 558 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 559 -if eval "test \"\${$as_ac_Header+set}\" = set"; then
 560 -  echo $ECHO_N "(cached) $ECHO_C" >&6
 561 -fi
 562 -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
 563 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
 564 -else
 565 -  # Is the header compilable?
 566 -echo "$as_me:$LINENO: checking $ac_header usability" >&5
 567 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
 568 -cat >conftest.$ac_ext <<_ACEOF
 569 -/* confdefs.h.  */
 570 -_ACEOF
 571 -cat confdefs.h >>conftest.$ac_ext
 572 -cat >>conftest.$ac_ext <<_ACEOF
 573 -/* end confdefs.h.  */
 574 -$ac_includes_default
 575 -#include <$ac_header>
 576 -_ACEOF
 577 -rm -f conftest.$ac_objext
 578 -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
 579 -  (eval $ac_compile) 2>conftest.er1
 580 -  ac_status=$?
 581 -  grep -v '^ *+' conftest.er1 >conftest.err
 582 -  rm -f conftest.er1
 583 -  cat conftest.err >&5
 584 -  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 585 -  (exit $ac_status); } &&
 586 -    { ac_try='test -z "$ac_c_werror_flag"
 587 -            || test ! -s conftest.err'
 588 -  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
 589 -  (eval $ac_try) 2>&5
 590 -  ac_status=$?
 591 -  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 592 -  (exit $ac_status); }; } &&
 593 -    { ac_try='test -s conftest.$ac_objext'
 594 -  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
 595 -  (eval $ac_try) 2>&5
 596 -  ac_status=$?
 597 -  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 598 -  (exit $ac_status); }; }; then
 599 -  ac_header_compiler=yes
 600 -else
 601 -  echo "$as_me: failed program was:" >&5
 602 -sed 's/^/| /' conftest.$ac_ext >&5
 603 -
 604 -ac_header_compiler=no
 605 -fi
 606 -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 607 -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
 608 -echo "${ECHO_T}$ac_header_compiler" >&6
 609 -
 610 -# Is the header present?
 611 -echo "$as_me:$LINENO: checking $ac_header presence" >&5
 612 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
 613 -cat >conftest.$ac_ext <<_ACEOF
 614 -/* confdefs.h.  */
 615 -_ACEOF
 616 -cat confdefs.h >>conftest.$ac_ext
 617 -cat >>conftest.$ac_ext <<_ACEOF
 618 -/* end confdefs.h.  */
 619 -#include <$ac_header>
 620 -_ACEOF
 621 -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
 622 -  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
 623 -  ac_status=$?
 624 -  grep -v '^ *+' conftest.er1 >conftest.err
 625 -  rm -f conftest.er1
 626 -  cat conftest.err >&5
 627 -  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 628 -  (exit $ac_status); } >/dev/null; then
 629 -  if test -s conftest.err; then
 630 -    ac_cpp_err=$ac_c_preproc_warn_flag
 631 -    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
 632 -  else
 633 -    ac_cpp_err=
 634 -  fi
 635 -else
 636 -  ac_cpp_err=yes
 637 -fi
 638 -if test -z "$ac_cpp_err"; then
 639 -  ac_header_preproc=yes
 640 -else
 641 -  echo "$as_me: failed program was:" >&5
 642 -sed 's/^/| /' conftest.$ac_ext >&5
 643 -
 644 -  ac_header_preproc=no
 645 -fi
 646 -rm -f conftest.err conftest.$ac_ext
 647 -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
 648 -echo "${ECHO_T}$ac_header_preproc" >&6
 649 -
 650 -# So?  What about this header?
 651 -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
 652 -  yes:no: )
 653 -    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
 654 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
 655 -    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
 656 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
 657 -    ac_header_preproc=yes
 658 -    ;;
 659 -  no:yes:* )
 660 -    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
 661 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
 662 -    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
 663 -echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
 664 -    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
 665 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
 666 -    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
 667 -echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
 668 -    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
 669 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
 670 -    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
 671 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
 672 -    (
 673 -      cat <<\_ASBOX
 674 -## -------------------------------- ##
 675 -## Report this to aris@0xbadc0de.be ##
 676 -## -------------------------------- ##
 677 -_ASBOX
 678 -    ) |
 679 -      sed "s/^/$as_me: WARNING:     /" >&2
 680 -    ;;
 681 -esac
 682 -echo "$as_me:$LINENO: checking for $ac_header" >&5
 683 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 684 -if eval "test \"\${$as_ac_Header+set}\" = set"; then
 685 -  echo $ECHO_N "(cached) $ECHO_C" >&6
 686 -else
 687 -  eval "$as_ac_Header=\$ac_header_preproc"
 688 -fi
 689 -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
 690 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
 691 -
 692 -fi
 693 -if test `eval echo '${'$as_ac_Header'}'` = yes; then
 694 -  cat >>confdefs.h <<_ACEOF
 695 -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
 696 -_ACEOF
 697 -
 698 -fi
 699 -
 700 -done
 701 -
 702 -echo "$as_me:$LINENO: checking for GNU libc compatible realloc" >&5
 703 -echo $ECHO_N "checking for GNU libc compatible realloc... $ECHO_C" >&6
 704 -if test "${ac_cv_func_realloc_0_nonnull+set}" = set; then
 705 -  echo $ECHO_N "(cached) $ECHO_C" >&6
 706 -else
 707 -  if test "$cross_compiling" = yes; then
 708 -  ac_cv_func_realloc_0_nonnull=no
 709 -else
 710 -  cat >conftest.$ac_ext <<_ACEOF
 711 -/* confdefs.h.  */
 712 -_ACEOF
 713 -cat confdefs.h >>conftest.$ac_ext
 714 -cat >>conftest.$ac_ext <<_ACEOF
 715 -/* end confdefs.h.  */
 716 -#if STDC_HEADERS || HAVE_STDLIB_H
 717 -# include <stdlib.h>
 718 -#else
 719 -char *realloc ();
 720 -#endif
 721 -
 722 -int
 723 -main ()
 724 -{
 725 -exit (realloc (0, 0) ? 0 : 1);
 726 -  ;
 727 -  return 0;
 728 -}
 729 -_ACEOF
 730 -rm -f conftest$ac_exeext
 731 -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
 732 -  (eval $ac_link) 2>&5
 733 -  ac_status=$?
 734 -  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 735 -  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
 736 -  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
 737 -  (eval $ac_try) 2>&5
 738 -  ac_status=$?
 739 -  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 740 -  (exit $ac_status); }; }; then
 741 -  ac_cv_func_realloc_0_nonnull=yes
 742 -else
 743 -  echo "$as_me: program exited with status $ac_status" >&5
 744 -echo "$as_me: failed program was:" >&5
 745 -sed 's/^/| /' conftest.$ac_ext >&5
 746 -
 747 -( exit $ac_status )
 748 -ac_cv_func_realloc_0_nonnull=no
 749 -fi
 750 -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 751 -fi
 752 -fi
 753 -echo "$as_me:$LINENO: result: $ac_cv_func_realloc_0_nonnull" >&5
 754 -echo "${ECHO_T}$ac_cv_func_realloc_0_nonnull" >&6
 755 -if test $ac_cv_func_realloc_0_nonnull = yes; then
 756 -
 757 -cat >>confdefs.h <<\_ACEOF
 758 -#define HAVE_REALLOC 1
 759 -_ACEOF
 760 -
 761 -else
 762 -  cat >>confdefs.h <<\_ACEOF
 763 -#define HAVE_REALLOC 0
 764 -_ACEOF
 765 -
 766 -   case $LIBOBJS in
 767 -    "realloc.$ac_objext"   | \
 768 -  *" realloc.$ac_objext"   | \
 769 -    "realloc.$ac_objext "* | \
 770 -  *" realloc.$ac_objext "* ) ;;
 771 -  *) LIBOBJS="$LIBOBJS realloc.$ac_objext" ;;
 772 -esac
 773 -
 774 -
 775 -cat >>confdefs.h <<\_ACEOF
 776 -#define realloc rpl_realloc
 777 -_ACEOF
 778 -
 779 -fi
 780 -
 781 -
 782 -
 783 -
 784  
 785  for ac_header in sys/select.h sys/socket.h
 786  do
 787 @@ -4957,8 +4979,14 @@
 788  
 789  
 790  
 791 -for ac_func in endpwent gethostbyaddr gethostbyname getpass memmove memset \
 792 - select socket strchr strdup strerror strstr poll
 793 +
 794 +
 795 +
 796 +
 797 +
 798 +for ac_func in endpwent getpass memmove memset gethostbyname gethostbyaddr \
 799 + select socket strchr strdup strerror strstr poll getpwent getuid \
 800 +signal tcgetattr tcsetattr
 801  do
 802  as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 803  echo "$as_me:$LINENO: checking for $ac_func" >&5
 804 @@ -5424,7 +5452,7 @@
 805  } >&5
 806  cat >&5 <<_CSEOF
 807  
 808 -This file was extended by libssh $as_me 0.11-dev , which was
 809 +This file was extended by libssh $as_me 0.11 , which was
 810  generated by GNU Autoconf 2.59.  Invocation command line was
 811  
 812    CONFIG_FILES    = $CONFIG_FILES
 813 @@ -5484,7 +5512,7 @@
 814  
 815  cat >>$CONFIG_STATUS <<_ACEOF
 816  ac_cs_version="\\
 817 -libssh config.status 0.11-dev
 818 +libssh config.status 0.11
 819  configured by $0, generated by GNU Autoconf 2.59,
 820    with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 821  
 822 diff -uNr libssh-0.11-orig/configure.in libssh-0.11-rsk/configure.in
 823 --- libssh-0.11-orig/configure.in   2005-03-04 13:54:59.000000000 -0600
 824 +++ libssh-0.11-rsk/configure.in    2005-06-24 10:51:36.000000000 -0500
 825 @@ -13,6 +13,11 @@
 826     DYLIB_EXTENSION="dylib"
 827     LIBSSH_LDFLAGS="-dynamiclib -prebind -seg1addr 0x3a000000 -install_name \"${libdir}/libssh.dylib\"
	-headerpad_max_install_names -current_version 0.1"
 828     ;;
 829 +   *-mingw32msvc*)
 830 +   DYLIB_EXTENSION="dll"
 831 +   LIBSSH_LDFLAGS="-shared"
 832 +   LIBS="$LIBS -lwsock32 -lgdi32"
 833 +   ;;
 834     *)
 835     DYLIB_EXTENSION="so"
 836     LIBSSH_LDFLAGS="-shared"
 837 @@ -32,14 +37,16 @@
 838  # Checks for libraries.
 839  AC_CHECK_LIB([crypto], [BN_init])
 840  AC_CHECK_LIB([z], [deflateInit_])
 841 -AC_CHECK_LIB([resolv],[gethostbyname])
 842 -AC_CHECK_LIB([nsl],[gethostbyname])
 843 +AC_SEARCH_LIBS(inet_ntoa, socket resolv nsl ws2_32 wsock32,, [ AC_MSG_WARN([Couldn't find inet_ntoa]) ])
 844 +AC_SEARCH_LIBS(gethostbyname, socket resolv nsl ws2_32 wsock32,, [ AC_MSG_WARN([Couldn't find gethostbyname]) ])
 845 +AC_SEARCH_LIBS(gethostbyaddr, socket resolv nsl ws2_32 wsock32,, [ AC_MSG_WARN([Couldn't find gethostbyaddr]) ])
 846  
 847  # Checks for header files.
 848  AC_HEADER_STDC
 849  AC_CHECK_HEADERS([fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h \
 850  sys/time.h termios.h unistd.h openssl/aes.h openssl/blowfish.h zlib.h \
 851 -sys/poll.h ])
 852 +sys/poll.h sys/select.h netdb.h windows.h pty.h pwd.h signal.h inttypes.h \
 853 +stdint.h sys/types.h])
 854  
 855  # Checks for typedefs, structures, and compiler characteristics.
 856  AC_C_CONST
 857 @@ -48,12 +55,12 @@
 858  # Checks for library functions.
 859  AC_FUNC_MALLOC
 860  AC_FUNC_MEMCMP
 861 -AC_FUNC_REALLOC
 862  AC_FUNC_SELECT_ARGTYPES
 863  AC_TYPE_SIGNAL
 864  AC_FUNC_VPRINTF
 865 -AC_CHECK_FUNCS([endpwent gethostbyaddr gethostbyname getpass memmove memset \
 866 - select socket strchr strdup strerror strstr poll])
 867 +AC_CHECK_FUNCS([endpwent getpass memmove memset gethostbyname gethostbyaddr \
 868 + select socket strchr strdup strerror strstr poll getpwent getuid \
 869 +signal tcgetattr tcsetattr])
 870  
 871  AC_CONFIG_FILES([Makefile
 872                   libssh/Makefile])
 873 diff -uNr libssh-0.11-orig/include/libssh/libssh.h libssh-0.11-rsk/include/libssh/libssh.h
 874 --- libssh-0.11-orig/include/libssh/libssh.h    2005-03-04 13:54:59.000000000 -0600
 875 +++ libssh-0.11-rsk/include/libssh/libssh.h 2005-06-24 11:23:19.000000000 -0500
 876 @@ -22,7 +22,18 @@
 877  #define _LIBSSH_H
 878  #include <libssh/config.h>
 879  #include <unistd.h>
 880 +#ifdef HAVE_SYS_SELECT_H
 881  #include <sys/select.h> /* for fd_set * */
 882 +#endif
 883 +#ifdef HAVE_WINDOWS_H
 884 +#include <windows.h>
 885 +#endif
 886 +#ifdef HAVE_INTTYPES_H
 887 +#include <inttypes.h>
 888 +#endif
 889 +#ifdef HAVE_STDINT_H
 890 +#include <stdint.h>
 891 +#endif
 892  #include <sys/types.h>
 893  #define LIBSSH_VERSION "libssh-0.11"
 894  
 895 @@ -40,10 +51,10 @@
 896  typedef struct ssh_kbdint SSH_KBDINT;
 897  
 898  /* integer values */
 899 -typedef u_int32_t u32;
 900 -typedef u_int16_t u16;
 901 -typedef u_int64_t u64;
 902 -typedef u_int8_t u8;
 903 +typedef uint32_t u32;
 904 +typedef uint16_t u16;
 905 +typedef uint64_t u64;
 906 +typedef uint8_t u8;
 907  
 908  /* the offsets of methods */
 909  #define KEX_ALGO 0
 910 @@ -95,6 +106,9 @@
 911  char *ssh_get_issue_banner(SSH_SESSION *session);
 912  /* get copyright informations */
 913  const char *ssh_copyright();
 914 +char *ssh_get_banner(SSH_SESSION *session);
 915 +void ssh_send_banner(SSH_SESSION *session);
 916 +
 917  /* string.h */
 918  
 919  /* You can use these functions, they won't change */
 920 diff -uNr libssh-0.11-orig/include/libssh/priv.h libssh-0.11-rsk/include/libssh/priv.h
 921 --- libssh-0.11-orig/include/libssh/priv.h  2005-03-04 13:54:59.000000000 -0600
 922 +++ libssh-0.11-rsk/include/libssh/priv.h   2005-06-24 10:48:01.000000000 -0500
 923 @@ -27,6 +27,30 @@
 924  #define _LIBSSH_PRIV_H
 925  #include "libssh/libssh.h"
 926  
 927 +#ifdef HAVE_CONFIG_H
 928 +#include "libssh/config.h"
 929 +#endif
 930 +
 931 +#ifdef HAVE_WINDOWS_H
 932 +#include <windows.h>
 933 +#define HAVE_SELECT 1
 934 +#define HAVE_GETHOSTBYADDR 1
 935 +#define HAVE_GETHOSTBYNAME 1
 936 +#define HAVE_INET_ADDR 1
 937 +#undef HAVE_INET_ATON
 938 +#undef HAVE_SIGNAL
 939 +#endif
 940 +
 941 +#ifdef HAVE_UNISTD_H
 942 +#include <unistd.h>
 943 +#endif
 944 +
 945 +#ifdef HAVE_MALLOC
 946 +#if HAVE_MALLOC == 0
 947 +void *rpl_malloc(size_t n);
 948 +#endif
 949 +#endif
 950 +
 951  /* Debugging constants */
 952  
 953  /* Define this if you want to debug crypto systems */
 954 @@ -297,6 +321,7 @@
 955  /* connect.c */
 956  SSH_SESSION *ssh_session_new();
 957  int ssh_connect_host(const char *host,const char *bind_addr, int port, long timeout, long usec);
 958 +int ssh_net_init(void);
 959  
 960  /* in kex.c */
 961  extern char *ssh_kex_nums[];
 962 diff -uNr libssh-0.11-orig/include/libssh/server.h libssh-0.11-rsk/include/libssh/server.h
 963 --- libssh-0.11-orig/include/libssh/server.h    2005-03-04 13:54:59.000000000 -0600
 964 +++ libssh-0.11-rsk/include/libssh/server.h 2005-06-23 23:38:49.000000000 -0500
 965 @@ -27,5 +27,7 @@
 966  int bind_socket();
 967  int listen_socket(int s);
 968  int accept_socket(int s);
 969 +SSH_SESSION *getserver(SSH_OPTIONS * options);
 970 +int server_set_kex(SSH_SESSION * session);
 971  
 972  #endif
 973 diff -uNr libssh-0.11-orig/libssh/Makefile.in libssh-0.11-rsk/libssh/Makefile.in
 974 --- libssh-0.11-orig/libssh/Makefile.in 2005-03-04 13:54:59.000000000 -0600
 975 +++ libssh-0.11-rsk/libssh/Makefile.in  2005-06-23 17:00:35.000000000 -0500
 976 @@ -1,7 +1,7 @@
 977  
 978  OBJECTS= client.o packet.o dh.o crypt.o connect.o error.o buffer.o \
 979     string.o kex.o channels.o options.o keys.o auth.o base64.o \
 980 -        keyfiles.o misc.o gzip.o wrapper.o sftp.o server.o
 981 +        keyfiles.o misc.o gzip.o wrapper.o sftp.o server.o malloc.o
 982  SHELL = /bin/sh
 983  VPATH = @srcdir@
 984  
 985 diff -uNr libssh-0.11-orig/libssh/auth.c libssh-0.11-rsk/libssh/auth.c
 986 --- libssh-0.11-orig/libssh/auth.c  2005-03-04 13:54:59.000000000 -0600
 987 +++ libssh-0.11-rsk/libssh/auth.c   2005-06-23 16:45:08.000000000 -0500
 988 @@ -22,7 +22,9 @@
 989  #include "libssh/priv.h"
 990  #include "libssh/ssh2.h"
 991  #include <string.h>
 992 +#ifdef HAVE_NETDB_H
 993  #include <netdb.h>
 994 +#endif
 995  
 996  static int ask_userauth(SSH_SESSION *session){
 997      if(session->auth_service_asked)
 998 diff -uNr libssh-0.11-orig/libssh/buffer.c libssh-0.11-rsk/libssh/buffer.c
 999 --- libssh-0.11-orig/libssh/buffer.c    2005-03-04 13:54:59.000000000 -0600
1000 +++ libssh-0.11-rsk/libssh/buffer.c 2005-06-23 16:42:30.000000000 -0500
1001 @@ -20,10 +20,12 @@
1002  the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
1003  MA 02111-1307, USA. */
1004  
1005 +#include "libssh/priv.h"
1006  #include <stdlib.h>
1007  #include <string.h>
1008 +#ifdef HAVE_NETDB_H
1009  #include <netdb.h>
1010 -#include "libssh/priv.h"
1011 +#endif
1012  BUFFER *buffer_new(){
1013      BUFFER *buffer=malloc(sizeof(BUFFER));
1014      memset(buffer,0,sizeof(BUFFER));
1015 diff -uNr libssh-0.11-orig/libssh/channels.c libssh-0.11-rsk/libssh/channels.c
1016 --- libssh-0.11-orig/libssh/channels.c  2005-03-04 13:54:59.000000000 -0600
1017 +++ libssh-0.11-rsk/libssh/channels.c   2005-06-23 19:08:00.000000000 -0500
1018 @@ -20,13 +20,15 @@
1019  the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
1020  MA 02111-1307, USA. */
1021  
1022 +#include "libssh/priv.h"
1023  #include <string.h>
1024  #include <stdlib.h>
1025 +#ifdef HAVE_NETDB_H
1026  #include <netdb.h>
1027 +#endif
1028  #include <unistd.h>
1029  #include <stdio.h>
1030  
1031 -#include "libssh/priv.h"
1032  #include "libssh/ssh2.h"
1033  #define WINDOWLIMIT 1024
1034  #define WINDOWBASE 32000
1035 @@ -652,12 +654,17 @@
1036  /* returns the number of bytes available, 0 if nothing is currently available, -1 if error */
1037  int channel_poll(CHANNEL *channel, int is_stderr){
1038      BUFFER *buffer;
1039 +
1040 +    if (!channel) {
1041 +        return(-1);
1042 +    }
1043 +
1044      if(is_stderr){
1045          buffer=channel->stderr_buffer;
1046          if(!buffer)
1047              buffer=channel->stderr_buffer=buffer_new();
1048      } else {
1049 -        buffer=channel->stdout_buffer;
1050 +        buffer = channel->stdout_buffer;
1051          if(!buffer)
1052              buffer=channel->stdout_buffer=buffer_new();
1053      }
1054 diff -uNr libssh-0.11-orig/libssh/client.c libssh-0.11-rsk/libssh/client.c
1055 --- libssh-0.11-orig/libssh/client.c    2005-03-04 13:54:59.000000000 -0600
1056 +++ libssh-0.11-rsk/libssh/client.c 2005-06-24 11:19:06.000000000 -0500
1057 @@ -19,12 +19,23 @@
1058  the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
1059  MA 02111-1307, USA. */
1060  
1061 +#include "libssh/priv.h"
1062  #include <stdio.h>
1063  #include <unistd.h>
1064  #include <stdlib.h>
1065  #include <string.h>
1066 +#ifdef HAVE_NETDB_H
1067  #include <netdb.h>
1068 -#include "libssh/priv.h"
1069 +#endif
1070 +#ifdef HAVE_WINDOWS_H
1071 +#include <windows.h>
1072 +#endif
1073 +#ifdef HAVE_SYS_TYPES_H
1074 +#include <sys/types.h>
1075 +#endif
1076 +#ifdef HAVE_SYS_SOCKET_H
1077 +#include <sys/socket.h>
1078 +#endif
1079  #include "libssh/ssh2.h"
1080  static void ssh_cleanup(SSH_SESSION *session);
1081  #define set_status(opt,status) do {\
1082 @@ -32,17 +43,20 @@
1083              opt->connect_status_function(opt->connect_status_arg, status); \
1084      } while (0)
1085  /* simply gets a banner from a socket */
1086 +
1087  char *ssh_get_banner(SSH_SESSION *session){
1088      char buffer[128];
1089      int i = 0;
1090 +    ssize_t read_ret;
1091 +
1092      while (i < 127) {
1093 -        if(read(session->fd, &buffer[i], 1)<=0){
1094 +        if((read_ret = recv(session->fd, &buffer[i], 1, 0))<=0){
1095              ssh_set_error(session,SSH_CONNECTION_LOST,"Remote host closed connection");
1096              return NULL;
1097          }
1098 -        if (buffer[i] == '\r')
1099 +        if (buffer[i] == '\015')
1100              buffer[i] = 0;
1101 -        if (buffer[i] == '\n') {
1102 +        if (buffer[i] == '\012') {
1103              buffer[i] = 0;
1104              return strdup(buffer);
1105          }
1106 @@ -64,7 +78,7 @@
1107          banner=session->options->clientbanner;
1108      session->clientbanner=strdup(banner);
1109      snprintf(buffer,128,"%s\r\n",session->clientbanner);
1110 -    write(session->fd,buffer,strlen(buffer));
1111 +    send(session->fd,buffer,strlen(buffer),0);
1112  }
1113  
1114  
1115 @@ -159,8 +173,10 @@
1116    else
1117        fd=ssh_connect_host(options->host,options->bindaddr,options->port,
1118            options->timeout,options->timeout_usec);    
1119 -  if(fd<0)
1120 +  if(fd<0) {
1121 +      ssh_set_error(NULL,SSH_FATAL,"ssh_connect_host failed");
1122        return NULL;
1123 +  }
1124    set_status(options,0.2);
1125    session=ssh_session_new();
1126    session->fd=fd;
1127 @@ -168,6 +184,7 @@
1128        session->options=options;
1129    if(!(session->serverbanner=ssh_get_banner(session))){
1130        ssh_cleanup(session);
1131 +      ssh_set_error(NULL,SSH_FATAL,"ssh_get_banner failed");
1132        return NULL;
1133    }
1134    set_status(options,0.4);
1135 @@ -176,18 +193,21 @@
1136    set_status(options,0.5);
1137    if(ssh_get_kex(session,0)){
1138        ssh_disconnect(session);
1139 +      ssh_set_error(NULL,SSH_FATAL,"ssh_get_kex failed");
1140        return NULL;
1141    }
1142    set_status(options,0.6);
1143    list_kex(&session->server_kex);
1144    if(set_kex(session)){
1145        ssh_disconnect(session);
1146 +      ssh_set_error(NULL,SSH_FATAL,"set_kex failed");
1147        return NULL;
1148    }
1149    send_kex(session,0);
1150    set_status(options,0.8);
1151    if(dh_handshake(session)){
1152        ssh_disconnect(session);
1153 +      ssh_set_error(NULL,SSH_FATAL,"dh_handshake failed");
1154        return NULL;
1155    }
1156    set_status(options,1.0);
1157 diff -uNr libssh-0.11-orig/libssh/connect.c libssh-0.11-rsk/libssh/connect.c
1158 --- libssh-0.11-orig/libssh/connect.c   2005-03-04 13:54:59.000000000 -0600
1159 +++ libssh-0.11-rsk/libssh/connect.c    2005-06-24 11:19:38.000000000 -0500
1160 @@ -20,33 +20,64 @@
1161  the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
1162  MA 02111-1307, USA. */
1163  
1164 +#include "libssh/priv.h"
1165 +
1166 +#ifdef HAVE_NETDB_H
1167  #include <netdb.h>
1168 +#endif
1169  #include <string.h>
1170  #include <unistd.h>
1171  #include <stdlib.h>
1172  #include <errno.h>
1173  #include <sys/types.h>
1174 +#ifdef HAVE_SYS_SOCKET_H
1175  #include <sys/socket.h>
1176 +#endif
1177 +#ifdef HAVE_SYS_SELECT_H
1178  #include <sys/select.h>
1179 +#endif
1180  #include <sys/time.h>
1181 +#ifdef HAVE_NETINET_IN_H
1182  #include <netinet/in.h>
1183 +#endif
1184  #include <fcntl.h>
1185 -#include "libssh/priv.h"
1186  #ifdef HAVE_SYS_POLL_H
1187  #include <sys/poll.h>
1188  #endif
1189  
1190 -#ifndef HAVE_GETHOSTBYNAME
1191 -#ifndef HAVE_GETHOSTBYADDR
1192 -#error "your system doesn't have gethostbyname nor gethostbyaddr"
1193 -#endif
1194 -#endif
1195  #define FIRST_CHANNEL 42
1196  static void sock_set_nonblocking(int sock) {
1197 +#if defined(F_SETFL) && defined(O_NONBLOCK)
1198      fcntl(sock,F_SETFL,O_NONBLOCK);
1199 +#endif
1200  }
1201  static void sock_set_blocking(int sock){
1202 +#ifdef F_SETFL
1203      fcntl(sock,F_SETFL,0);
1204 +#endif
1205 +}
1206 +
1207 +int ssh_net_init(void) {
1208 +#ifdef __WIN32__
1209 +   static int called = 0;
1210 +   WSADATA wsaData;
1211 +
1212 +   if (called) {
1213 +       return(0);
1214 +   }
1215 +
1216 +   if (WSAStartup(MAKEWORD(2, 0), &wsaData)!=0) {
1217 +    return(-1);
1218 +   }
1219 +   if (wsaData.wVersion!=MAKEWORD(2, 0)) {
1220 +    /* Cleanup Winsock stuff */
1221 +    WSACleanup();
1222 +    return(-1);
1223 +   }
1224 +
1225 +   called = 1;
1226 +#endif
1227 +   return(0);
1228  }
1229  
1230  /* connect_host connects to an IPv4 (or IPv6) host */
1231 @@ -59,26 +90,42 @@
1232      struct hostent *hp=NULL;
1233      static int count=0; /* for reentrencity */
1234      int s;
1235 +
1236 +    ssh_net_init();
1237 +
1238      while(++count>1)
1239          --count;
1240 -#ifdef HAVE_GETHOSTBYADDR
1241 -    hp=gethostbyaddr(host,4,AF_INET);
1242 +
1243 +
1244 +    sa.sin_family = AF_INET;
1245 +
1246 +#ifdef HAVE_INET_ATON
1247 +   if (!inet_aton(host,&sa.sin_addr)) {
1248 +#else
1249 +#ifdef HAVE_INET_ADDR
1250 +   if ( (sa.sin_addr.s_addr=inet_addr(host) )==-1) {
1251 +#else
1252 +   {
1253  #endif
1254 -#ifdef HAVE_GETHOSTBYNAME
1255 -    if(!hp)
1256 -        hp=gethostbyname(host);
1257  #endif
1258 -    if(!hp){
1259 -        --count;
1260 -        ssh_set_error(NULL,SSH_FATAL,"Failed to resolve hostname %s (%s)",host,hstrerror(h_errno));
1261 -        return -1;
1262 +       hp = gethostbyname(host);
1263 +
1264 +       if(!hp) {
1265 +           --count;
1266 +#ifdef HAVE_HSTRERROR
1267 +             ssh_set_error(NULL,SSH_FATAL,"Failed to resolve hostname %s (%s)",host,hstrerror(h_errno));
1268 +#else
1269 +             ssh_set_error(NULL,SSH_FATAL,"Failed to resolve hostname %s (%s)",host,strerror(h_errno));
1270 +#endif
1271 +             return -1;
1272 +        }
1273 +
1274 +        memcpy(&sa.sin_addr.s_addr,hp->h_addr_list[0],hp->h_length);
1275 +        sa.sin_family=hp->h_addrtype;
1276      }
1277 -    memset(&sa,0,sizeof(sa));
1278 -    memcpy(&sa.sin_addr,hp->h_addr,hp->h_length);
1279 -    sa.sin_family=hp->h_addrtype;
1280      sa.sin_port=htons((unsigned short)port);
1281      --count;
1282 -    
1283 +
1284      if(bind_addr){
1285          ssh_say(2,"resolving %s\n",bind_addr);
1286          hp=NULL;
1287 @@ -93,7 +140,11 @@
1288  #endif
1289          if(!hp){
1290              --count;
1291 +#ifdef HAVE_HSTRERROR
1292              ssh_set_error(NULL,SSH_FATAL,"Failed to resolve bind address %s (%s)",bind_addr,hstrerror(h_errno));
1293 +#else
1294 +            ssh_set_error(NULL,SSH_FATAL,"Failed to resolve bind address %s (%s)",bind_addr,strerror(h_errno));
1295 +#endif
1296              return -1;
1297          }
1298      }
1299 @@ -189,16 +240,16 @@
1300      if(fdset.revents & (POLLHUP|POLLIN|POLLPRI))
1301          return (session->datatoread=1);
1302      return 0;
1303 -#elif HAVE_SELECT
1304 +#elif defined(HAVE_SELECT)
1305      
1306      /* Set to return immediately (no blocking) */
1307      sometime.tv_sec = 0;
1308      sometime.tv_usec = 0;
1309 -    
1310 +
1311      /* Set up descriptor */
1312      FD_ZERO(&descriptor);
1313      FD_SET(session->fd, &descriptor);
1314 -    
1315 +
1316      /* Make the call, and listen for errors */
1317      if (select(session->fd + 1, &descriptor, NULL, NULL, &sometime) < 0) {
1318         ssh_set_error(NULL,SSH_FATAL, "select: %s", strerror(errno));
1319 @@ -213,84 +264,119 @@
1320  }
1321  
1322  /* this function is a complete wrapper for the select syscall. it does more than wrapping ... */
1323 -int ssh_select(CHANNEL **channels,CHANNEL **outchannels, int maxfd, fd_set *readfds, struct timeval *timeout){
1324 -    struct timeval zerotime;
1325 -    fd_set localset,localset2;
1326 -    int rep;
1327 -    int i,j;
1328 -    int set;
1329 -
1330 -    zerotime.tv_sec=0;
1331 -    zerotime.tv_usec=0;
1332 -    /* first, poll the maxfd file descriptors from the user with a zero-second timeout. they have the bigger priority
	*/
1333 -    if(maxfd>0){
1334 -        memcpy(&localset,readfds, sizeof(fd_set));
1335 -        rep=select(maxfd,&localset,NULL,NULL,&zerotime);
1336 -        // catch the eventual errors
1337 -        if(rep==-1)
1338 -            return -1;
1339 -    }
1340 -    j=0;
1341 -    // polls every channel.
1342 -    for(i=0;channels[i];i++){
1343 -        if(channel_poll(channels[i],0)>0){
1344 -            outchannels[j]=channels[i];
1345 -            j++;
1346 -        } else
1347 -        if(channel_poll(channels[i],1)>0){
1348 -            outchannels[j]=channels[i];
1349 -            j++;
1350 -        }
1351 -    }
1352 -    outchannels[j]=NULL;
1353 -    /* look into the localset for active fd */
1354 -    set=0;
1355 -    for(i=0;(i<maxfd) && !set;i++)
1356 -        if(FD_ISSET(i,&localset))
1357 -            set=1;
1358 -    // j!=0 means a channel has data
1359 -    if( (j!=0) || (set!=0)){
1360 -        if(maxfd>0)
1361 -            memcpy(readfds,&localset,sizeof(fd_set));
1362 -        return 0;
1363 -    }
1364 -    /* at this point, not any channel had any data ready for reading, nor any fd had data for reading */
1365 -    memcpy(&localset,readfds,sizeof(fd_set));
1366 -    for(i=0;channels[i];i++){
1367 -        if(channels[i]->session->alive){
1368 -            FD_SET(channels[i]->session->fd,&localset);
1369 -            if(channels[i]->session->fd>maxfd-1)
1370 -                maxfd=channels[i]->session->fd+1;
1371 -        }
1372 -    }
1373 -    rep=select(maxfd,&localset,NULL,NULL,timeout);
1374 -    if(rep==-1 && errno==EINTR){
1375 -        return SSH_EINTR; /* interrupted by a signal */
1376 -    }
1377 -    if(rep==-1){
1378 -        /* was the error due to a libssh's Channel or from a closed descriptor from the user ? user closed descriptors
	have been
1379 -        caught in the first select and not closed since that moment. that case shouldn't occur at all */
1380 -        return -1;
1381 -    }
1382 -    /* set the data_to_read flag on each session */
1383 -    for(i=0;channels[i];i++)
1384 -        if(FD_ISSET(channels[i]->session->fd,&localset))
1385 -            channels[i]->session->datatoread=1;
1386 -            
1387 -    /* now, test each channel */
1388 -    j=0;
1389 -    for(i=0;channels[i];i++){
1390 -        if(FD_ISSET(channels[i]->session->fd,&localset))
1391 -            if((channel_poll(channels[i],0)>0) || (channel_poll(channels[i],1)>0)){
1392 -                outchannels[j]=channels[i];
1393 -                j++;
1394 -            }
1395 -    }
1396 -    outchannels[j]=NULL;
1397 -    FD_ZERO(&localset2);
1398 -    for(i=0;i<maxfd;i++)
1399 -        if(FD_ISSET(i,readfds) && FD_ISSET(i,&localset))
1400 -            FD_SET(i,&localset2);
1401 -    memcpy(readfds,&localset2,sizeof(fd_set));
1402 -    return 0;
1403 +int ssh_select(CHANNEL **channels, CHANNEL **outchannels, int maxfd, fd_set *readfds, struct timeval *timeout){
1404 +   struct timeval zerotime;
1405 +   fd_set localset, localset2;
1406 +   int rep = 0;
1407 +   int i, j;
1408 +   int set;
1409 +   int getc_ret;
1410 +
1411 +   zerotime.tv_sec = 0;
1412 +   zerotime.tv_usec = 1;
1413 +
1414 +   /* first, poll the maxfd file descriptors from the user with a zero-second timeout. they have the bigger priority */
1415 +   if (maxfd > 0) {
1416 +       memcpy(&localset, readfds, sizeof(*readfds));
1417 +       rep = select(maxfd, &localset, NULL, NULL, &zerotime);
1418 +       // catch the eventual errors
1419 +       if (rep == -1) {
1420 +           FD_ZERO(&localset);
1421 +           if (FD_ISSET(fileno(stdin), readfds)) {
1422 +               getc_ret = getc(stdin);
1423 +               if (getc_ret != EOF) {
1424 +                   ungetc(getc_ret, stdin);
1425 +                   FD_SET(fileno(stdin), &localset);
1426 +               }
1427 +           }
1428 +       }
1429 +   }
1430 +
1431 +   /* polls every channel. */
1432 +   j = 0;
1433 +   for (i = 0; channels[i]; i++) {
1434 +       if (channel_poll(channels[i], 0) > 0) {
1435 +           outchannels[j] = channels[i];
1436 +           j++;
1437 +       } else if (channel_poll(channels[i], 1) > 0) {
1438 +           outchannels[j] = channels[i];
1439 +           j++;
1440 +       }
1441 +   }
1442 +   outchannels[j] = NULL;
1443 +
1444 +   /* look into the localset for active fd */
1445 +   set = 0;
1446 +   for (i = 0; i < maxfd; i++) {
1447 +       if (FD_ISSET(i, &localset)) {
1448 +           set = 1;
1449 +           break;
1450 +       }
1451 +   }
1452 +
1453 +   /* j!=0 means a channel has data */
1454 +   if ((j != 0) || (set != 0)) {
1455 +       if (maxfd > 0) {
1456 +           memcpy(readfds, &localset, sizeof(fd_set));
1457 +       }
1458 +       return 0;
1459 +   }
1460 +
1461 +   /* at this point, not any channel had any data ready for reading, nor any fd had data for reading */
1462 +   memcpy(&localset, readfds, sizeof(fd_set));
1463 +   for (i = 0; channels[i]; i++) {
1464 +       if (channels[i]->session->alive) {
1465 +           FD_SET(channels[i]->session->fd, &localset);
1466 +           if (channels[i]->session->fd > (maxfd - 1)) {
1467 +               maxfd = channels[i]->session->fd + 1;
1468 +           }
1469 +       }
1470 +   }
1471 +
1472 +   rep = select(maxfd, &localset, NULL, NULL, timeout);
1473 +   if (rep == -1 && errno == EINTR) {
1474 +       return SSH_EINTR; /* interrupted by a signal */
1475 +   }
1476 +
1477 +   if (rep == -1) {
1478 +       /* was the error due to a libssh's Channel or from a closed descriptor from the user ? user closed descriptors
	have been
1479 +       caught in the first select and not closed since that moment. that case shouldn't occur at all */
1480 +       FD_ZERO(&localset);
1481 +       if (FD_ISSET(fileno(stdin), readfds)) {
1482 +           getc_ret = getc(stdin);
1483 +           if (getc_ret != EOF) {
1484 +               ungetc(getc_ret, stdin);
1485 +               FD_SET(fileno(stdin), &localset);
1486 +           }
1487 +       }
1488 +   }
1489 +
1490 +   /* set the data_to_read flag on each session */
1491 +   for (i = 0; channels[i]; i++) {
1492 +       if (FD_ISSET(channels[i]->session->fd, &localset)) {
1493 +           channels[i]->session->datatoread = 1;
1494 +       }
1495 +   }
1496 +
1497 +   /* now, test each channel */
1498 +   j = 0;
1499 +   for (i = 0; channels[i]; i++) {
1500 +       if (FD_ISSET(channels[i]->session->fd, &localset)) {
1501 +           if ((channel_poll(channels[i], 0) > 0) || (channel_poll(channels[i], 1) > 0)) {
1502 +               outchannels[j] = channels[i];
1503 +               j++;
1504 +           }
1505 +       }
1506 +   }
1507 +
1508 +   outchannels[j] = NULL;
1509 +   FD_ZERO(&localset2);
1510 +   for (i = 0; i < maxfd; i++) {
1511 +       if (FD_ISSET(i, readfds) && FD_ISSET(i, &localset)) {
1512 +           FD_SET(i, &localset2);
1513 +       }
1514 +   }
1515 +
1516 +   memcpy(readfds, &localset2, sizeof(fd_set));
1517 +   return 0;
1518  }
1519 diff -uNr libssh-0.11-orig/libssh/crypt.c libssh-0.11-rsk/libssh/crypt.c
1520 --- libssh-0.11-orig/libssh/crypt.c 2005-03-04 13:54:59.000000000 -0600
1521 +++ libssh-0.11-rsk/libssh/crypt.c  2005-06-23 16:35:35.000000000 -0500
1522 @@ -28,8 +28,11 @@
1523  #include <openssl/evp.h>
1524  #include <openssl/hmac.h>
1525  
1526 -#include <netdb.h>
1527  #include "libssh/priv.h"
1528 +
1529 +#ifdef HAVE_NETDB_H
1530 +#include <netdb.h>
1531 +#endif
1532  #include "libssh/crypto.h"
1533  
1534  u32 packet_decrypt_len(SSH_SESSION *session, char *crypted){
1535 diff -uNr libssh-0.11-orig/libssh/dh.c libssh-0.11-rsk/libssh/dh.c
1536 --- libssh-0.11-orig/libssh/dh.c    2005-03-04 13:54:59.000000000 -0600
1537 +++ libssh-0.11-rsk/libssh/dh.c 2005-06-23 18:28:49.000000000 -0500
1538 @@ -35,12 +35,18 @@
1539  /* k' = e^y mod p */
1540  /* if everything went correctly, k and k' are equal */
1541  
1542 +#include "libssh/priv.h"
1543 +
1544  #include <stdio.h>
1545  #include <stdlib.h>
1546  #include <unistd.h>
1547  #include <fcntl.h>
1548 +#ifdef HAVE_NETDB_H
1549  #include <netdb.h>
1550 -#include "libssh/priv.h"
1551 +#endif
1552 +#ifdef HAVE_WINDOWS_H
1553 +#include <windows.h>
1554 +#endif
1555  
1556  #include <openssl/rand.h>
1557  #include <openssl/evp.h>
1558 @@ -68,15 +74,23 @@
1559  /* maybe it might be enhanced .... */
1560  /* XXX Do it. */       
1561  void ssh_get_random(void *where, int len){
1562 -   static int rndfd=0;
1563 -        if(!rndfd){
1564 -                rndfd=open("/dev/urandom",O_RDONLY);
1565 -                if(rndfd<0){
1566 -                        fprintf(stderr,"Can't open /dev/urandom\n");
1567 -                        exit(-1);
1568 -                }
1569 -        }
1570 -        read(rndfd,where,len);
1571 +   static int rndfd = -1;
1572 +   unsigned char *data = where;
1573 +   int i;
1574 +
1575 +   if(rndfd < 0) {
1576 +       rndfd=open("/dev/urandom",O_RDONLY);
1577 +   }
1578 +
1579 +   if(rndfd >= 0){
1580 +       read(rndfd,where,len);
1581 +       return;
1582 +   }
1583 +
1584 +   for (i = 0; i < len; i++) {
1585 +       srand(getpid() + time(NULL) + rand() + len + i);
1586 +       data[i] = (int) (256.0*rand()/(RAND_MAX+1.0));
1587 +   }
1588  }
1589  
1590  /* it inits the values g and p which are used for DH key agreement */
1591 diff -uNr libssh-0.11-orig/libssh/keyfiles.c libssh-0.11-rsk/libssh/keyfiles.c
1592 --- libssh-0.11-orig/libssh/keyfiles.c  2005-03-04 13:54:59.000000000 -0600
1593 +++ libssh-0.11-rsk/libssh/keyfiles.c   2005-06-23 20:42:53.000000000 -0500
1594 @@ -40,10 +40,19 @@
1595      char buffer[256];
1596      int len;
1597      snprintf(buffer,256,"Please enter passphrase for %s",descr);
1598 +#ifdef HAVE_GETPASS
1599      pass=getpass(buffer);
1600      snprintf(buf,size,"%s",buffer);
1601 -    len=strlen(buf);
1602      memset(pass,0,strlen(pass));
1603 +#else
1604 +    fgets(buf, size, stdin);
1605 +    if (strlen(buf) > 0) {
1606 +        if (buf[strlen(buf) - 1] == '\n') {
1607 +             buf[strlen(buf) - 1] = '\0';
1608 +        }
1609 +    }
1610 +#endif
1611 +    len=strlen(buf);
1612      return len;
1613  }
1614  
1615 @@ -277,6 +286,7 @@
1616      BUFFER *pubkey_buffer;
1617      STRING *pubkey=session->current_crypto->server_pubkey;
1618      char **tokens;
1619 +
1620      options_default_known_hosts_file(session->options);
1621      if(!session->options->host){
1622          ssh_set_error(session,SSH_FATAL,"Can't verify host in known hosts if the hostname isn't known");
1623 @@ -289,8 +299,12 @@
1624      if(tokens==FOUND_OTHER)
1625          return SSH_SERVER_FOUND_OTHER;
1626      if(tokens==FILE_NOT_FOUND){
1627 +#if 0
1628          ssh_set_error(session,SSH_FATAL,"verifying that server is a known host : file %s not
	found",session->options->known_hosts_file);
1629          return SSH_SERVER_ERROR;
1630 +#else
1631 +   return SSH_SERVER_KNOWN_OK;
1632 +#endif
1633      }
1634      /* ok we found some public key in known hosts file. now un-base64it */
1635      /* Some time, we may verify the IP address did not change. I honestly think */
1636 Binary files libssh-0.11-orig/libssh/libssh.dll and libssh-0.11-rsk/libssh/libssh.dll differ
1637 diff -uNr libssh-0.11-orig/libssh/malloc.c libssh-0.11-rsk/libssh/malloc.c
1638 --- libssh-0.11-orig/libssh/malloc.c    1969-12-31 18:00:00.000000000 -0600
1639 +++ libssh-0.11-rsk/libssh/malloc.c 2005-06-23 17:01:02.000000000 -0500
1640 @@ -0,0 +1,16 @@
1641 +#include "libssh/priv.h"
1642 +
1643 +#ifdef HAVE_MALLOC
1644 +#  if HAVE_MALLOC == 0
1645 +
1646 +#undef malloc
1647 +
1648 +#include <sys/types.h>
1649 +
1650 +void *malloc ();
1651 +
1652 +/* Allocate an N-byte block of memory from the heap. If N is zero, allocate a 1-byte block. */
1653 +
1654 +void * rpl_malloc (size_t n) { if (n == 0) n = 1; return malloc (n); } 
1655 +#  endif
1656 +#endif
1657 diff -uNr libssh-0.11-orig/libssh/misc.c libssh-0.11-rsk/libssh/misc.c
1658 --- libssh-0.11-orig/libssh/misc.c  2005-03-04 13:54:59.000000000 -0600
1659 +++ libssh-0.11-rsk/libssh/misc.c   2005-06-23 18:33:55.000000000 -0500
1660 @@ -20,25 +20,37 @@
1661  along with the SSH Library; see the file COPYING.  If not, write to
1662  the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
1663  MA 02111-1307, USA. */
1664 +
1665 +#include "libssh/priv.h"
1666 +
1667  #include <stdio.h>
1668  #include <unistd.h>
1669  #include <string.h>
1670  #include <stdlib.h>
1671 +#ifdef HAVE_PWD_H
1672  #include <pwd.h>
1673 +#endif
1674  #include <sys/types.h>
1675 +#ifdef HAVE_NETDB_H
1676  #include <netdb.h>
1677 +#endif
1678  #include "libssh/libssh.h"
1679  
1680  /* if the program was executed suid root, don't trust the user ! */
1681  static int is_trusted(){
1682 +#ifdef HAVE_GETUID
1683 +#  ifdef HAVE_GETEUID
1684      if(geteuid()!=getuid())
1685          return 0;
1686 +#  endif
1687 +#endif
1688      return 1;
1689  }
1690  
1691  static char *get_homedir_from_uid(int uid){
1692 -    struct passwd *pwd;
1693      char *home;
1694 +#ifdef HAVE_GETPWENT
1695 +    struct passwd *pwd;
1696      while((pwd=getpwent())){
1697          if(pwd->pw_uid == uid){
1698              home=strdup(pwd->pw_dir);
1699 @@ -47,10 +59,17 @@
1700          }
1701      }
1702      endpwent();
1703 +#else
1704 +#ifdef __WIN32__
1705 +    home = strdup("c:/");
1706 +    return(home);
1707 +#endif
1708 +#endif
1709      return NULL;
1710  }
1711  
1712  static char *get_homedir_from_login(char *user){
1713 +#ifdef HAVE_GETPWENT
1714      struct passwd *pwd;
1715      char *home;
1716      while((pwd=getpwent())){
1717 @@ -61,6 +80,7 @@
1718          }
1719      }
1720      endpwent();
1721 +#endif
1722      return NULL;
1723  }
1724          
1725 @@ -74,7 +94,11 @@
1726          if((user=getenv("USER")))
1727              return get_homedir_from_login(user);
1728      }
1729 +#ifdef HAVE_GETUID
1730      return get_homedir_from_uid(getuid());
1731 +#else
1732 +    return get_homedir_from_uid(0);
1733 +#endif
1734  }
1735  
1736  /* we have read access on file */
1737 diff -uNr libssh-0.11-orig/libssh/options.c libssh-0.11-rsk/libssh/options.c
1738 --- libssh-0.11-orig/libssh/options.c   2005-03-04 13:54:59.000000000 -0600
1739 +++ libssh-0.11-rsk/libssh/options.c    2005-06-23 16:44:50.000000000 -0500
1740 @@ -19,13 +19,15 @@
1741  along with the SSH Library; see the file COPYING.  If not, write to
1742  the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
1743  MA 02111-1307, USA. */
1744 +#include "libssh/priv.h"
1745  #include <stdio.h>
1746  #include <stdlib.h>
1747  #include <unistd.h>
1748  #include <string.h>
1749 +#ifdef HAVE_PWD_H
1750  #include <pwd.h>
1751 +#endif
1752  #include <sys/types.h>
1753 -#include "libssh/priv.h"
1754  
1755  SSH_OPTIONS *options_new(){
1756      SSH_OPTIONS *option=malloc(sizeof(SSH_OPTIONS));
1757 @@ -159,6 +161,7 @@
1758  }
1759  
1760  static char *get_username_from_uid(int uid){
1761 +#ifdef HAVE_GETPWENT
1762      struct passwd *pwd;
1763      char *user;
1764      while((pwd=getpwent())){
1765 @@ -169,6 +172,7 @@
1766          }
1767      }
1768      endpwent();
1769 +#endif
1770      ssh_set_error(NULL,SSH_FATAL,"uid %d doesn't exist !",uid);
1771      return NULL;
1772  }
1773 @@ -183,11 +187,14 @@
1774          opt->username=strdup(user);
1775          return 0;
1776      }
1777 +
1778 +#ifdef HAVE_GETUID
1779      user=get_username_from_uid(getuid());
1780      if(user){
1781          opt->username=user;
1782          return 0;
1783      }
1784 +#endif
1785      return -1;
1786  }
1787  
1788 diff -uNr libssh-0.11-orig/libssh/packet.c libssh-0.11-rsk/libssh/packet.c
1789 --- libssh-0.11-orig/libssh/packet.c    2005-03-04 13:54:59.000000000 -0600
1790 +++ libssh-0.11-rsk/libssh/packet.c 2005-06-24 11:20:48.000000000 -0500
1791 @@ -20,13 +20,25 @@
1792  the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
1793  MA 02111-1307, USA. */
1794  
1795 +#include "libssh/priv.h"
1796 +
1797  #include <stdlib.h>
1798  #include <stdio.h>
1799  #include <unistd.h>
1800  #include <string.h>
1801 -#include "libssh/priv.h"
1802  #include "libssh/ssh2.h"
1803 +#ifdef HAVE_NETDB_H
1804  #include <netdb.h>
1805 +#endif
1806 +#ifdef HAVE_WINDOWS_H
1807 +#include <windows.h>
1808 +#endif
1809 +#ifdef HAVE_SYS_TYPES_H
1810 +#include <sys/types.h>
1811 +#endif
1812 +#ifdef HAVE_SYS_SOCKET_H
1813 +#include <sys/socket.h>
1814 +#endif
1815  #include <errno.h>
1816  #include "libssh/crypto.h"
1817  
1818 @@ -38,7 +50,7 @@
1819      int r;
1820      int total=0;
1821      int toread=len;
1822 -    while((r=read(fd,buffer+total,toread))){
1823 +    while((r=recv(fd,buffer+total,toread,0))){
1824          if(r==-1)
1825              return -1;
1826          total += r;
1827 @@ -171,7 +183,7 @@
1828      int written;
1829      int total=0;
1830      do {
1831 -        written=write(fd,buffer,len);
1832 +        written=send(fd,buffer,len,0);
1833          if(written==0)
1834              return 0;
1835          if(written==-1)
1836 diff -uNr libssh-0.11-orig/libssh/server.c libssh-0.11-rsk/libssh/server.c
1837 --- libssh-0.11-orig/libssh/server.c    2005-03-04 13:54:59.000000000 -0600
1838 +++ libssh-0.11-rsk/libssh/server.c 2005-06-24 10:34:22.000000000 -0500
1839 @@ -25,14 +25,20 @@
1840  /* from times to times, you need to serve your friends */
1841  /* and, perhaps, ssh connections. */
1842  
1843 +#include "libssh/priv.h"
1844 +
1845  #ifdef WITH_SERVER
1846  
1847  #include <fcntl.h>
1848  #include <unistd.h>
1849  #include <stdio.h>
1850  #include <sys/types.h>
1851 +#ifdef HAVE_SYS_SOCKET_H
1852  #include <sys/socket.h>
1853 +#endif
1854 +#ifdef HAVE_NETDB_H
1855  #include <netdb.h>
1856 +#endif
1857  #include <errno.h>
1858  #include <string.h>
1859  #include "libssh/libssh.h"
1860 @@ -41,7 +47,11 @@
1861  int bind_socket() {
1862      struct sockaddr_in myaddr;
1863      int opt = 1;
1864 -    int s = socket(PF_INET, SOCK_STREAM, 0);
1865 +    int s;
1866 +
1867 +    ssh_net_init();
1868 +
1869 +    s = socket(PF_INET, SOCK_STREAM, 0);
1870      memset(&myaddr, 0, sizeof(myaddr));
1871      myaddr.sin_family = AF_INET;
1872      myaddr.sin_port = htons(2222);
1873 @@ -122,7 +132,9 @@
1874             "kex error : did not find algo");
1875         return -1;
1876     }
1877 +    }
1878      return 0;
1879 +
1880  }
1881  
1882  #endif /* HAVE_SERVER */
1883 diff -uNr libssh-0.11-orig/libssh/sftp.c libssh-0.11-rsk/libssh/sftp.c
1884 --- libssh-0.11-orig/libssh/sftp.c  2005-03-04 13:54:59.000000000 -0600
1885 +++ libssh-0.11-rsk/libssh/sftp.c   2005-06-23 16:56:57.000000000 -0500
1886 @@ -22,10 +22,12 @@
1887  MA 02111-1307, USA. */
1888  
1889  
1890 +#include "libssh/priv.h"
1891  #include <string.h>
1892  #include <fcntl.h>
1893 +#ifdef HAVE_NETDB_H
1894  #include <netdb.h>
1895 -#include "libssh/priv.h"
1896 +#endif
1897  #include "libssh/ssh2.h"
1898  #include "libssh/sftp.h"
1899  #ifndef NO_SFTP
1900 diff -uNr libssh-0.11-orig/libssh/string.c libssh-0.11-rsk/libssh/string.c
1901 --- libssh-0.11-orig/libssh/string.c    2005-03-04 13:54:59.000000000 -0600
1902 +++ libssh-0.11-rsk/libssh/string.c 2005-06-23 16:42:46.000000000 -0500
1903 @@ -20,11 +20,13 @@
1904  the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
1905  MA 02111-1307, USA. */
1906  
1907 +#include "libssh/priv.h"
1908  #include <stdlib.h>
1909 +#ifdef HAVE_NETDB_H
1910  #include <netdb.h>
1911 +#endif
1912  #include <unistd.h>
1913  #include <string.h>
1914 -#include "libssh/priv.h"
1915  
1916  STRING *string_new(u32 size){
1917      STRING *str=malloc(size + 4);
1918 diff -uNr libssh-0.11-orig/sample.c libssh-0.11-rsk/sample.c
1919 --- libssh-0.11-orig/sample.c   2005-03-04 13:54:59.000000000 -0600
1920 +++ libssh-0.11-rsk/sample.c    2005-06-24 09:54:17.000000000 -0500
1921 @@ -12,16 +12,26 @@
1922  clients must be made or how a client should react.
1923  */
1924  
1925 +#include "libssh/priv.h"
1926 +
1927  #include <stdio.h>
1928  #include <unistd.h>
1929  #include <stdlib.h>
1930  #include <string.h>
1931 +#ifdef HAVE_TERMIOS_H
1932  #include <termios.h>
1933 +#endif
1934  
1935 +#ifdef HAVE_SYS_SELECT_H
1936  #include <sys/select.h>
1937 +#endif
1938  #include <sys/time.h>
1939 +#ifdef HAVE_PTY_H
1940  #include <pty.h>
1941 +#endif
1942 +#ifdef HAVE_SIGNAL_H
1943  #include <signal.h>
1944 +#endif
1945  #include <errno.h>
1946  #include <libssh/libssh.h>
1947  #include <libssh/sftp.h>
1948 @@ -33,7 +43,9 @@
1949  char *user;
1950  int sftp;
1951  char *cmds[MAXCMD];
1952 +#ifdef HAVE_TERMIOS_H
1953  struct termios terminal;
1954 +#endif
1955  void do_sftp(SSH_SESSION *session);
1956  
1957  void add_cmd(char *cmd){
1958 @@ -78,7 +90,9 @@
1959  }
1960  
1961  void do_cleanup(){
1962 +#ifdef HAVE_TCSETATTR
1963      tcsetattr(0,TCSANOW,&terminal);
1964 +#endif
1965  }
1966  void do_exit(){
1967      do_cleanup();
1968 @@ -91,28 +105,32 @@
1969      signal_delayed=1;
1970  }
1971  void sizechanged(){
1972 +#ifdef HAVE_PTY_H
1973      struct winsize win = { 0, 0, 0, 0 };
1974      ioctl(1, TIOCGWINSZ, &win);
1975      channel_change_pty_size(chan,win.ws_col, win.ws_row);
1976  //    printf("Changed pty size\n");
1977      setsignal();
1978 +#endif
1979  }
1980  void setsignal(){
1981 +#ifdef HAVE_SIGNAL
1982      signal(SIGWINCH,sigwindowchanged);
1983      signal_delayed=0;
1984 +#endif
1985  }
1986  
1987 -void select_loop(SSH_SESSION *session,CHANNEL *channel){
1988 +void select_loop(SSH_SESSION *session, CHANNEL *channel){
1989      fd_set fds;
1990      struct timeval timeout;
1991      char buffer[10];
1992 -    BUFFER *readbuf=buffer_new();
1993 -    CHANNEL *channels[]={channel,NULL};
1994 -    CHANNEL *outchannel[2];
1995 +    BUFFER *readbuf = buffer_new();
1996 +    CHANNEL *channels[2] = {channel, NULL};
1997 +    CHANNEL *outchannel[2] = {NULL, NULL};
1998      int lus;
1999 -    int eof=0;
2000 +    int eof = 0;
2001      int ret;
2002 -    while(channel){
2003 +    while (channel) {
2004         /* when a signal is caught, ssh_select will return
2005           * with SSH_EINTR, which means it should be started 
2006           * again. It lets you handle the signal the faster you
2007 @@ -120,18 +138,20 @@
2008           * your signal handler doesn't call libssh at all, you're
2009           * free to handle signals directly in sighandler.
2010           */
2011 -        do{
2012 +        do {
2013              FD_ZERO(&fds);
2014 -            if(!eof)
2015 -                FD_SET(0,&fds);
2016 -            timeout.tv_sec=30;
2017 -            timeout.tv_usec=0;
2018 -            ret=ssh_select(channels,outchannel,0+1,&fds,&timeout);
2019 -            if(signal_delayed)
2020 +            if(!eof) {
2021 +                FD_SET(fileno(stdin), &fds);
2022 +            }
2023 +            timeout.tv_sec = 30;
2024 +            timeout.tv_usec = 0;
2025 +            ret = ssh_select(channels,outchannel,fileno(stdin)+1,&fds,&timeout);
2026 +            if (signal_delayed) {
2027                  sizechanged();        
2028 +            }
2029          } while (ret==SSH_EINTR);
2030 -        if(FD_ISSET(0,&fds)){
2031 -            lus=read(0,buffer,10);
2032 +        if(FD_ISSET(fileno(stdin),&fds)){
2033 +            lus=fread(buffer,1,10,stdin);
2034              if(lus){
2035                  channel_write(channel,buffer,lus);
2036              }
2037 @@ -174,16 +194,22 @@
2038  
2039  void shell(SSH_SESSION *session){
2040      CHANNEL *channel;
2041 +#ifdef HAVE_TERMIOS_H
2042      struct termios terminal_local;
2043 +#endif
2044      int interactive=isatty(0);
2045      if(interactive){
2046 +#ifdef HAVE_TCGETATTR
2047          tcgetattr(0,&terminal_local);
2048          memcpy(&terminal,&terminal_local,sizeof(struct termios));
2049          cfmakeraw(&terminal_local);
2050          tcsetattr(0,TCSANOW,&terminal_local);
2051 +#endif
2052          setsignal();
2053      }
2054 +#ifdef HAVE_SIGNAL
2055      signal(SIGTERM,do_cleanup);
2056 +#endif
2057      channel = channel_open_session(session);
2058      chan=channel;
2059      if(interactive){
2060 @@ -310,7 +336,18 @@
2061                  ssh_userauth_kbdint_setanswer(session,i,buffer);
2062                  memset(buffer,0,strlen(buffer));
2063              } else {
2064 +#ifdef HAVE_GETPASS
2065                  ptr=getpass(prompt);
2066 +#else
2067 +       fprintf(stderr, "%s", prompt);
2068 +       ptr = malloc(1024);
2069 +       fgets(ptr, 1024, stdin);
2070 +       if (strlen(ptr) > 0) {
2071 +           if (ptr[strlen(ptr) - 1] == '\n') {
2072 +               ptr[strlen(ptr) - 1] = '\0';
2073 +           }
2074 +       }
2075 +#endif
2076                  ssh_userauth_kbdint_setanswer(session,i,ptr);
2077              }
2078          }
2079 @@ -336,13 +373,15 @@
2080          return -1;
2081      }    
2082      opts(argc,argv);
2083 +#ifdef HAVE_SIGNAL
2084      signal(SIGTERM,do_exit);
2085 +#endif
2086      if(user)
2087          options_set_username(options,user);
2088      options_set_host(options,host);
2089      session=ssh_connect(options);
2090      if(!session){
2091 -        fprintf(stderr,"Connection failed : %s\n",ssh_get_error(NULL));
2092 +        fprintf(stderr,"[4891] Connection failed : %s\n",ssh_get_error(NULL));
2093          return -1;
2094      }
2095  
2096 @@ -407,7 +446,18 @@
2097          }
2098      }
2099      if(auth!=SSH_AUTH_SUCCESS){
2100 +#ifdef HAVE_GETPASS
2101          password=getpass("Password : ");
2102 +#else
2103 +   fprintf(stderr, "Password : ");
2104 +   password = malloc(1024);
2105 +   fgets(password, 1024, stdin);
2106 +   if (strlen(password) > 0) {
2107 +       if (password[strlen(password) - 1] == '\n') {
2108 +           password[strlen(password) - 1] = '\0';
2109 +       }
2110 +   }
2111 +#endif
2112          if(ssh_userauth_password(session,NULL,password) != SSH_AUTH_SUCCESS){
2113              fprintf(stderr,"Authentication failed: %s\n",ssh_get_error(session));
2114              ssh_disconnect(session);
2115 Binary files libssh-0.11-orig/samplesftp and libssh-0.11-rsk/samplesftp differ
2116 Binary files libssh-0.11-orig/samplessh and libssh-0.11-rsk/samplessh differ
2117 Binary files libssh-0.11-orig/samplesshd and libssh-0.11-rsk/samplesshd differ
2118 diff -uNr libssh-0.11-orig/samplesshd.c libssh-0.11-rsk/samplesshd.c
2119 --- libssh-0.11-orig/samplesshd.c   2005-03-04 13:54:59.000000000 -0600
2120 +++ libssh-0.11-rsk/samplesshd.c    2005-06-24 10:34:21.000000000 -0500
2121 @@ -22,16 +22,18 @@
2122  
2123  #include <libssh/libssh.h>
2124  #include <libssh/server.h>
2125 +#include "libssh/priv.h"
2126  #include <unistd.h>
2127 +#include <stdio.h>
2128  int main(int argc, char **argv){
2129  #ifdef WITH_SERVER
2130      SSH_OPTIONS *opts=ssh_getopt(&argc,argv);
2131 -    SSH_SESSION *server=getserver(opts);
2132 +    SSH_SESSION *server = getserver(opts);
2133      if(!server){
2134        printf("pwned : %s\n",ssh_get_error(NULL));
2135        exit(-1);
2136      }
2137 -    server->clientbanner=ssh_get_banner(server);
2138 +    server->clientbanner = ssh_get_banner(server);
2139      if(!server->clientbanner){
2140          printf("%s\n",ssh_get_error(NULL));
2141          return -1;
2142 @@ -44,6 +46,8 @@
2143      }
2144      list_kex(&server->client_kex);
2145  
2146 +    printf("Key exchange complete.\n");
2147 +
2148      while(1);
2149  #endif
2150      return 0;

libssh-0.11-win32-1.patch is a patch against libssh 0.11 to support the Win32 platform.
5113563 [rkeene@sledge /home/rkeene/projects/libssh-win32/v0.11]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2008-10-17 07:41:29