CGI processing Postscript - Setup

This is a discussion on CGI processing Postscript - Setup ; I am trying to get working a calendar program I have used in the past, on a new Mandriva 2008 installation. It opens O.K. in Apache as HTML, but if I specify Postscript output, it tries to download the cgi ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: CGI processing Postscript

  1. CGI processing Postscript

    I am trying to get working a calendar program I have used in the past, on a
    new Mandriva 2008 installation. It opens O.K. in Apache as HTML, but if I
    specify Postscript output, it tries to download the cgi file. After a bit
    of hunting around, I installed gv to handle the Postscript, but no luck.
    Perhaps I still need to set up the machinery to handle
    Application/Postscript? If so, what package do I need? What is a better
    place to ask?

    There are no clues in Apache's access_log or errors_log.

    TIA,

    Doug.

  2. Re: CGI processing Postscript

    On Wed, 31 Oct 2007 01:32:54 +1100, Doug Laidlaw wrote:

    > I am trying to get working a calendar program I have used in the past, on a
    > new Mandriva 2008 installation. It opens O.K. in Apache as HTML, but if I
    > specify Postscript output, it tries to download the cgi file.


    What specifically is "it"? Your browser? What is Apache sending as
    headers? Did you setup Apache to send the application/postscript type
    headers? If it does, then Apache is done with its job. If it's not, then
    you should add it.

    For 2.2.6, that's in mime_module, make sure
    TypesConfig /etc/apache2/mime.types

    is set, which contains

    application/postscript eps ps

    on my system. Old Apache is likely the same or similar.


    > After a bit
    > of hunting around, I installed gv to handle the Postscript, but no luck.


    In Firefox, it will likely say "file xyz is of type application/postcript
    .... what should Firefox do with this file?" The first time you encounter
    it. You app needs to respect /etc/mailcap and do what is in there. Not all
    do, but I believe this is the convention. (man mailcap)


    > Perhaps I still need to set up the machinery to handle
    > Application/Postscript?


    Well, the config files...

    >
    > There are no clues in Apache's access_log or errors_log.


    Use something like curl to see what's being sent:

    curl -v http://your.host/file.ps

    and look at the headers for the mime type. Example:

    [ jayjwa@vdrl:~>] cd public_html/
    [ jayjwa@vdrl:~/public_html>] nano test.txt
    [ jayjwa@vdrl:~/public_html>] cat test.txt | mps > test.ps
    [ jayjwa@vdrl:~/public_html>] file test.ps
    test.ps: PostScript document text conforming at level 3.0
    [ jayjwa@vdrl:~/public_html>] curl -v https://vdrl.ath.cx/~jayjwa/test.ps
    * About to connect() to vdrl.ath.cx port 443 (#0)
    * Trying 192.168.10.76... connected
    * Connected to vdrl.ath.cx (192.168.10.76) port 443 (#0)
    * SSL certificate verify ok.
    > GET /~jayjwa/test.ps HTTP/1.1
    > User-Agent: curl/7.17.1 (i686-pc-linux-gnu) libcurl/7.17.1 OpenSSL/0.9.8g zlib/1.2.3 c-ares/1.4.0 libidn/1.2 libssh2/0.17
    > Host: vdrl.ath.cx
    > Accept: */*
    >

    < HTTP/1.1 200 OK
    < Date: Sun, 11 Nov 2007 14:18:59 GMT
    < Server: Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.8g DAV/2 PHP/5.2.4
    < Last-Modified: Sun, 11 Nov 2007 14:18:23 GMT
    < ETag: "7fe2a-33a-e36ee9c0"
    < Accept-Ranges: bytes
    < Content-Length: 826
    < Content-Type: application/postscript
    <
    %!PS-Adobe-3.0
    %%Creator: mps v2.1.0 Copyright (C) 1999, Richard R. Urena. All rights reserved.
    %%CreationDate: Sun Nov 11 09:18:23 2007

    %%DocumentFonts: Courier
    %%LanguageLevel: 1
    %%Orientation: Portrait
    %%Pages: (atend)
    %%PageOrder: Ascend
    %%EndComments

    %BeginProlog
    /S {moveto show} bind def
    /P {showpage} bind def
    %EndProlog

    %%BeginSetup
    % Change the encoding vector to Latin-1 (ISO-8859-1)
    /Courier findfont
    dup length dict begin
    {1 index /FID ne {def} {pop pop} ifelse} forall
    /Encoding ISOLatin1Encoding def
    currentdict
    end
    /Courier-ISOLatin1 exch definefont pop
    % Scale to the desired size
    /Courier-ISOLatin1 findfont 10 scalefont setfont
    %%EndSetup

    % ------ begin file: (stdin) ------ %

    %%Page: 1
    (Hey, this is a postscript test! OK.) 72.0 714.9 S
    (All done now.) 72.0 690.9 S
    P

    %%Trailer
    %%Pages: 1
    %%EOF
    * Connection #0 to host vdrl.ath.cx left intact
    * Closing connection #0
    * SSLv3, TLS alert, Client hello (1):



    CGI's (should) specify
    the mime type in their headers. If not, Apache will guess, and it could
    guess wrong. After that, you need an app that will respect mailcap, or
    provide the same functionality. Be careful with auto-processing
    Postscript. I've been told it can exec commands (security concerns), but
    haven't actually seen a real attack using it.

    In /etc/mailcap,

    # Postscript
    application/postscript; \
    gv %s; \
    test=test -n "$DISPLAY"; \
    description=postscript document


    using FF to access the same URL, it pops up a box with the "What should
    Firefox ..." dialog with the default set to 'gv'. Hitting return displays
    the test document in gv. I'm not sure about other apps respecting
    /etc/mailcap.



    --
    [** America, the police state **]
    Whoooose! What's that noise? Why, it's US citizen's
    rights, going down the toilet with Bush flushing.
    http://www.wired.com/politics/securi...007/08/wiretap
    http://www.hermes-press.com/police_state.htm


+ Reply to Thread