Menu

#5176 download from server not working.

1.890
closed-fixed
None
7
2018-10-08
2018-08-12
grhayes
No

fetch.cgi not being properly redirected to download files. Instead of the file you want to download a file called fetch.cgi is downloaded wich is not actually fetch.cgi but an html file about 5k in size meant to redirect to the proper download.

I have two systems one is running ubuntu 18.04 the other is running 18.04.1 the one running 18.04 works fine the one running 18.04.1 is not working correctly. Both are running version 1.890
From the working system log:
IPADDRESS - tristan [11/Aug/2018:19:19:14 -0500] "GET /updown/fetch.cgi?fetch=%2Fvar%2Fwww%2Fhtml&show=0 HTTP/1.1" 302 0
IPADDRESS - tristan [11/Aug/2018:19:19:16 -0500] "GET /updown/fetch.cgi/var/www/html.zip?unzip=1 HTTP/1.1" 200 13744383
From the not working system log:
IPADDRESS - admin01 [11/Aug/2018:19:20:34 -0500] "GET /updown/fetch.cgi?fetch=%2Fvar%2Fwww%2Fhtml&show=1 HTTP/1.1" 302 0
IPADDRESS - admin01 [11/Aug/2018:19:20:34 -0500] "GET /updown/fetch.cgi/var/www/html.zip?unzip=1 HTTP/1.1" 200 356099
IPADDRESS - admin01 [11/Aug/2018:19:20:34 -0500] "GET /updown/fetch.cgi HTTP/1.1" 200 5080

Related

Bugs: #5176

Discussion

  • Jamie Cameron

    Jamie Cameron - 2018-08-12

    That unsual - what does the downloaded fetch.cgi file contain exactly?

     
    • grhayes

      grhayes - 2018-09-04

      It contained the contents of the fetch.cgi file. See below. It turns out
      the update and upgrade removed and shut down several required things like
      zip.
      The issue is thus with Ubuntu and not you. That said the application could
      have made sure the required software was installed and alerted the user in
      this case myself as that it was not available.

      !/usr/bin/perl

      Output one file for download

      require './updown-lib.pl';
      &ReadParse();
      &error_setup($text{'fetch_err'});
      $can_fetch || &error($text{'fetch_ecannot'});

      Validate filename

      $file = $ENV{'PATH_INFO'} || $in{'fetch'};
      if ($file !~ /^([a-z]:)?\// && $can_dirs[0] ne "/") {
      $file = "$can_dirs[0]/$file";
      }
      $file || &error($text{'fetch_efile'});
      if ($file =~ /^(.*).zip$/ && $in{'unzip'}) {

      Remove .zip extension

      $file = $1;
      }
      -r $file || -d $file || &error($text{'fetch_eexists2'});
      &can_write_file($file) ||
      &error(&text('fetch_eaccess', "$file", $!));
      if (-d $file && !&has_command("zip")) {
      &error($text{'fetch_ezip'});
      }
      if ($file eq "/" || $file =~ /^[a-z]:\/$/) {
      &error($text{'fetch_eroot'});
      }

      if ($ENV{'PATH_INFO'}) {

      Switch to the correct user

      if ($can_mode == 3) {
      @uinfo = getpwnam($remote_user);
      &switch_uid_to($uinfo[2], $uinfo[3]);
      }
      elsif ($can_mode == 1 && @can_users == 1) {
      @uinfo = getpwnam($can_users[0]);
      &switch_uid_to($uinfo[2], $uinfo[3]);
      }

      if (-d $file) {

      Zip up the whole directory

      ($shortfile = $file) =~ s/^.*\///g;
      $shortfile =~ s/\s+//g;
      $temp = &transname($shortfile.".zip");
      $out = &backquote_command("cd ".quotemeta($file).
      " && zip -r ".quotemeta($temp)." .");
      if ($?) {
      &error(&text('fetch_ezipcmd',
      "".&html_escape($out).""));
      }
      @st = stat($temp);
      print "Content-length: $st[7]\n";
      print "Content-type: application/zip\n\n";
      open(FILE, $temp);
      unlink($temp);
      while(read(FILE, $buffer, 1000000)) {
      print("$buffer");
      }
      close(FILE);
      }
      else {

      Work out the type

      &open_readfile(FILE, $file) ||
      &error(&text('fetch_eopen', $!));
      if ($fetch_show) {
      $type = &guess_mime_type($file, undef);
      if (!$type) {

      See if it is really text

      $out = &backquote_command("file ".
      quotemeta(&resolve_links($file)));
      $type = "text/plain" if ($out =~ /text|script/);
      }
      }
      else {
      print "Content-Disposition: Attachment\n";
      }

      Send it

      $type ||= "application/octet-stream";
      if (!$fetch_show) {
      print "Content-Disposition: Attachment\n";
      }
      @st = stat($file);
      print "Content-length: $st[7]\n";
      print "X-Content-Type-Options: nosniff\n";
      print "Content-type: $type\n\n";
      while(read(FILE, $buffer, 1000000)) {
      print("$buffer");
      }
      close(FILE);
      }

      Switch back to root

      &switch_uid_back();
      }
      else {

      Save file in config

      if ($module_info{'usermin'}) {
      &lock_file("$user_module_config_directory/config");
      $userconfig{'fetch'} = $file;
      $userconfig{'show'} = $in{'show'};
      &write_file("$user_module_config_directory/config", \%userconfig);
      &unlock_file("$user_module_config_directory/config");
      }
      else {
      &lock_file("$module_config_directory/config");
      $config{'fetch_'.$remote_user} = $file;
      $config{'show_'.$remote_user} = $in{'show'};
      &write_file("$module_config_directory/config", \%config);
      &unlock_file("$module_config_directory/config");
      }

      Redirect to nice URL

      $file =~ s/#/%23/g;
      if (-d $file) {
      &redirect("fetch.cgi".$file.".zip?unzip=1");
      }
      else {
      &redirect("fetch.cgi".$file);
      }
      }

      On Sun, Aug 12, 2018 at 12:52 PM, Jamie Cameron jcameron@users.sourceforge.net wrote:

      That unsual - what does the downloaded fetch.cgi file contain exactly?

      Status: open
      Group: 1.890
      Created: Sun Aug 12, 2018 12:24 AM UTC by grhayes
      Last Updated: Sun Aug 12, 2018 12:24 AM UTC
      Owner: Jamie Cameron

      fetch.cgi not being properly redirected to download files. Instead of the
      file you want to download a file called fetch.cgi is downloaded wich is not
      actually fetch.cgi but an html file about 5k in size meant to redirect to
      the proper download.

      I have two systems one is running ubuntu 18.04 the other is running
      18.04.1 the one running 18.04 works fine the one running 18.04.1 is not
      working correctly. Both are running version 1.890

      From the working system log:
      IPADDRESS - tristan [11/Aug/2018:19:19:14 -0500] "GET
      /updown/fetch.cgi?fetch=%2Fvar%2Fwww%2Fhtml&show=0 HTTP/1.1" 302 0
      IPADDRESS - tristan [11/Aug/2018:19:19:16 -0500] "GET
      /updown/fetch.cgi/var/www/html.zip?unzip=1 HTTP/1.1" 200 13744383
      From the not working system log:
      IPADDRESS - admin01 [11/Aug/2018:19:20:34 -0500] "GET
      /updown/fetch.cgi?fetch=%2Fvar%2Fwww%2Fhtml&show=1 HTTP/1.1" 302 0
      IPADDRESS - admin01 [11/Aug/2018:19:20:34 -0500] "GET
      /updown/fetch.cgi/var/www/html.zip?unzip=1 HTTP/1.1" 200 356099
      IPADDRESS - admin01 [11/Aug/2018:19:20:34 -0500] "GET /updown/fetch.cgi
      HTTP/1.1" 200 5080


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/webadmin/bugs/5176/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #5176

  • Ilia Rostovtsev

    Ilia Rostovtsev - 2018-09-05

    Before I was going to write that everything works okay I did few more tests that really went okay; but at the moment I've chosen to download a directory, like /root/.config and check radio to Yes - show it in the browser if possible - I got fetch.cgi in response, with error message inside saying Failed to download file : No filename entered.

    However, to work around the problem switching radio to No made things work as expected.

    I will tackle it around a little bit more to make sure things go smooth under all conditions.

    Thank you for pointing this out.

     
  • Ilia

    Ilia - 2018-10-08

    Okay, that was a global download bug in the theme. All downloads across UI are working fine now, with the latest commit. You're welcome to try latest development version.

    Thank you for reporting. :)

     
  • Ilia

    Ilia - 2018-10-08
    • status: open --> closed-fixed
     

Log in to post a comment.