-#!/bin/bash
-#
-# Ensure there is an HTTP_AUTHORIZATION environment variable
-# with appropriate content
-
-# root user:password
-login_check() {
- D=$(pwd)
- while [ ! -f $D/.htpasswd ] ; do
- [ "$D" = "$1" ] && return 0
- if [ "$D" = / ] ; then
- logger BAD FAILURE
- return 1
- fi
- D=$(dirname $D)
- done
- if [ -z "$2" ] || ! grep -q "$2" $D/.htpasswd ; then
- cat <<EOF
-Status: 401 Unauthorized
-WWW-Authenticate: Basic realm="Hourglass"
-EOF
- return 1
- fi
-}
-#logger "HTTP_AUTHORIZATION=$HTTP_AUTHORIZATION"
-if login_check "$(dirname $(dirname $0))" "${HTTP_AUTHORIZATION#Basic }" ; then
-
- cd ..
- REMOTE_USER="$(echo -n "${HTTP_AUTHORIZATION#Basic }" | base64 -d)"
- REMOTE_USER="${REMOTE_USER%%:*}"
- export REMOTE_USER
- ROLE="$(grep "^${REMOTE_USER}": roles.txt)"
- export ROLE="${ROLE#*:}"
- if [ -f "$ROLE/$1" ] ; then
- echo
- exec /usr/local/bin/newlisp newlisp $ROLE/$1
- fi
-fi
-cat <<EOF
-
-Broken.
-EOF