curl: no password sent for ftp sites

Bug reports and enhancement requests
Post Reply
basinilya
Posts: 16
Joined: Sat Dec 25, 2010 7:17 pm

curl: no password sent for ftp sites

Post by basinilya »

Flashgot starts curl with the following params:

Code: Select all

/usr/bin/curl -C - -L -O ftp://user@foo.org/file
No password, although I entered one in firefox.

here's output:

Code: Select all

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (67) Access denied: 530
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101211 Firefox/3.6.13
User avatar
Giorgio Maone
Site Admin
Posts: 9524
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: curl: no password sent for ftp sites

Post by Giorgio Maone »

Not sure whether this can be fixed. Will look into that.
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
basinilya
Posts: 16
Joined: Sat Dec 25, 2010 7:17 pm

Re: curl: no password sent for ftp sites

Post by basinilya »

Is it because the plugin doesn't know the ftp password?
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101211 Firefox/3.6.13
User avatar
Giorgio Maone
Site Admin
Posts: 9524
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: curl: no password sent for ftp sites

Post by Giorgio Maone »

basinilya wrote:Is it because the plugin doesn't know the ftp password?
Yes, more or less.
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
basinilya
Posts: 16
Joined: Sat Dec 25, 2010 7:17 pm

Re: curl: no password sent for ftp sites

Post by basinilya »

flashgotService.patch

Code: Select all

--- /home/il/Downloads/flashgot/components/flashgotService.js	2010-12-16 16:17:52.000000000 +0300
+++ components/flashgotService.js	2010-12-26 14:21:15.000000000 +0300
@@ -677,10 +677,25 @@
       try {
         uri = IOS.newURI(l.href, null, null);
         if (l.userPass && l.userPass.indexOf(":") > -1) continue;
+        if (uri.scheme == "ftp") {
+          if (uri.username) {
+            var WindowWatcherService = CC["@mozilla.org/embedcomp/window-watcher;1"].getService(CI.nsIWindowWatcher);
+            let _aprompter = WindowWatcherService.getNewAuthPrompter(null).QueryInterface(CI.nsIAuthPrompt);
+            var ftpport = (uri.port < 0 || uri.port == 21 ? "" : ":" + uri.port);
+            var realm = uri.scheme + "://" + uri.username + "@" + uri.host + ftpport;
+
+            if (_aprompter.promptPassword("password", "password for " + realm, realm, _aprompter.SAVE_PASSWORD_NEVER, upwd)) {
+              l.href = uri.scheme + "://" + uri.username + ":" + upwd.value + "@" + 
+                       uri.host + ftpport + uri.spec.substring(uri.prePath.length);
+              this.log("Authentication data for " + uri + " added.");
+            }
+          }
+        } else {
         httpAuthManager.getAuthIdentity(uri.scheme, uri.host, uri.port < 0 ? (uri.scheme == "https" ? 443 : 80) : uri.port, null, null, uri.path, udom, uname, upwd);
         this.log("Authentication data for " + uri + " added.");
         l.href = uri.scheme + "://" + uname.value + ":" + upwd.value + "@" + 
                  uri.host + (uri.port < 0 ? "" : (":" + uri.port)) + uri.spec.substring(uri.prePath.length);
+        }
       } catch(e) {}
     }
   },
If password is stored, the password prompt won't appear, but will return the password. If not stored, the prompt will appear, you input and press OK,
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101211 Firefox/3.6.13
User avatar
Giorgio Maone
Site Admin
Posts: 9524
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: curl: no password sent for ftp sites

Post by Giorgio Maone »

Thank you for the patch :)
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
User avatar
Giorgio Maone
Site Admin
Posts: 9524
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: curl: no password sent for ftp sites

Post by Giorgio Maone »

Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
basinilya
Posts: 16
Joined: Sat Dec 25, 2010 7:17 pm

Re: curl: no password sent for ftp sites

Post by basinilya »

silently fails, no terminal window

Code: Select all

*** FlashGot 1.2.8rc2 started at Sun, 26 Dec 2010 17:16:15 GMT ***
Recent post info found: [xpconnect wrapped (nsISupports, nsIHttpChannel, nsIUploadChannel, nsIChannel)], http://static.rutracker.org/favicon.ico VS ftp://user@ftp.foo.ru/jasp/jasperserver-pro-3.5.1-linux-installer.bin, false, false
Adding authentication info
Delayed Runner error: ReferenceError: password is not defined, ([object Array])@file:///home/il/.mozilla/firefox/69l263hw.default/extensions/%7B19503e42-ca3c-4c27-b1e2-9cdb2170ee34%7D/components/flashgotService.js:694
([object Array],0,[object Object])@file:///home/il/.mozilla/firefox/69l263hw.default/extensions/%7B19503e42-ca3c-4c27-b1e2-9cdb2170ee34%7D/components/flashgotService.js:612
([object Object])@file:///home/il/.mozilla/firefox/69l263hw.default/extensions/%7B19503e42-ca3c-4c27-b1e2-9cdb2170ee34%7D/components/flashgotService.js:603
()@chrome://flashgot/content/RedirectContext.js:78
()@chrome://flashgot/content/RedirectContext.js:54
()@file:///home/il/.mozilla/firefox/69l263hw.default/extensions/%7B19503e42-ca3c-4c27-b1e2-9cdb2170ee34%7D/components/flashgotService.js:601
([object XPCWrappedNative_NoHelper])@file:///home/il/.mozilla/firefox/69l263hw.default/extensions/%7B19503e42-ca3c-4c27-b1e2-9cdb2170ee34%7D/components/flashgotService.js:754

Code: Select all

            prompter.promptPassword("Password", realm + " " + password, realm, prompter.SAVE_PASSWORD_NEVER, upwd))

replace password with "password"
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101211 Firefox/3.6.13
User avatar
Giorgio Maone
Site Admin
Posts: 9524
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: curl: no password sent for ftp sites

Post by Giorgio Maone »

Fixed in latest development build, please check, thanks.
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
basinilya
Posts: 16
Joined: Sat Dec 25, 2010 7:17 pm

Re: curl: no password sent for ftp sites

Post by basinilya »

working
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101211 Firefox/3.6.13
basinilya
Posts: 16
Joined: Sat Dec 25, 2010 7:17 pm

Re: curl: no password sent for ftp sites

Post by basinilya »

wait! Now username is undefined.
wrong case:
uri.userName
uri.username
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101211 Firefox/3.6.13
User avatar
Giorgio Maone
Site Admin
Posts: 9524
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: curl: no password sent for ftp sites

Post by Giorgio Maone »

Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
basinilya
Posts: 16
Joined: Sat Dec 25, 2010 7:17 pm

Re: curl: no password sent for ftp sites

Post by basinilya »

working
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101211 Firefox/3.6.13
Post Reply