diff -u --recursive --new-file afd-1.3.6.old/src/protocols/ssh_common.c afd-1.3.6/src/protocols/ssh_common.c --- afd-1.3.6.old/src/protocols/ssh_common.c 2007-11-13 20:48:39.000000000 +0100 +++ afd-1.3.6/src/protocols/ssh_common.c 2008-03-19 18:33:21.000000000 +0100 @@ -487,6 +487,7 @@ status = select(max_fd, &rset, NULL, &eset, &timeout); if (status > 0) { +retry_read: if (FD_ISSET(data_fd, &eset) || FD_ISSET(fdm, &eset)) { trans_log(ERROR_SIGN, __FILE__, __LINE__, NULL, @@ -572,15 +573,6 @@ { char *ptr = msg_str; - while (*ptr) - { - if (*ptr == '\n') - { - *ptr = ' '; - } - ptr++; - } - ptr = msg_str; if ((posi(ptr, "assword:") != NULL) || (!strncmp(msg_str, "Enter passphrase", 16))) { @@ -614,6 +606,14 @@ } else { + while (*ptr) + { + if ((*ptr == '\n') || (*ptr == '\r')) + { + *ptr = ' '; + } + ptr++; + } trans_log(ERROR_SIGN, __FILE__, __LINE__, msg_str, "Failed to enter passwd."); status = INCORRECT; @@ -626,6 +626,14 @@ { /* It's asking for a password or passphrase and */ /* we don't have one. Report error. */ + while (*ptr) + { + if ((*ptr == '\n') || (*ptr == '\r')) + { + *ptr = ' '; + } + ptr++; + } trans_log(ERROR_SIGN, __FILE__, __LINE__, msg_str, "ssh is asking for password (or passphrase) and none is provided. Bailing out!"); status = INCORRECT; @@ -743,6 +751,30 @@ } else { + int tmp_status; + + /* + * If the ssh daemon sends a banner this is + * send to us by the ssh client in another + * buffer. So we need to ensure there is no + * more data in the pipe otherwise we will not + * see password prompt and or other messages + * that are important. + */ + FD_SET(data_fd, &rset); + FD_SET(data_fd, &eset); + FD_SET(fdm, &rset); + FD_SET(fdm, &eset); + timeout.tv_usec = 0L; + timeout.tv_sec = 5L; + tmp_status = select(max_fd, &rset, NULL, &eset, + &timeout); + if (tmp_status > 0) + { + status = tmp_status; + goto retry_read; + } + /* Replace '\n's by spaces for logging. */ while (*ptr++) {