Hi folks!

This one seems to be a duplicate of a previous bug report for bb
1.3.1/1.4.1, here's the link:

http://www.busybox.net/lists/busybox/2007-February/026289.html

Currently (latest svn version), I'm unable to upload files onto my
busybox installation running busybox httpd.

The problem is, that the `cat` command never finishes after it wrote
the uploaded file successfully to the temporary location, that means
uploading works, but after the upload has finished, `cat` doesn't quit.

I also tried `dd of=$TMPOUT` => didn't work either (hangs after upload
has finished).

As mentioned in the above link, I had a similar problem a few months ago
and have looked at the patch posted back then from Denis, but wasn't
able to merge it to the current httpd.c (don't even know if it would
have made sense ;) ).

Any ideas, what's going wrong here?

The sample cgi-script for uploading the file follows:

----------[ uploadconfig.cgi ] -------------------------

#!/bin/sh

# parameters:
# $1 - file destination
upload_file()
{
  TMPOUT=$(mktemp /tmp/XXXXXX)

  # upload the file to $TMPOUT
  cat >$TMPOUT

  # get the line count and remove the first 4 and the last 2 lines
  # of the uploaded file (these lines contain boundery and content-type
  # information only)
  LINE_COUNT=$(wc -l $TMPOUT | awk "-F " '{ print $1 }')
  if [ $LINE_COUNT -le 6 ]; then
    RETURN=1
  else
    UPPER_BOUND=$(( $LINE_COUNT - 4 ))
    LOWER_BOUND=$(( $UPPER_BOUND - 2 ))
    tail -n $UPPER_BOUND $TMPOUT | head -n $LOWER_BOUND > $1
    RETURN=$?
  fi

  rm -f $TMPOUT

  if [ "$RETURN" = "0" ]; then
    echo "<p class=\"statusok\">Upload successful.</p>"
  else
    echo "<p class=\"statusfail\">Error while uploading the file!</p>"
  fi

  return $RETURN
}


echo "<h2>Upload configuration file</h2>"

if [ "$REQUEST_METHOD" = "POST" ]; then
  if upload_file /system/etc/lxtc-config; then
    echo "<center><pre>"
    cat /system/etc/lxtc-config
    echo "</pre></center>"
  fi
else
  echo "<form name=\"test\" method=\"post\"
action=\"/cgi-bin/uploadconfig.cgi\" enctype=\"multipart/form-data\">"
  echo "<input type=\"file\" name=\"configfile\" maxlength=\"10240\" />"
  echo "<input type=\"submit\" value=\"Upload configuration file\" />"
  echo "</form>"
fi
---------------------------------- 8< --------------------

ciao,
-- 
Alexander Griesser (Netzwerkadministration)
E-Mail: [EMAIL PROTECTED] | Web: http://www.lkh-vil.or.at
KABEG LKH Villach | Nikolaigasse 43 | 9500 Villach
Tel.:   +43 4242 208 3061 | Fax.:   +43 4242 971 3061
_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to