*** bbnet.c.orig 2004-11-24 22:11:36.000000000 -0500 --- bbnet.c 2004-11-25 15:34:21.000000000 -0500 *************** *** 55,61 **** int timer1 = BBNETTIMER1; int timer2 = BBNETTIMER2; int timer3 = BBNETTIMER3; - char errormsg[MAXLINE]; #ifdef SIGSETJMP --- 55,60 ---- *************** *** 286,291 **** --- 285,291 ---- struct sockaddr_in serv_addr; int stopwriting=0; char line[MAXLINE+1]; + char sendline[MAXLINE+1]; char *lineptr; *************** *** 364,402 **** /* Thanks to Carl Privitt */ /* Added port in Host: HTTP message header: Christian Perrier */ if (dir) ! sprintf(line, "HEAD %s HTTP/1.0\r\nUser-Agent: BigBrother/%s\r\nHost: %s:%d\r\n\r\n", dir,BBREL,machine,port); else ! sprintf(line, "HEAD / HTTP/1.0\r\nUser-Agent: BigBrother/%s\r\nHost: %s:%d\r\n\r\n", BBREL,machine,port); } /* * Thanks to Jon Lewis */ else { ! sprintf(line, "quit\r\n"); #if DEBUG debug("We have default: %s\n", line); #endif } if (input) { if (strlen(input)) { ! strncpy(line, input, MAXLINE -5); ! strcat(line, "\r\n"); #if DEBUG ! debug("We have input: %s\n", line); #endif } else { /* THIS IS TO ALLOW NULL INPUT */ ! line[0] = '\0'; #if DEBUG debug("NULL INPUT\n"); #endif } } ! ! n = send(sockfd, line, strlen(line),0); line[0]='\0'; - /* FIRST TIME AROUND - 3 SECOND DELAY */ loopcnt = 0; timer = timer1; --- 364,404 ---- /* Thanks to Carl Privitt */ /* Added port in Host: HTTP message header: Christian Perrier */ if (dir) ! sprintf(sendline, "HEAD %s HTTP/1.0\r\nUser-Agent: BigBrother/%s\r\nHost: %s:%d\r\n\r\n", dir,BBREL,machine,port); else ! sprintf(sendline, "HEAD / HTTP/1.0\r\nUser-Agent: BigBrother/%s\r\nHost: %s:%d\r\n\r\n", BBREL,machine,port); } /* * Thanks to Jon Lewis */ else { ! sprintf(sendline, "quit\r\n"); #if DEBUG debug("We have default: %s\n", line); #endif } if (input) { if (strlen(input)) { ! strncpy(sendline, input, MAXLINE -5); ! strcat(sendline, "\r\n"); #if DEBUG ! debug("We have input: %s\n", sendline); #endif } else { /* THIS IS TO ALLOW NULL INPUT */ ! sendline[0] = '\0'; #if DEBUG debug("NULL INPUT\n"); #endif } } ! /* ! * Al Payne - 2004-11-24 ! * sending data first caused the output to be lost from some SSH servers ! */ ! if (port != 22) n = send(sockfd, sendline, strlen(sendline),0); line[0]='\0'; /* FIRST TIME AROUND - 3 SECOND DELAY */ loopcnt = 0; timer = timer1; *************** *** 426,432 **** } } alarm(timer); - while ( (n = recv(sockfd, line, MAXLINE, 0)) > 0 ) { /* * SMM - 1.09 --- 428,433 ---- *************** *** 455,460 **** --- 456,478 ---- if (n > 0) line[n]='\0';/* Shun-Jee Liu */ /* + * Al Payne - 2004-11-24 (apayne@pleiades.com) + * Don't wait for ssh server to reply again. If we've + * made it this far, we got something, and bb-network.sh + * will determine if it's valid. + */ + if (port == 22) { + n = send(sockfd, sendline, strlen(sendline),0); + + alarm(0); + printf("%s",line); + #ifdef GETTIMEOFDAY + stopwatch(); /* STOP THE CLOCK */ + #endif + close(sockfd); + return(0); + } + /* * SMM - 26 DEC 97 * SOME TESTING SHOULDN'T BE DISPLAYED 'CAUSE IT'S GROSS * THANKS TO: Per.E.Berger@telia.se