Hello community, here is the log from the commit of package lftp checked in at Sun Apr 9 12:17:38 CEST 2006. -------- --- lftp/lftp.changes 2006-03-20 18:05:43.000000000 +0100 +++ lftp/lftp.changes 2006-04-08 00:29:20.000000000 +0200 @@ -1,0 +2,5 @@ +Fri Apr 7 16:21:58 CEST 2006 - pnemec@suse.cz + +- fixed lftp_wrapper [#162595] + +------------------------------------------------------------------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ lftp.spec ++++++ --- /var/tmp/diff_new_pack.fMKMRE/_old 2006-04-09 12:17:12.000000000 +0200 +++ /var/tmp/diff_new_pack.fMKMRE/_new 2006-04-09 12:17:12.000000000 +0200 @@ -26,7 +26,7 @@ URL: http://lftp.yar.ru/ Autoreqprov: on Version: 3.4.0 -Release: 15 +Release: 17 Summary: LFTP Command Line File Transfer Program Source: %{name}-%{version}.tar.bz2 Patch1: %{name}-%{version}-nostrip.diff @@ -117,6 +117,8 @@ rm -rf $RPM_BUILD_ROOT %changelog -n lftp +* Fri Apr 07 2006 - pnemec@suse.cz +- fixed lftp_wrapper [#162595] * Mon Mar 20 2006 - postadal@suse.cz - packaged %%ghost /usr/bin/ftp [#159341] * Mon Mar 13 2006 - postadal@suse.cz ++++++ lftp-wrapper.patch ++++++ --- /var/tmp/diff_new_pack.fMKMRE/_old 2006-04-09 12:17:12.000000000 +0200 +++ /var/tmp/diff_new_pack.fMKMRE/_new 2006-04-09 12:17:12.000000000 +0200 @@ -1,25 +1,25 @@ ---- src/Makefile.am -+++ src/Makefile.am -@@ -1,7 +1,7 @@ - localedir = $(datadir)/locale - pkgverlibdir = $(pkglibdir)/$(VERSION) - --bin_PROGRAMS = lftp -+bin_PROGRAMS = lftp lftp_wrapper - bin_SCRIPTS = lftpget - pkgdata_SCRIPTS = import-ncftp import-netscape verify-file convert-netscape-cookies - noinst_SCRIPTS = ftpget -@@ -10,6 +10,7 @@ - example1.cc example2.cc +--- src/CopyJob.cc ++++ src/CopyJob.cc +@@ -21,6 +21,7 @@ + /* $Id: CopyJob.cc,v 1.32 2005/06/22 09:25:59 lav Exp $ */ - lftp_SOURCES = lftp.cc complete.h complete.cc lftp_rl.c lftp_rl.h getdate.y getdate.h -+lftp_wrapper_SOURCES = lftp_wrapper.c - - #ftpget_SOURCES = ftpget.cc + #include <config.h> ++#include <unistd.h> + #include "CopyJob.h" + #include "ArgV.h" + #include "plural.h" +@@ -269,7 +270,7 @@ + void CopyJobEnv::SayFinalWithPrefix(const char *p) + { +- if(no_status) ++ if(no_status || !isatty(1)) + return; + if(count==errors) + return; --- src/lftp_wrapper.c +++ src/lftp_wrapper.c -@@ -0,0 +1,978 @@ +@@ -0,0 +1,1036 @@ + +/*************************************************************************** + * * @@ -37,7 +37,7 @@ + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * -+ * the Free Software Foundation; either version 2 of the License, or * ++ * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ @@ -62,7 +62,7 @@ +static char *collect_strings(int argc, char **argv); +char *get_file(char *url_with_file); +char *get_url(char *url_with_file); -+int haveFile(char *retez); ++int haveFile(char *text); + +int isFile(char *url); +int isFTP(char *url); @@ -71,6 +71,7 @@ +int locateChar(char *haystack, char needle); +int locateCharR(char *haystack, char needle); +char *convertClasicToFtp(char *url); ++int isWithUsername(char *url); +int isValidPort(char *port); + + @@ -94,6 +95,7 @@ +static char *FTP_URL = "ftp://"; +static char *FILE_URL = "file://"; +static unsigned int MAX_PORT = 65535; ++static char *std_out = "/dev/stdout"; + + +int main(int argc, char *argv[]) @@ -105,7 +107,6 @@ + int verbose = 0; /* -1=off 0 = NA 1 =on */ + int force_cache_reload = 0; + int autologin = 1; -+ char *output_file = NULL; + char *ftp_port = NULL; + int retry_wait = -1; + char *end; @@ -117,16 +118,29 @@ + char buf[BUFSIZE + 1]; + int rate_get = 0, rate_put = 0; + int rate_get_incr = -1, rate_put_incr = -1; -+ char *anonymous_pass; ++ char *anonymous_pass=NULL; + char *env; + int passive_mode = -1; + int active_fallback = -1; -+ int interactive = 0; /* if 0 - interactive; 1 -not * -+ * interactive */ -+ int globing = 0; /* if 0 using mput/mget, if 1 -+ * using * put/get to supress -+ * local file * completiotion */ -+ int showEXE=0; ++ /* if 0 - interactive; 1 -not * ++ * interactive */ ++ int interactive = 0; ++ ++ /* if 0 using mput/mget, if 1 * ++ * using * put/get to supress * ++ * local file * completiotion */ ++ int globing = 0; ++ int showEXE=0; ++ ++ /* if 0 no redirection, if 1 redirection to file or to /dev/stdout */ ++ int redirect_output=0; ++ char *output_file = NULL; ++ ++ /* both in lftp and lukemftp is default mode passive, 0 means acitve */ ++ passive_mode=1; ++ ++ /* terminal */ ++ int is_tty=0; + int i; + + e_script[0] = '\0'; @@ -150,7 +164,12 @@ + * environment compatibility + */ + anonymous_pass = getenv("FTPANONPASS"); -+ ++ /* ++ * verbosity ++ */ ++ is_tty= isatty(1); ++ if(is_tty==0) verbose = -1; ++ + if ((env = getenv("FTPMODE")) != NULL) { + if (strcasecmp(env, "passive") == 0) { + passive_mode = 1; @@ -174,6 +193,8 @@ + /* + * Force active mode ftp. + */ ++ passive_mode=0; ++ break; + case 'g': + /* + * Disables file name globbing. @@ -189,6 +210,7 @@ + /* + * Enables packet tracing + */ ++ break; + case 'v': + verbose = 1; /* on */ + break; @@ -229,10 +251,10 @@ + /* + * When auto-fetching files, save the contents in output + */ -+ output_file = optarg; -+ /* -+ * if (strcmp(outfile, "-") == 0) -+ */ ++ redirect_output=1; ++ output_file = optarg; ++ if (strcmp(output_file, "-") == 0) output_file=std_out ; ++ + break; + case 'p': + /* @@ -343,6 +365,7 @@ + break; + case 'x': + showEXE=1; /* show exec string */ ++ break; + default: + printf("unknown character %c \n", ch); + continue; @@ -351,7 +374,7 @@ + argc -= optind; + argv += optind; + -+ if (compat_mode_warning) ++ if (compat_mode_warning && (verbose!=-1)) + fprintf(stderr, + "Wrapper for lftp to simulate compatibility with lukemftp\n"); + @@ -373,13 +396,9 @@ + new_argv[iarg++] = "-p"; + new_argv[iarg++] = strdup(ftp_port); + } -+ + switch (verbose) { + case 1: -+ if (debug == 0) -+ debug = 5; -+ else -+ debug++; ++ debug+=3; + break; + case 0: + debug = 3; @@ -389,11 +408,13 @@ + debug = 0; + } + -+ if (debug) { -+ snprintf(buf, BUFSIZE, "debug %d", debug); -+ buf[BUFSIZE] = '\0'; ++ if (debug) ++ snprintf(buf, BUFSIZE, "debug %d", debug); ++ else ++ snprintf(buf, BUFSIZE, "debug off"); ++ ++ buf[BUFSIZE] = '\0'; + add_to_e_script(buf); -+ } + + /* lukemftp do not support ssl, neither wraper will */ + add_to_e_script("set ftp:ssl-allow false"); @@ -433,7 +454,9 @@ + buf[BUFSIZE] = '\0'; + add_to_e_script(buf); + } -+ ++ if(!passive_mode){ ++ snprintf(buf, BUFSIZE,"set ftp:passive-mode=true"); ++ } + if (upload_path) { + snprintf(buf, BUFSIZE, LFTP_OPEN " %s", upload_path); + buf[BUFSIZE] = '\0'; @@ -469,25 +492,31 @@ + /* + * get command + */ -+ -+ snprintf(get, 100, globing ? -+ (restart_auto_fetching ? "get -c" : "get") : -+ (restart_auto_fetching ? "mget -c" : "mget")); ++ if(redirect_output){ ++ snprintf(get, 100,(restart_auto_fetching ? "get1 -c -o %s" : "get1 -o %s"), output_file); ++ } ++ else{ ++ snprintf(get, 100, globing ? ++ (restart_auto_fetching ? "get -c" : "get") : ++ (restart_auto_fetching ? "mget -c" : "mget")); ++ } + + /* + * open command + */ -+ if (ftp_port == NULL) -+ snprintf(open, 100, LFTP_OPEN); -+ else -+ snprintf(open, 100, LFTP_OPEN " -p %s", ftp_port); + + for (i = 0; i < argc; i++) { + char *buf2 = argv[i]; + char *buf_file = NULL; + char *buf_url = NULL; ++ int hack_port=0; + int is = haveFile(buf2); -+ if (is) { /* url to download file with */ ++ if (ftp_port == NULL) ++ snprintf(open, 100, (anonymous || isWithUsername(buf2) ? LFTP_OPEN : LFTP_COMPAT_MODE_OPEN)); ++ else ++ snprintf(open, 100, "%s -p %s",(anonymous || isWithUsername(buf2) ? LFTP_OPEN : LFTP_COMPAT_MODE_OPEN) , ftp_port); ++ ++ if (is) { /* url to download file with */ + if (isHTML(buf2) || isFile(buf2)) { /* html download, + * only * mget is + * needed */ @@ -496,41 +525,58 @@ + } else { + if (isHost(buf2)) { + buf2 = convertClasicToFtp(buf2); ++ if(ftp_port){ ++ snprintf(open, 100, LFTP_COMPAT_MODE_OPEN); ++ hack_port=1; ++ } + } -+ if (isFTP(buf2)) { /* ftp download is litle bit * -+ * complicated */ ++ if (isFTP(buf2)) { /** ftp download is litle bit ++ * complicated ++ **/ + buf_file = get_file(buf2); + buf_url = get_url(buf2); -+ snprintf(buf, BUFSIZE, "%s %s; %s %s", open, -+ buf_url, get, buf_file); ++ if(!hack_port){ ++ snprintf(open, 100,LFTP_OPEN); ++ if(!ftp_port)snprintf(buf, BUFSIZE, "%s %s; %s %s", open, buf_url, get, buf_file); ++ else snprintf(buf, BUFSIZE, "%s %s:%s; %s %s", open, buf_url,ftp_port, get, buf_file); ++ } ++ else { ++ snprintf(buf, BUFSIZE, "%s %s:%s; %s %s", open, buf_url,ftp_port, get, buf_file); ++ } + add_to_e_script(buf); + } else + printf + ("url open/download handling not implemented with %s\n", + buf2); + } -+ } else { /* no file at end of url */ -+ int port = 0; ++ interactive = 1; ++ } else {/* no file at the end of url, so just open ftp */ ++ int port =0; + if (isFTP(buf2)) { -+ snprintf(buf, BUFSIZE, "user anonymous"); -+ /*add_to_e_script(buf);*/ ++ snprintf(open, 100, LFTP_OPEN); ++ anonymous=1; ++ if(ftp_port) port = atoi(ftp_port); + } else { /* [[user@]localhost [port]] test */ -+ if (i <= argc - 1) { /* some arguments left */ ++ if (i < argc - 1) { /* some arguments left */ + port = isValidPort(argv[1 + i]); -+ snprintf(open, 100, "%s", LFTP_OPEN); ++ } ++ else { ++ if(ftp_port) port = atoi(ftp_port); + } + } -+ if (port) -+ snprintf(buf, BUFSIZE, "%s %s %d", open, buf2, port); ++ if (port){ ++ snprintf(open, 100, (anonymous || isWithUsername(buf2) ? LFTP_OPEN : LFTP_COMPAT_MODE_OPEN)); ++ snprintf(buf, BUFSIZE, "%s %s:%d", open, buf2, port); ++ } + else -+ snprintf(buf, BUFSIZE, "%s %s", open, buf2); ++ snprintf(buf, BUFSIZE, "%s %s", open, buf2); + add_to_e_script(buf); + interactive = 0; + argv += argc; /* delete comands */ + argc = 0; -+ break; /* from FOR loop, ftp is not able to * -+ * download some file and then open url at -+ * * * * * * the end */ ++ break; /* from FOR loop, because ftp is not able to ++ download some file and then open url at ++ the end */ + } + /* + * if (!autologin) printf("autologin is not implemented @@ -562,28 +608,28 @@ +} + +/** -+ * check if retez is in format: (see man ftp) ++ * check if text is in format: (see man ftp) + * ftp:// + * http:// + * file:/// + * host:path -+ * @param char * retez -expecting string end with '\n' ++ * @param char * text -expecting string end with '\n' + * if yes return 1 + * if no return 0 + **/ -+int haveFile(char *retez) ++int haveFile(char *text) +{ + int end = -1; + int i = 0, j = 0, k = 0; + char *tmp = NULL; -+ tmp = retez; -+ if(retez==NULL) return 0; ++ tmp = text; ++ if(text==NULL) return 0; + + /** + * Handle this + * [http://[user[:password]@]host[:port]/path] + **/ -+ if (isHTML(retez)) { ++ if (isHTML(text)) { + tmp += strlen(HTML_URL); + end = strlen(tmp); + if (strncmp(tmp + end - 1, "/", 1) == 0) @@ -599,32 +645,28 @@ + * Handle this + * ftp://[user[:password]@]host[:port]/path[/]] + **/ -+ if (isFTP(retez)) { ++ if (isFTP(text)) { + tmp += strlen(FTP_URL); + end = strlen(tmp); + if (strncmp(tmp + end - 1, "/", 1) == 0) + return 0; /* is directory ! */ -+ i = locateCharR(tmp, '/'); -+ if (i != end - 1 && i != -1) -+ return 1; /* is there any character after /? */ -+ else -+ return 0; ++ /* is there any character after /? */ ++ i = locateCharR(tmp, '/'); ++ return (i != end - 1 && i != -1); + } + + /** + * Handle this + * [file:///path] + **/ -+ if (isFile(retez)) { ++ if (isFile(text)) { + tmp += strlen(FILE_URL); + end = strlen(tmp); + if (strncmp(tmp + end - 1, "/", 1) == 0) + return 0; /* is directory ! */ -+ i = locateCharR(tmp, '/'); -+ if (i != end - 1 && i != -1) -+ return 1; /* is there any character after /? */ -+ else -+ return 0; ++ /* is there any character after /? */ ++ i = locateCharR(tmp, '/'); ++ return (i != end - 1 && i != -1); + } + + /** @@ -767,7 +809,7 @@ + **/ +int isFTP(char *url) +{ -+ return strstr(url, FTP_URL) == NULL ? 0 : 1; ++ return !strncmp(url, FTP_URL, strlen(FTP_URL)); +} + +/** @@ -776,7 +818,7 @@ + **/ +int isHTML(char *url) +{ -+ return strstr(url, HTML_URL) == NULL ? 0 : 1; ++ return !strncmp(url, HTML_URL, strlen(HTML_URL)); +} + +/** @@ -824,13 +866,29 @@ + return colon == -1 || colon == strlen(url) ? 0 : 1; +} + ++int isWithUsername(char *url) ++{ ++ int i1, i2, i3, i4; ++ if (isFTP(url)) url += strlen(FTP_URL); ++ ++ i1 = locateChar(url, '@'); ++ i2 = locateChar(url, ':'); ++ i3 = locateChar(url, '/'); ++ i4 = locateChar(url, '['); ++ ++ return (i1 != -1 && ++ (i2 == -1 || i1 < i2) && ++ (i3 == -1 || i1 < i3) && ++ (i4 == -1 || i1 < i4)); ++} ++ +/** + * return 1 if url begin with FILE_URL string + * return 0 otherwise + **/ +int isFile(char *url) +{ -+ return strstr(url, FILE_URL) == NULL ? 0 : 1; ++ return !strncmp(url, FILE_URL, strlen(FILE_URL)); +} + +/** @@ -998,3 +1056,22 @@ + freeaddrinfo(res); + return 1; +} +--- src/Makefile.am ++++ src/Makefile.am +@@ -1,7 +1,7 @@ + localedir = $(datadir)/locale + pkgverlibdir = $(pkglibdir)/$(VERSION) + +-bin_PROGRAMS = lftp ++bin_PROGRAMS = lftp lftp_wrapper + bin_SCRIPTS = lftpget + pkgdata_SCRIPTS = import-ncftp import-netscape verify-file convert-netscape-cookies + noinst_SCRIPTS = ftpget +@@ -10,6 +10,7 @@ + example1.cc example2.cc + + lftp_SOURCES = lftp.cc complete.h complete.cc lftp_rl.c lftp_rl.h getdate.y getdate.h ++lftp_wrapper_SOURCES = lftp_wrapper.c + + #ftpget_SOURCES = ftpget.cc + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun...