Project

General

Profile

[Solved] [CGI] groff causes segementation fault

Added by N_BaH over 2 years ago

hi,

I'm writing a simple "man to html" CGI script :

#!/bin/bash

printf 'Content-type: text/html\n\n'
echo '<!doctype html>'
exec 2>&1
set -x
zcat /usr/share/man/man1/man.1.gz | groff -man -Thtml -
set +x

here's what I get on Archlinux:

+ zcat /usr/share/man/man1/man.1.gz
+ groff -man -Thtml - /srv/http/cgi-bin/test: line 7: 94180 Done zcat /usr/share/man/man1/man.1.gz 94181 Segmentation fault (core dumped) | groff -man -Thtml -
+ set +x

I have other CGI scripts that work as intended.

# here's /etc/lighttpd/lighttpd.conf :# See /usr/share/doc/lighttpd
# and http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions

server.port        = 80
server.username        = "http" 
server.groupname    = "http" 
server.document-root    = "/srv/http" 
server.errorlog        = "/var/log/lighttpd/error.log" 
dir-listing.activate    = "enable" 
index-file.names    = ( "index.html", "cgi-bin/accueil" )
mimetype.assign        = (
                ".html" => "text/html",
                ".txt" => "text/plain",
                ".css" => "text/css",
                ".js" => "application/x-javascript",
                ".jpg" => "image/jpeg",
                ".jpeg" => "image/jpeg",
                ".gif" => "image/gif",
                ".png" => "image/png",
                "" => "application/octet-stream" 
            )
server.modules += ( "mod_userdir" )
userdir.path = "public_html" 

server.modules += ( "mod_cgi" )
$HTTP["url"] =~ "^(/~[^/]+)?/cgi-bin/" { #this is default config found on internet; it works with other CGI shell scripts.
    cgi.assign = ("" => "")
}

# PDF view files instead of downloading
#https://azgtech.wordpress.com/2011/01/26/force-download-pdf-using-lighttpd/
#https://stackoverflow.com/questions/6293893/how-do-i-force-files-to-open-in-the-browser-instead-of-downloading-pdf
server.modules += ( "mod_setenv" )
$HTTP["url"] =~ "(.*)\.pdf" {
    mimetype.assign = (".pdf" =>"application/pdf")
    setenv.add-response-header = ( "Content-Disposition" => "inline" )
}
# Redirection
$HTTP["host"] == "machine_name" {
    $HTTP["url"] =~ "^/$" {
        url.redirect = ( "" => "/cgi-bin/home" )
        url.rediect-code = 302
    }
}


Replies (2)

RE: [CGI] groff causes segementation fault - Added by gstrauss over 2 years ago

Check env | sort in your script. Perhaps groff expects an environment variable to be present which is not present.
Try running groff with an empty environment (env -) to confirm.

RE: [CGI] groff causes segementation fault - Added by N_BaH over 2 years ago

silly me !
I remember that I tested PATH variable, though.
I probably didn't refresh browser's cache.

groff uses so many "sub programs"...

thank you.

btw, how do I mark thread as solved ? by editing first message's title ?

    (1-2/2)