Bug#123782: acknowledged by developer (Re: Bug#123782: boot-floppies: dbootstrap's wget should use passive ftp)

2001-12-16 Thread Erik Andersen

On Sat Dec 15, 2001 at 09:55:08AM -0800, Matt Kraai wrote:
> On Fri, Dec 14, 2001 at 07:38:03PM -0600, Mike Coleman wrote:
> > [EMAIL PROTECTED] (Debian Bug Tracking System) writes:
> > > Anyhow, it's irrelevant.  Since busybox wget doens't support this
> > > argument, the user's request to use this argument is hereby denied.
> > > :)
> > > 
> > > Bug submitter, if busybox wget is not using ftp in the right way,
> > > please file a bug on busybox, not on the boot-floppies.  Thanks.
> > 
> > Turns out that busybox wget *does* use passive ftp by default, which it
> > should, but that there's a bug in the way it's doing name lookups.
> > (The problem is that it does a second DNS lookup for the PASV connection,
> > which won't necessarily return the same IP for a round-robin DNS situation
> > like ftp.us.debian.org, so the download fails.)
> 
> Indeed.  Thanks for figuring this out.  I've built fixed
> packages[1], if you can use them, and appended the patch.

Good work Matt and Mike.  Applied to CVS.  A new busybox package
is forthcoming,

 -Erik

--
Erik B. Andersen http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Bug#123782: acknowledged by developer (Re: Bug#123782: boot-floppies: dbootstrap's wget should use passive ftp)

2001-12-15 Thread Matt Kraai

On Fri, Dec 14, 2001 at 07:38:03PM -0600, Mike Coleman wrote:
> [EMAIL PROTECTED] (Debian Bug Tracking System) writes:
> > Anyhow, it's irrelevant.  Since busybox wget doens't support this
> > argument, the user's request to use this argument is hereby denied.
> > :)
> > 
> > Bug submitter, if busybox wget is not using ftp in the right way,
> > please file a bug on busybox, not on the boot-floppies.  Thanks.
> 
> Turns out that busybox wget *does* use passive ftp by default, which it
> should, but that there's a bug in the way it's doing name lookups.
> (The problem is that it does a second DNS lookup for the PASV connection,
> which won't necessarily return the same IP for a round-robin DNS situation
> like ftp.us.debian.org, so the download fails.)

Indeed.  Thanks for figuring this out.  I've built fixed
packages[1], if you can use them, and appended the patch.

Matt

1. http://www.lafn.org/~kraai/busybox/busybox_0.60.2-2.2_powerpc.changes

--- busybox-0.60.2/wget.c   Thu Jul 19 15:28:01 2001
+++ busybox/wget.c  Sat Dec 15 09:36:34 2001
@@ -53,7 +53,8 @@
 };
 
 static void parse_url(char *url, struct host_info *h);
-static FILE *open_socket(char *host, int port);
+static struct sockaddr_in *lookup_host(char *host);
+static FILE *open_socket(struct sockaddr_in *s_in, int port);
 static char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc);
 static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf);
 
@@ -168,6 +169,7 @@
int extra_headers_left = sizeof(extra_headers);
int which_long_opt = 0, option_index = -1;
struct host_info server, target;
+   struct sockaddr_in *s_in;
 
FILE *sfp = NULL;   /* socket to web/ftp server
 */
FILE *dfp = NULL;   /* socket to ftp server (data) 
 */
@@ -289,6 +291,8 @@
do_continue = 0;
}
 
+   s_in = lookup_host (server.host);
+
if (proxy || !target.is_ftp) {
/*
 *  HTTP session
@@ -301,7 +305,7 @@
 * Open socket to http server
 */
if (sfp) fclose(sfp);
-   sfp = open_socket(server.host, server.port);
+   sfp = open_socket(s_in, server.port);

/*
 * Send HTTP request.
@@ -407,7 +411,7 @@
if (! target.user)
target.user = xstrdup("anonymous:busybox@");
 
-   sfp = open_socket(server.host, server.port);
+   sfp = open_socket(s_in, server.port);
if (ftpcmd(NULL, NULL, sfp, buf) != 220)
close_delete_and_die("%s", buf+4);
 
@@ -450,7 +454,7 @@
port = atoi(s+1);
s = strrchr(buf, ',');
port += atoi(s+1) * 256;
-   dfp = open_socket(server.host, port);
+   dfp = open_socket(s_in, port);
 
if (do_continue) {
sprintf(buf, "REST %ld", beg_range);
@@ -552,26 +556,34 @@
 }
 
 
-FILE *open_socket(char *host, int port)
+static struct sockaddr_in *lookup_host(char *host)
 {
-   struct sockaddr_in s_in;
+   static struct sockaddr_in s_in;
struct hostent *hp;
-   int fd;
-   FILE *fp;
 
memset(&s_in, 0, sizeof(s_in));
s_in.sin_family = AF_INET;
hp = xgethostbyname(host);
memcpy(&s_in.sin_addr, hp->h_addr_list[0], hp->h_length);
-   s_in.sin_port = htons(port);
+
+   return &s_in;
+}
+
+
+FILE *open_socket(struct sockaddr_in *s_in, int port)
+{
+   int fd;
+   FILE *fp;
+
+   s_in->sin_port = htons(port);
 
/*
 * Get the server onto a stdio stream.
 */
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
perror_msg_and_die("socket()");
-   if (connect(fd, (struct sockaddr *) &s_in, sizeof(s_in)) < 0)
-   perror_msg_and_die("connect(%s)", host);
+   if (connect(fd, (struct sockaddr *) s_in, sizeof(*s_in)) < 0)
+   perror_msg_and_die("connect()");
if ((fp = fdopen(fd, "r+")) == NULL)
perror_msg_and_die("fdopen()");
 


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Bug#123782: acknowledged by developer (Re: Bug#123782: boot-floppies: dbootstrap's wget should use passive ftp)

2001-12-14 Thread Mike Coleman

[EMAIL PROTECTED] (Debian Bug Tracking System) writes:
> Anyhow, it's irrelevant.  Since busybox wget doens't support this
> argument, the user's request to use this argument is hereby denied.
> :)
> 
> Bug submitter, if busybox wget is not using ftp in the right way,
> please file a bug on busybox, not on the boot-floppies.  Thanks.

Turns out that busybox wget *does* use passive ftp by default, which it
should, but that there's a bug in the way it's doing name lookups.
(The problem is that it does a second DNS lookup for the PASV connection,
which won't necessarily return the same IP for a round-robin DNS situation
like ftp.us.debian.org, so the download fails.)

A workaround is to use a specific IP address instead of the hostname.

I'll file against busybox.

Mike


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]