#!/bin/sh
#------------------------------------------------------------------------------
# sec-lib.cgi - provide functions to control access
#
# Creation:     20.05.2001  tg
# Last Update:  $Id$
#
#------------------------------------------------------------------------------
# get main helper functions
. /srv/www/include/cgi-helper
if [ "$SEC_REALM" = "" -o "$SEC_ACTION" = "" ]
then
  show_html_header "$_MN_accdenied" "showmenu=no"
  show_error "$_MN_seclib" '$_MN_nopar'
  # Exit the CGI-Script
  exit 1
fi
case $REMOTE_USER in
    "") ;;
    *)
        if grep ^$REMOTE_USER= /etc/httpd/rights | cut -d= -f2 | \
           grep -vq -e "^all$" \
                    -e "\( \|^\)$SEC_REALM:all\( \|$\)" \
                    -e "\( \|^\)$SEC_REALM[^ ]*[:,]$SEC_ACTION\( \|,\|$\)"
        then
            show_html_header "$_MN_accdenied" "showmenu=no"
            show_error "$_MN_accdenied" "$_MN_noright
 \
                                        $_MN_user: \"$REMOTE_USER\"
 \
                                        $_MN_realm: \"$SEC_REALM\"
 \
                                        $_MN_secaction: \"$SEC_ACTION\""
            show_html_footer
            # Exit the CGI-Script
          exit 1
        fi
    ;;
esac