Files
mars-smart/root/cgi-bin/user.in
2026-04-21 02:12:28 +02:00

144 lines
3.5 KiB
Bash

#!/bin/sh
#
# CGI-script for userlist editting (Using bindery tools)
#
# Copyright 2000 Wilmer van der Gaast (lintux@lintux.cx)
#
# 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
if [ "$2" != "x" ]; then
echo Content-Type: text/html
echo;
fi
checkrefer
checkparams $*
checkbind
declare -i i
if [ -n "$*" ]; then
EXPR="`echo $* | cut -d\& -f1`"
if [ "$EXPR" = "$*" ]; then
export $*;
else
i=1
while [ -n "$EXPR" ]; do
export $EXPR
EXPR=`echo $* | cut -d\& -f $i`
i=i+1;
done;
fi;
fi
if [ -n "$*" ]; then
if [ -n "$DELETE" ]; then
export DELETE=""
nwborm $SERVER_LOGIN -t 1 -o $USER
$0 list x
exit;
elif [ -n "$EDIT" ]; then
export EDIT=""
FULLNAME="`nwbpvalues $SERVER_LOGIN -t 1 -o $USER -p IDENTIFICATION`"
UNIX_USER="`nwbpvalues $SERVER_LOGIN -t 1 -o $USER -p UNIX_USER | cut -b53-68`"
UNIX_USER="`echo $UNIX_USER | cut -d. -f1`"
i=0; for g in `nwbols $SERVER_LOGIN -t 2 | cut -d" " -f1`; do i=$i+1; done
{ echo C,x,Groups,$i
nwbols $SERVER_LOGIN -t 2 | cut -d" " -f1 | sort |
{ read LINE
while [ "$LINE" ]; do
echo $LINE,$LINE
read LINE;
done; }
} | $REPLACE $SMART_ROOT/forms/user | $GENFORM "$USER" "$FULLNAME" "$UNIX_USER" "" `
nwbols $SERVER_LOGIN -t 2 | sort |
{ read GRP
GRP=\`echo $GRP | cut -d" " -f1\`
while [ -n "$GRP" ]; do
if [ "\`nwbpvalues $SERVER_LOGIN -t 1 -o $USER -p GROUPS_I\'M_IN | \
grep $GRP\`" = "$GRP" ]; then
echo -n "1 ";
else
echo -n "0 ";
fi
read GRP
GRP=\`echo $GRP | cut -d" " -f1\`;
done;
}`
fi;
fi
case "$1" in
uadd )
i=0; for g in `nwbols $SERVER_LOGIN -t 2 | cut -d" " -f1`; do i=$i+1; done
{ echo C,x,Groups,$i
nwbols $SERVER_LOGIN -t 2 | cut -d" " -f1 | sort |
{ read LINE
while [ "$LINE" ]; do
echo $LINE,$LINE
read LINE;
done; }
} | $REPLACE $SMART_ROOT/forms/user | $GENFORM
;;
list )
cat<<EOF
<HTML>
<HEAD>
<TITLE>SMArT - Security - User list</TITLE>
</HEAD>
<BODY BGCOLOR=#C0C0C0>
<FORM ACTION="/cgi-bin/user" METHOD=GET>
<TABLE BORDER>
<TR>
<TH COLSPAN=3 BGCOLOR=$HEADER_BACK ALIGN=LEFT>
<TABLE BORDER=0 FRAME=0 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD><IMG SRC="/smart_icon.jpg"></TD>
<TD><FONT COLOR=$HEADER_BACK>-</FONT></TD>
<TH><FONT COLOR=$HEADER_FORE>Users</FONT></TH>
</TR>
</TABLE>
<TR><TH>Sel<TH>NetWare user name<TH>NetWare user ID
`nwbols $SERVER_LOGIN -t 1 | sort +1 | {
read LINE
i=0
while [ -n "$LINE" ]; do
i=i+1
NAME=\`echo $LINE | cut -d" " -f1\`
echo -n \<TR\>
echo -n \<TD\>\<INPUT TYPE=RADIO NAME=\"USER\" VALUE=\"$NAME\"\>
echo -n \<TD\>
echo -n $NAME
echo -n \<TD\>
echo $LINE | cut -d" " -f2
read LINE
done;
}`
<TR>
<TD COLSPAN=3 ALIGN=CENTER>
<A HREF="/cgi-bin/user?uadd">Add user</A>
<INPUT TYPE=SUBMIT NAME="EDIT" VALUE="Edit">
<INPUT TYPE=SUBMIT NAME="DELETE" VALUE="Delete">
</TABLE>
</BODY>
</HTML>
EOF
;;
esac