+ Some changes from start-web-server

+ Add CGI support
This commit is contained in:
mainzelm 2004-05-24 12:00:34 +00:00
parent 1374c26247
commit ae913b3b90
1 changed files with 24 additions and 14 deletions

View File

@ -11,10 +11,8 @@ exec scsh -lel SSAX-4.9/load.scm -lel sunet-2.1/load.scm -dm -o surflet-server -
httpd-make-options httpd-make-options
httpd-basic-handlers httpd-basic-handlers
httpd-file-directory-handlers httpd-file-directory-handlers
; cgi-server httpd-cgi-handlers
; seval-handler httpd-seval-handlers
; rman-gateway
; info-gateway
surflet-handler surflet-handler
surflet-handler/options surflet-handler/options
let-opt let-opt
@ -29,6 +27,7 @@ exec scsh -lel SSAX-4.9/load.scm -lel sunet-2.1/load.scm -dm -o surflet-server -
(format #f (format #f
"Usage: start-surflet-server "Usage: start-surflet-server
[-h DIR | --htdocs-dir=DIR] [-s DIR | --surflet-dir=DIR] [-h DIR | --htdocs-dir=DIR] [-s DIR | --surflet-dir=DIR]
[--cgi-bin-dir=DIR]
[-i DIR | --images-dir=DIR] [-p NUM | --port=NUM] [-i DIR | --images-dir=DIR] [-p NUM | --port=NUM]
[-l FILE | --log-file-name=FILE] [-r NUM | --requests=NUM] [-l FILE | --log-file-name=FILE] [-r NUM | --requests=NUM]
[--help] [--help]
@ -36,14 +35,14 @@ exec scsh -lel SSAX-4.9/load.scm -lel sunet-2.1/load.scm -dm -o surflet-server -
with with
htdocs-dir directory of html files (default: root/htdocs) htdocs-dir directory of html files (default: root/htdocs)
surflet-dir directory of SUrflet files (default: root/surflets) surflet-dir directory of SUrflet files (default: root/surflets)
cgi-bin-dir directory of cgi files (default: root/cgi-bin)
images-dir directory of images files (default: root/img) images-dir directory of images files (default: root/img)
port port server is listening to (default: 8080) port port server is listening to (default: 8080)
log-file-name directory where to store the logfile in CLF log-file-name directory where to store the logfile in CLF
(default: /tmp/httpd.log) (default: /tmp/httpd.log)
requests maximal amount of simultaneous requests (default 5) requests maximal amount of simultaneous requests (default 5)
--help show this help --help show this help
"))
NOTE: This is the SUrflet-server. It does not support cgi-bin.~%"))
(define (display-usage) (define (display-usage)
(display (usage) (current-error-port)) (display (usage) (current-error-port))
@ -83,6 +82,9 @@ exec scsh -lel SSAX-4.9/load.scm -lel sunet-2.1/load.scm -dm -o surflet-server -
(surflet-dir-option (surflet-dir-option
(option '(#\s "surflet-dir") #t #f (option '(#\s "surflet-dir") #t #f
(absolute-file-option-proc 'surflet-dir))) (absolute-file-option-proc 'surflet-dir)))
(cgi-bin-dir-option
(option '(#\c "cgi-bin-dir") #t #f
(absolute-file-option-proc 'cgi-bin-dir)))
(images-dir-option (images-dir-option
(option '(#\i "images-dir") #t #f (option '(#\i "images-dir") #t #f
(absolute-file-option-proc 'images-dir))) (absolute-file-option-proc 'images-dir)))
@ -101,6 +103,7 @@ exec scsh -lel SSAX-4.9/load.scm -lel sunet-2.1/load.scm -dm -o surflet-server -
(display-usage))))) (display-usage)))))
(args-fold arg-list (args-fold arg-list
(list htdocs-dir-option surflet-dir-option (list htdocs-dir-option surflet-dir-option
cgi-bin-dir-option
images-dir-option port-option images-dir-option port-option
log-file-name-option requests-option log-file-name-option requests-option
help-option) help-option)
@ -128,34 +131,38 @@ exec scsh -lel SSAX-4.9/load.scm -lel sunet-2.1/load.scm -dm -o surflet-server -
(main `(main ,@(car args))) (main `(main ,@(car args)))
(main '(main)))) (main '(main))))
(define (become-nobody-if-root)
(cond ((zero? (user-uid))
(set-gid (->gid "nobody"))
(set-uid (->uid "nobody")))))
(define (main args) (define (main args)
(with-cwd (with-cwd
(file-name-directory (car args)) (file-name-directory (car args))
(let* ((default-options (let* ((default-options
`((htdocs-dir . ,(absolute-file-name "root/htdocs")) `((htdocs-dir . ,(absolute-file-name "root/htdocs"))
(surflet-dir . ,(absolute-file-name "root/surflets")) (surflet-dir . ,(absolute-file-name "root/surflets"))
(cgi-bin-dir . ,(absolute-file-name "root/cgi-bin"))
(images-dir . ,(absolute-file-name "root/img")) (images-dir . ,(absolute-file-name "root/img"))
(port . 8008) (port . 8080)
(log-file-name . "/tmp/httpd.log") (log-file-name . "/tmp/httpd.log")
(requests . 5))) (requests . 5)))
(options (make-options-from-args (cdr args) default-options))) (options (make-options-from-args (cdr args) default-options)))
(cond ((zero? (user-uid))
(set-gid (->gid "nobody"))
(set-uid (->uid "nobody"))))
(format #t "Going to run SUrflet server with: (format #t "Going to run SUrflet server with:
htdocs-dir: ~a htdocs-dir: ~a
surflet-dir: ~a surflet-dir: ~a
cgi-bin-dir: ~a
images-dir: ~a images-dir: ~a
port: ~a port: ~a
log-file-name: ~a log-file-name: ~a
a maximum of ~a simultaneous requests, syslogging activated, a maximum of ~a simultaneous requests, syslogging activated,
and home-dir-handler (public_html) activated. and home-dir-handler (public_html) activated.
NOTE: This is the SUrflet server. It does not support cgi.
" "
(lookup-option options 'htdocs-dir) (lookup-option options 'htdocs-dir)
(lookup-option options 'surflet-dir) (lookup-option options 'surflet-dir)
(lookup-option options 'cgi-bin-dir)
(lookup-option options 'images-dir) (lookup-option options 'images-dir)
(lookup-option options 'port) (lookup-option options 'port)
(lookup-option options 'log-file-name) (lookup-option options 'log-file-name)
@ -168,6 +175,7 @@ exec scsh -lel SSAX-4.9/load.scm -lel sunet-2.1/load.scm -dm -o surflet-server -
with-simultaneous-requests (lookup-option options 'requests) with-simultaneous-requests (lookup-option options 'requests)
with-syslog? #t with-syslog? #t
with-log-file (lookup-option options 'log-file-name) with-log-file (lookup-option options 'log-file-name)
with-post-bind-thunk become-nobody-if-root
;; The following settings are made to avoid dns lookups. ;; The following settings are made to avoid dns lookups.
with-reported-port (lookup-option options 'port) with-reported-port (lookup-option options 'port)
with-fqdn "localhost" with-fqdn "localhost"
@ -175,7 +183,8 @@ exec scsh -lel SSAX-4.9/load.scm -lel sunet-2.1/load.scm -dm -o surflet-server -
with-request-handler with-request-handler
(alist-path-dispatcher (alist-path-dispatcher
(list (list
(cons "h" (home-dir-handler "public_html")) (cons "cgi-bin" (cgi-handler (lookup-option options 'cgi-bin-dir)))
(cons "seval" seval-handler)
(cons "source" (rooted-file-or-directory-handler (cons "source" (rooted-file-or-directory-handler
(lookup-option options 'surflet-dir) (lookup-option options 'surflet-dir)
(with-file-name->content-type (with-file-name->content-type
@ -189,8 +198,9 @@ exec scsh -lel SSAX-4.9/load.scm -lel sunet-2.1/load.scm -dm -o surflet-server -
(cons "surflet" (surflet-handler (cons "surflet" (surflet-handler
(with-surflet-path (with-surflet-path
(lookup-option options 'surflet-dir))))) (lookup-option options 'surflet-dir)))))
(rooted-file-or-directory-handler (tilde-home-dir-handler "public_html"
(lookup-option options 'htdocs-dir)))))))) (rooted-file-or-directory-handler
(lookup-option options 'htdocs-dir)))))))))
)) ))
;; EOF ;; EOF