#!/bin/sh
#
# CGI-script for adjusting passwords etc. for MARS_NWE
#
# Copyright 2000 Wilmer van der Gaast (lintux@dds.nl)
#

#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

. $WEBSERVE_ROOT/cgi-bin/functions
. $WEBSERVE_ROOT/smart.conf

echo Content-Type: text/html
echo

checkrefer
checkparams $*

function listitems
{
  read LINE
  while [ -n "$LINE" ]; do
    echo \<TR\>
    echo -n \<TD\>
    echo $LINE | cut -d" " -f2
    echo -n \<TD\>
    echo $LINE | cut -d" " -f3
    echo -n \<TD\>
    echo $LINE | cut -d" " -f4
    echo -n \<TD\>
    echo $LINE | cut -d" " -f5;
    read LINE
  done;
}
                                      
case $* in
	encryption )
		CURRENT=`getconfig 7 | cut -d" " -f2`
		$GENFORM < $SMART_ROOT/forms/encryption "$CURRENT"
;;
	supervisor )
		NOVELL=`getconfig 12 | cut -d" " -f2`
		LINUX=`getconfig 12 | cut -d" " -f3`
    PASSWORD=`getconfig 12 | cut -d" " -f4`
		$GENFORM < $SMART_ROOT/forms/supervisor "$NOVELL" "$LINUX" "$PASSWORD"
;;
	mapping )
		CURRENT=`getconfig 15 | cut -d" " -f2`
		PASSWORD=`getconfig 15 | cut -d" " -f3`
		$GENFORM < $SMART_ROOT/forms/automap "$CURRENT" "$PASSWORD"
;;
	sec-flags )
		declare -i CURRENT F1 F2 F4 F8 F10 F20 F40
		CURRENT=`getconfig 8 | cut -d" " -f2`
		F1="($CURRENT & 1) / 1"
		F2="($CURRENT & 2) / 2"
		F4="($CURRENT & 4) / 4"
		F8="($CURRENT & 8) / 8"
		F10="($CURRENT & 16) / 16"
		F20="($CURRENT & 32) / 32"
		F40="($CURRENT & 64) / 64"
		$GENFORM < $SMART_ROOT/forms/sec-flags "$F1" "$F2" "$F4" "$F8" "$F10" "$F20" "$F40"
;;
esac
