Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning large binary to browswer via CGI

Status
Not open for further replies.
Oct 8, 2012
5
0
0
US
I have a fairly simple perl cgi script that generates a large ISO file (4GB). Perl is working fine from a CGI perspective because simple html generated by the perl cgi works fine. When executed at the shell, the perl script generates the large ISO file perfectly. However, when run via cgi, what is returned to the browser is a small 34k file.

I suspect either a timeout from apache, a size limitation, or both.

The html generated by perl is as follows:

Content-type: application/octet-stream;
Content-Disposition: attachment; filename="kickstart.iso"
Content-Transfer-Encoding: binary

The binary data follows immediately

I'm fairly green at HTML/CGI so any assistance might be appreciated.
 
Here's the perl code. Binmode is being used.

#!/usr/bin/perl

print "Content-type: application/octet-stream\n";
print "Content-Disposition: attachment\; filename=\"kickstart.iso\"\n";
print "Content-Transfer-Encoding: binary\n\n";

binmode(STDOUT);

exec("mkisofs -r -T -J -V \"Redhat KSBoot\" -b pub/isolinux/isolinux.bin -c pub/isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -v .");
 
Hi

I was able to reproduce the problem.

But I am quite sure the problem is not with the transfer. If I redirect [tt]exec[teal]([/teal][green]"mkisofs --all-that-stuff > /tmp/dolfantimmy.iso"[/green][teal]);[/teal][/tt], the resulted file will be also 34816 byte long.

As [tt]mkisofs[/tt]'s STDERR is not redirected, it gets written to the web server's error log file. There is a line :
error_log said:
[Mon Oct 08 19:43:00 2012] [error] [client 192.168.2.81] mkisofs: Permission denied. Error opening boot image file 'pub/isolinux/isolinux.bin' for update.
If I set write permission on the pub/isolinux/ directory and the isolinux.bin file for the web server's user, the error message disappears and the downloaded file's size seems to be correct.

I have no experience with [tt]mkisofs[/tt], but I would give a try to the above.


Feherke.
[link feherke.github.com/][/url]
 
Thanks so much for trying to help. Essentially the mkisofs is building a kickstart installation cd image.

I suspect you have a permissions issue on your side. The above perl script is called iso.pl If I execute the following....

perl ./iso.pl > foo.iso

a 4GB is generated as I would suspect.

 
Hi

dolfantimmy said:
If I execute the following....

perl ./iso.pl > foo.iso

a 4GB is generated as I would suspect.
Also if you [tt]su - webserveruser[/tt] first ? ( I mean, become to user with who's permissions the web server runs. Search the configuration files for [tt]User[/tt] directive to find out the given user. )


Feherke.
[link feherke.github.com/][/url]
 
Hi

dolfantimmy said:
I am running as root
You mean, you have a [tt]User root[/tt] directive in your web server configuration ? You read the warning before setting that, right ?

httpd documentation said:
Security
Don't set [tt]User[/tt] (or [tt]Group[/tt]) to root unless you know exactly what you are doing, and what the dangers are.
( Apache HTTP Server Version 2.2 Documentation | Apache MPM Common Directives | User Directive )

Anyway, one thing you can still do : check your web server's logs.

Feherke.
[link feherke.github.com/][/url]
 
Feherke,

I must have overlooked your suggestion regarding the write bit on isolinux directory isolinux.bin file. That solved the problem. Thanks a TON!!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top