diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2004-02-28 20:08:39 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2004-02-28 20:08:39 +0000 |
commit | 68c59d886feb0c2e491e9608d0a185298de6d55c (patch) | |
tree | 805052e1f5f634399e6401716effb33bc6379b4d /usr.bin | |
parent | b512d87fadb1280dc0b9c44a2d02e323455ac2f0 (diff) |
Open a new connection for each URL given on the command line.
This eliminates problematic 'CWD /' commands that caused interactive
commands and auto fetch commands to occaisonally end up in different
directories, creating problems for the install scripts.
Problematic 'CWD /' commands noticed by deraadt@.
ok millert@.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ftp/fetch.c | 66 |
1 files changed, 25 insertions, 41 deletions
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index 90e48db5e7e..57c0c2f79c2 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fetch.c,v 1.48 2003/12/16 21:46:22 deraadt Exp $ */ +/* $OpenBSD: fetch.c,v 1.49 2004/02/28 20:08:38 krw Exp $ */ /* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */ /*- @@ -38,7 +38,7 @@ */ #if !defined(lint) && !defined(SMALL) -static char rcsid[] = "$OpenBSD: fetch.c,v 1.48 2003/12/16 21:46:22 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: fetch.c,v 1.49 2004/02/28 20:08:38 krw Exp $"; #endif /* not lint and not SMALL */ /* @@ -610,14 +610,13 @@ auto_fetch(argc, argv, outfile) char *argv[]; char *outfile; { - static char lasthost[MAXHOSTNAMELEN]; char *xargv[5]; char *cp, *line, *host, *dir, *file, *portnum; char *user, *pass; char *ftpproxy, *httpproxy; int rval, xargc; volatile int argpos; - int dirhasglob, filehasglob; + int dirhasglob, filehasglob, oautologin; char rempath[MAXPATHLEN]; argpos = 0; @@ -778,49 +777,34 @@ bad_ftp_url: user, pass, host, portnum, dir, file); /* - * Set up the connection if we don't have one. + * Set up the connection. */ - if (strcmp(host, lasthost) != 0) { - int oautologin; - - (void)strlcpy(lasthost, host, sizeof lasthost); - if (connected) - disconnect(0, NULL); - xargv[0] = __progname; - xargv[1] = host; - xargv[2] = NULL; - xargc = 2; - if (!EMPTYSTRING(portnum)) { - xargv[2] = portnum; - xargv[3] = NULL; - xargc = 3; - } - oautologin = autologin; - if (user != NULL) - autologin = 0; - setpeer(xargc, xargv); - autologin = oautologin; - if ((connected == 0) || - ((connected == 1) && !ftp_login(host, user, pass))) { - warnx("Can't connect or login to host `%s'", - host); - rval = argpos + 1; - continue; - } - - /* Always use binary transfers. */ - setbinary(0, NULL); - } - /* cd back to '/' */ - xargv[0] = "cd"; - xargv[1] = "/"; + if (connected) + disconnect(0, NULL); + xargv[0] = __progname; + xargv[1] = host; xargv[2] = NULL; - cd(2, xargv); - if (!dirchange) { + xargc = 2; + if (!EMPTYSTRING(portnum)) { + xargv[2] = portnum; + xargv[3] = NULL; + xargc = 3; + } + oautologin = autologin; + if (user != NULL) + autologin = 0; + setpeer(xargc, xargv); + autologin = oautologin; + if ((connected == 0) || + ((connected == 1) && !ftp_login(host, user, pass))) { + warnx("Can't connect or login to host `%s'", host); rval = argpos + 1; continue; } + /* Always use binary transfers. */ + setbinary(0, NULL); + dirhasglob = filehasglob = 0; if (doglob) { if (!EMPTYSTRING(dir) && |