After allocation the socket, become user nobody if current user is root

This commit is contained in:
mainzelm 2003-04-22 13:14:50 +00:00
parent 998182b5cb
commit f385c76f6a
1 changed files with 5 additions and 3 deletions

View File

@ -96,14 +96,15 @@ exec scsh +lpsd -ll packages.scm -dm -o http-test -e main -s "$0" "$@"
(else
(unknown-option-error (car options)))))))))
(define (become-nobody-if-root)
(cond ((zero? (user-uid))
(set-gid (->gid "nobody"))
(set-uid (->uid "nobody")))))
(define (main args)
(init)
(format #t "reading options: ~s~%" (cdr args))
(get-options (cdr args))
(cond ((zero? (user-uid))
(set-gid (->gid "nobody"))
(set-uid (->uid "nobody"))))
(format #t "Going to run Webserver with:
htdocs-dir: ~a
@ -122,6 +123,7 @@ exec scsh +lpsd -ll packages.scm -dm -o http-test -e main -s "$0" "$@"
with-root-directory (cwd)
with-syslog? #t
with-log-file log-file-name
with-post-bind-thunk become-nobody-if-root
with-request-handler
(alist-path-dispatcher
(list (cons "cgi-bin" (cgi-handler cgi-bin-dir)))