Initial revision

This commit is contained in:
Kurt Spanier 1999-09-10 17:33:39 +00:00
parent 1c52d43149
commit 884d6832d5
71 changed files with 21522 additions and 0 deletions

200
contrib/tweb/CHANGES Normal file
View File

@ -0,0 +1,200 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* CHANGES *
* *
* Function:..A short description of the last modifications of TWEB *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* September 14 1995 Z D D V V *
* Last modification: Z D D V V *
* January 15 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/*/
Changes of the web-x.500-gateway TWEB
=====================================
Version: tweb-2.3 1998/10/05
Changes to code
- dynamic re-sort and re-display based on entries found in the DIT:
SORT definitions given by config files can be changed due to
local information within a DIT area; that provides for dynamic
definitions of sorting groups and/or display of groups with new
labels and/or other sorting order;
DISPLAY definitions can be replaced or added dynamically, in order
to display contents of entries in other than the statically
configured way
Version: tweb-2.2 1998/3/20
Changes in configuration files (please check!)
- INDEX-URL (new): display hrefs below a certain dit showing special parts
of the entry-dn in any sequence
- DIT-CONFIG (new): get from a specified location the information how to
switch to other gateways depending on the given dn.
With NOT-BROWSE you can turn of this functionality for browsing.
- DISP-SEA-RDN (new): with this option you can make search-results to be
displayed only by rdn and not by relative dn to the search-base
- TON-URLS (new): hereby you can reference a given organization/alunit
by TONS (special numbers for organizational hirarchies)
example: T013307 can mean:
computing centre, dept. development of new services
- INDIRECT-ATTRS (new): attribute-value can be fetched by special keys from
other locations and additional be transformed by according
functions
- ALLOW-STRING DENY-STRING GRANT REFUSE : CHANGE IN BEHAVIOUR!!
now regular expressions are used. That means you have shorter
config strings.
- ALLOW-MSG (new): by this option you can specify a special file located
in the ETCDIRectorie containing a message to be displayed
in case of an allowed access to TWEB
- TABLES (new): triggered by the presence of a special objectclass
will be displayed a button in the header of the TWEB-page
allowing an eXtended data access such as:
a table with names, telephonenumbers and e-mail addresses
of the current organization
or the access to the electronic telephonebook-data
of the university of tuebingen generated by TWEB
dynamically
Version: tweb-2.0a 1997/1/7
Changes in configuration files (please check!)
- PULL-DOWN-MENUS (new): use BUTTONS and PULL-DOWN-MENUS instead of links
in order to support: help, language-switch, move-upwards
and read-entry functionalities
- GRANT (new): allow general access to TWEB for specified locations
( same syntax as ALLOW-STRING )
- REFUSE (new): refuse general access to TWEB for specified locations
( same syntax as DENY-STRING )
- INDIRECT-ATTRS (new): Get specified attribute-values from another
location
- CACHING-TERMS (new): specify caching-behaviour for browsers and www-caches
- CACHE-EXPIRE-DEFAULT (new): set a default caching-time for browsers
and www-caches
- SHOW-DEFOC (new): Show Default Objectclass
- COMREFUSE (new): prevent engine-access
- robots.txt (new): supply robots.txt-file functionality with the same
behaviour as in www-servers
Version: tweb-1.1b 1996/5/7
Changes in configuration files (please check!)
- STRICT-BASEDN (new): Access not below basedn is switched to responsible
gateway ( -> gw-switch)
- ALLOW-PROXY (new): if NO-PROXY is configured access from
given domain is allowed
Version: tweb-1.1a, 1996/4/25
Changes in configuration files (please check!)
- SORT extensions: fourth parameter RELATED DISPLAY-CLASS:
relation to according DISPLAY-entry
(default is 'default')
see DISPLAY changes
fifth parameter SORT-ATTRIBUTE:
attribute used to sort entries
(default is 'sn')
- DISPLAY changes: The DISPLAY objectClass entry is replaced by the string
that is used as fifth attribute with SORT
- NO-PROXY (new): option for access restrictions via PROXY-servers
- TWEBHOST (new): option to support a constant tweb-hostname
- NO-MODIFY (new): option to prevent entries with named objectclasses from
modification
- PGPKEY (new): DISPLAY-TYPE for PGPKeys enabling cut&paste
Changes to code
- conversion from upper to lowercase characters in:
make_oc_to_str(), pick_oc(), init_sort(), init_modify(),
attrs in display() and all internal comparison-strings!!!
- modification with multiline attributes now possible with NETSCAPE
- pictures in X.500 are shown (only with NETSCAPE)
- display is denied in do_read() in case of missing default-Display
- technical entries (gw...) are not shown if using DYNAMIC-GW
- the tokens to filter proxy-access with NO_PROXY are extended to:
" via " & "Proxy gateway"
- the tweb-version and compilation date is now shown with C & K options
- many bugfixes
Version: tweb-1.0b, 1996/2/29
Changes in configuration files (please check!)
- ALLOW/DENY-String moved from tweb.conf.[01] to tweb.rc
- tweb.lang.[01]: string 4 TEXT/HTML --> text/html
- tweb.rc : optional parameter TWEBHOST (see FEATURE-LIST)
Changes to code
- better behaviour in modify operations
BEWARE: modification of inherited attributes still NOT possible (!)
- logging-option (-l) with facultative parameter: LOCAL[0-7] of syslogd
-lx --> LOCAL3 (default)
- simplified metasyntax of GW-switches:
labeledURI= http://<host>:<port>/ <descriptive string> (gw[-<lang>])
- use 'aliasedObjectName' in HREF of aliases
- always print HTML header
- many bugfixes
Version: tweb-1.0a, 1996/2/7
- base distibution

101
contrib/tweb/COPYRIGHTS Normal file
View File

@ -0,0 +1,101 @@
Copyright (c) 1994 - 1999 University of Tuebingen, Germany.
Written by Kurt Spanier and Bernhard Winkler. All rights reserved.
This software is not subject to any license of the University of
Tuebingen, Germany.
Permission is granted to anyone to use this software for any purpose
on any computer system, and to alter it and redistribute it, subject
to the following restrictions:
1. The author is not responsible for the consequences of use of this
software, no matter how awful, even if they arise from flaws in it.
2. The origin of this software must not be misrepresented, either by
explicit claim or by omission. Since few users ever read sources,
credits should appear in the documentation.
3. Altered versions must be plainly marked as such, and must not be
misrepresented as being the original software. Since few users
ever read sources, credits should appear in the documentation.
4. This notice may not be removed or altered.
This work is derived from the Technical University of Chemnitz web500gw
by Frank Richter. Information concerning is available at
http://www.tu-chemnitz.de/~fri/web500gw.
web500gw is itself derived from the University of Michigan go500gw
by Tim Howes. Information concerning is available at
http://www.umich.edu/~dirsvcs/ldap/ldap.html
This work also contains materials derived from public sources:
ch_malloc.c, charray.c, dn.c from the University of Michigan LDAPv3.3,
with some minor bug fixes.
regular.c from the University of Toronto regexp by Henry Spencer,
with renaming of functions for not colliding with putative
build-in regexp functions in the underlying LDAP libraries,
as well as minor modifications.
The original software can be obtained from
ftp://ftp.cs.toronto.edu/pub/regexp.README, and
ftp://ftp.cs.toronto.edu/pub/regexp.shar.Z
Additional Information can be obtained by sending e-mail to:
tweb-support@mail500.uni-tuebingen.de
---
Portions Copyright (c) 1994-1998 Chemnitz University of Technology.
All rights reserved.
A LDAP based WWW - X.500 gateway
written by: Frank Richter, Frank.Richter@hrz.tu-chemnitz.de
Chemnitz University of Technology, Germany, 1994-1998
Redistribution and use in source and binary forms are permitted
provided that this notice is preserved and that due credit is given
to the Technical University of Chemnitz. The name of the University
may not be used to endorse or promote products derived from this
software without specific prior written permission. This software
is provided ``as is'' without express or implied warranty.
---
Portions Copyright (c) 1992-1996 Regents of the University of Michigan.
All rights reserved.
Redistribution and use in source and binary forms are permitted
provided that this notice is preserved and that due credit is given
to the University of Michigan at Ann Arbor. The name of the University
may not be used to endorse or promote products derived from this
software without specific prior written permission. This software
is provided ``as is'' without express or implied warranty.
---
Portions Copyright (c) 1986 by University of Toronto.
Written by Henry Spencer. Not derived from licensed software.
Permission is granted to anyone to use this software for any
purpose on any computer system, and to redistribute it freely,
subject to the following restrictions:
1. The author is not responsible for the consequences of use of
this software, no matter how awful, even if they arise
from defects in it.
2. The origin of this software must not be misrepresented, either
by explicit claim or by omission.
3. Altered versions must be plainly marked as such, and must not
be misrepresented as being the original software.

1138
contrib/tweb/FEATURE-LIST Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,75 @@
TWEB WWW-X500 GATEWAY - GETTING STARTED
With the information provided by this file you should be able to start
an initial version of TWEB. Please follow the steps below:
1. Copy the distribution Makefile onto Makefile:
> cp Makefile.openldap Makefile
2. Edit the Makefile. You have to change the variables in the first block of
the file to your appropriate settings:
> vi Makefile
3. Now type in make:
> make
This should make a binary called tweb whithout severe problems
4. Running the TWEB www-x500 gateway
4.1. Testing the newly compiled binary
Copy the tweb binary to the sub-directory TWEB_conFiles and
change to that directory:
> cp tweb TWEB_conFiles
> cd TWEB_conFiles
Copy the config files with extension .dist to their respective
basefiles:
> cp tweb.rc.dist tweb.rc
> cp tweb.conf.0.dist tweb.conf.0
> cp tweb.conf.1.dist tweb.conf.1
> cp tweb.lang.0.dist tweb.lang.0
> cp tweb.lang.1.dist tweb.lang.1
Edit tweb.rc to adjust the variables in the
first block to your appropriate settings:
> vi tweb.rc
Run TWEB with language 0 and 1 (i.e., german and english)
> ./tweb -L01
This will run two TWEB server processes, one for german language, the
other for english language, whithout syslog logging;
you can assess them with your WWW browser by giving the URL
http://<your-tweb-host>:<your-tweb-port>/
4.2. Adapting TWEB to your local requirements
When you reached this point you have a running TWEB with basic
functionality. Have a look to the FEATURE-LIST file for a
description of all features, TWEB does provide. The least, you
might want to change are the several header and footer files
in order to build up your organizational identity with TWEB.
But check also the security features, and the performance (i.e.,
load balancing) features. By setting the respective parameters,
TWEB can provide for a very special appearance with local require-
ments enforced as far as possible. Should you want more reasonable
features, please don't hesitate to contact the development team.
Have fun,
TWEB development team, Tuebingen, September, 9th, 1999
email: tweb-support@mail500.uni-tuebingen.de

View File

@ -0,0 +1,4 @@
<strong>Datei: LDAP_etc/allow.msg.0<br>
Achtung</strong>: Dies ist eine Meldung, die nur dem authorisierten
Nutzer angezeigt wird !!!
<hr>

View File

@ -0,0 +1,4 @@
<strong>File: LDAP_etc/allow.msg.1<br>
Attention</strong>: This message will only be shown to the
permitted user.
<hr>

View File

@ -0,0 +1,86 @@
# ldap filter file
#
# lines like this that start with # or empty lines are ignored
#
# syntax:
#
# <tag>
# <pattern1> <delimiters> <filter1-1> <desc1-1> [<scope>]
# <filter1-2> <desc1-2> [<scope>]
#
# <pattern2> <delimiters> <filter2-1> <desc2-1> [<scope>] ...
#
# The "desc" should describe the filter and it should correctly complete
# both of the following phrases:
#
# One <desc> match was found for...
# Three <desc> matches were found for...
#
# The scope is optional, and should be one of:
# "base"
# "onelevel"
# "subtree"
# if it is included.
#
"finger and go500 and go500gw subtree and rp500 and rcpt500"
"=" " " "%v" "arbitrary filter"
"^[0-9][0-9\-]*$" " " "(telephoneNumber=*%v)" "phone number"
"@" " " "(mail=%v)" "email address"
"(mail=%v*)" "start of email address"
"^.[\. _].*" ". _" "(cn=%v1* %v2-)" "first initial"
".*[. _].$" ". _" "(cn=%v1-*)" "last initial"
"[. _]" ". _" "(|(sn=%v1-)(cn=%v1-))" "exact"
"(|(sn~=%v1-)(cn~=%v1-))" "approximate"
".*" ". " "(|(cn=%v1)(sn=%v1)(uid=%v1))" "exact"
"(|(cn~=%v1)(sn~=%v1))" "approximate"
"web500gw subtree"
"=" " " "%v" "arbitrary filter"
"^[0-9][0-9\-]*$" " " "(|(telephoneNumber=*%v)(facsimileTelephoneNumber=*%v))" "phone number"
"@" " " "(mail=%v)" "email address"
"(mail=%v*)" "start of email address"
"^.[\. _].*" ". _" "(cn=%v1* %v2-)" "first initial"
".*[. _].$" ". _" "(cn=%v1-*)" "last initial"
############
# "[. _]" ". _" "(|(sn=%v1-)(cn=%v1-))" "exact"
# "(|(sn~=%v1-)(cn~=%v1-))" "approximate"##
#
# ".*" ". " "(|(cn=%v1)(sn=%v1))" "exact"
# "(|(cn~=%v1)(sn~=%v1))" "approximate"#
#
# Neue Einstellungen 970127 KPG:
"[oO][xX]:.*" ":" "(|(ou=%v2-))" "exact"
"[xX][oO]:.*" ":" "(|(ou=%v2-))" "exact"
"[oO]:.*" ":" "(|(ou=%v2-))" "exact"
"(|(ou~=%v2-))" "approximate"
"[xX]:.*[. _].*" ":" "(|(cn=%v2%v3%v4-))" "exact"
"[xX]:.*" ":" "(|(sn=%v2-))" "exact"
"[. _]" ". _" "(|(cn=%v))" "exact"
"(|(cn~=%v))" "approximate"
".*" ". " "(|(sn=%v))" "exact"
"(|(sn~=%v))" "approximate"
"go500gw onelevel and web500gw onelevel"
"^..$" " " "(|(o=%v)(c=%v)(l=%v)(co=%v))" "exact"
"(|(o~=%v)(c~=%v)(l~=%v)(co~=%v))" "approximate"
" " " " "(|(o=%v)(l=%v)(co=%v))" "exact"
"(|(o~=%v)(l~=%v)(co~=%v))" "approximate"
"\." " " "(associatedDomain=%v)" "exact"
".*" " " "(|(o=%v)(l=%v)(co=%v))" "exact"
"(|(o~=%v)(l~=%v)(co~=%v))" "approximate"

View File

@ -0,0 +1,40 @@
AU Australien
AR Argentinien
AT &Ouml;sterreich
BE Belgien
BR Brasilien
CA Kanada
HR Kroatien
CS Tschechoslowakei
CZ Tschechische Republik
DK D&auml;nemark
FI Finnland
FR Frankreich
DE Deutschland
EE Estland
GB Gro&szlig;britannien
GR Griechenland
HK Hong Kong
HU Ungarn
IS Island
IN Indien
IE Irland
IL Israel
IT Italien
JP Japan
KR Korea
LI Liechtenstein
LU Luxemburg
NL Niederlande
NZ Neuseeland
NO Norwegen
PL Polen
PT Portugal
ES Spanien
SE Schweden
CH Schweiz
RU Russische F&ouml;deration
US Vereinigte Staaten von Amerika
SI Slowenien
SK Slowakei
SG Singapur

View File

@ -0,0 +1,40 @@
AU Australia
AR Argentina
AT Austria
BE Belgium
BR Brazil
CA Canada
HR Croatia
CS Czechoslovakia
CZ Czech Republic
DK Denmark
FI Finland
FR France
DE Germany
EE Estonia
GB Great Britain
GR Greece
HK Hong Kong
HU Hungary
IS Iceland
IN India
IE Ireland
IL Israel
IT Italy
JP Japan
KR Korea
LI Liechtenstein
LU Luxemburg
NL Netherlands
NZ New Zealand
NO Norway
PL Poland
PT Portugal
ES Spain
SE Sweden
CH Switzerland
RU Russian Federation
US United States of America
SI Slovenia
SK Slovakia
SG Singapore

View File

@ -0,0 +1,4 @@
<hr>
<strong>Datei: LDAP_etc/search-only.foot.0<br>
Achtung:</strong> Dieser Text wird als Footer einer Search-Only-Seite
angezeigt !!!

View File

@ -0,0 +1,4 @@
<hr>
<strong>File: LDAP_etc/search-only.foot.1<br>
Attention:</strong> This footer will be display'ed at the end
of a search-only page.

View File

@ -0,0 +1,5 @@
<h1>Search-Only-Seite</h1>
<strong>Datei: LDAP_etc/search-only.head.0<br>
Achtung:</strong> Dieser Text wird am Beginn einer Search-Only-Seite
angezeigt !!!
<hr>

View File

@ -0,0 +1,5 @@
<h1>Search-Only-Page</h1>
<strong>File: LDAP_etc/search-only.head.1<br>
Attention:</strong> This header will be display'ed at the beginning
of a search-only page.
<hr>

View File

@ -0,0 +1,4 @@
<hr>
<strong>Datei: LDAP_etc/tweb-base.foot.0<br>
Achtung:</strong> Diese Seite wird als Footer auf der BASEDN-Seite
angezeigt !!!

View File

@ -0,0 +1,4 @@
<hr>
<strong>File: LDAP_etc/tweb-base.foot.1<br>
Attention:</strong> This text will be display'ed at the end of
the BASEDN page.

View File

@ -0,0 +1,5 @@
<h1>BASEDN-Header</h1>
<strong>Datei: LDAP_etc/tweb-base.head.0<br>
Achtung:</strong> Dieser Header wird am Beginn der BASEDN-Seite
angezeigt !!!
<hr>

View File

@ -0,0 +1,5 @@
<h1>BASEDN-Header</h1>
<strong>File: LDAP_etc/tweb-base.head.1<br>
Attention:</strong> This header will be display'ed at the beginning
of the BASEDN page.
<hr>

View File

@ -0,0 +1,4 @@
<hr>
<strong>Datei: LDAP_etc/tweb.footer.0<br>
Achtung:</strong> Dieser Footer wird am Ende einer normalen
Seite unterhalb BASEDN angezeigt !!!

View File

@ -0,0 +1,4 @@
<hr>
<strong>File: LDAP_etc/tweb.footer.1<br>
Attention:</strong> This footer will be display'ed at the end of a page
below BASEDN.

View File

@ -0,0 +1,5 @@
<h1>TWEB</h1>
<strong>Datei: LDAP_etc/tweb.header.0<br>
Achtung:</strong> Dieser Header wird am Beginn einer Seite unterhalb
von BASEDN angezeigt !!!
<hr>

View File

@ -0,0 +1,5 @@
<h1>TWEB</h1>
<strong>File: LDAP_etc/tweb.header.1<br>
Attention:</strong> This header will be display'ed at the beginning of
a page below BASEDN.
<hr>

View File

@ -0,0 +1,46 @@
<TITLE>TWEB HILFE</TITLE>
<BODY>
<H2> Das TWEB WWW2X.500-Gateway </H2>
Im X.500 sind weltweit viele Personen und Organisationen mit EMail- Adresse,
Postanschrift, FAX, Telefonnummer, Aufgabenbereich, etc. zu finden.
Zum einfachen Zugriff per WorldWideWeb dient <strong>TWEB</strong> WWW2X.500-Gateway.<P>
<strong>TWEB</strong> erm&ouml;glicht das einfache Browsen, die Suche
und die Modifikation des eigenen Eintrages im X.500.<P>
Das Gateway enth&auml;lt folgende Features
<ul>
<li>F&uuml;r den Administrator bietet <strong>TWEB</strong> umfangreiche M&ouml;glichkeiten
der Konfiguration mittels Konfigurations-Dateien, ohne &Auml;nderungen im
Code und ohne erneutes &Uuml;bersetzen.
<li>Zus&auml;tzlich sind Datenschutzmechanismen aktivierbar.
<li>Andere Sprachen sind durch Ersetzen/Hinzuf&uuml;gen
von Sprach-Dateien leicht realisierbar.
<li>Wie Sie es vom WWW her gewohnt sind, brauchen Sie nur den gew&uuml;nschten
unterstrichenen Eintrag anklicken, und Sie sehen, was darunter angesiedelt ist.
<li>Mit "Weitere Informationen" wird eine zweite Info-Seite gezeigt.
<li>Mit Hilfe der SUCH-Box k&ouml;nnen Sie nach Namen und Teilstrings suchen.
<li>Ihren eigenen Eintrag k&ouml;nnen Sie mit Ihrem Passwort in Verbindung
mit dem entsprechenden Button &auml;ndern.
</ul>
<hr>
<strong>TWEB</strong> ist eine Weiterentwicklung vom Web500gw von Frank Richter, Technische
Universitaet Chemnitz-Zwickau, basierend auf go500gw von Tim Howes,
University of Michigan.
<hr>
Bei Fragen, Anregungen, Bug-Reports Mail an:
<ADDRESS><A HREF="mailto:web500gw-support@mail500.uni-tuebingen.de"> web500gw-support@mail500.uni-tuebingen.de</A> - Stand: 16. Februar 1996</ADDRESS>
<hr>

View File

@ -0,0 +1,47 @@
<TITLE>TWEB HELP</TITLE>
<BODY>
<H2> TWEB WWW2X.500-Gateway HELP</H2>
There are worldwide lots of persons and organizations stored in the X.500-
directory with email-address, postal address, fax, telephone-number,
working-area, etc. For easy access with WorldWideWeb there is the
<strong>TWEB</strong> WWW2X.500-Gateway.<P>
<strong>TWEB</strong> allows easy browsing, searching and modification of
entries in the X.500-directory.<p>
Features of the gateway include
<ul>
<li>For the administrator <strong>TWEB</strong> offers extensive opportunities of
configuration by means of configuration-files without change of code
and without recompilation.
<li>Configurable data-protection-mechanisms are available.
<li>Other languages are supported by language-resource-files.
<li>As with other WWW applications you only have to click on the desired entry
to see, what is settled beneath.
<li>The button "More Information" shows a second page of information.
<li>By means of the SEARCH-box you can look for persons with exact or substring
match.
<li>You can modify your own entry by typing in your password in combination
with the modification button.
</ul>
<hr>
<strong>TWEB</strong> is based on Web500gw from Frank Richter, Technische
Universitaet Chemnitz-Zwickau, that itself is based on go500gw from Tim Howes,
University of Michigan.
<hr>
For questions, suggestions, bug-reports mail to:
<ADDRESS><A HREF="mailto:x500-netman@mail500.uni-tuebingen.de"> x500-netman@mail500.uni-tuebingen.de</A> - 27. October 1995</ADDRESS>
<hr>

View File

@ -0,0 +1,105 @@
#*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
# *
# Makefile... *
# *
# Function:..TWEB WWW to X.500-GATEWAY SERVER MAKEFILE *
# *
# *
# *
# Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
# Zentrum fuer Datenverarbeitung, *
# Bereich Entwicklungneuer Dienste, *
# Universitaet Tuebingen, GERMANY *
# *
# ZZZZZ DDD V V *
# Creation date: Z D D V V *
# August 16 1995 Z D D V V *
# Last modification: Z D D V V *
# September 9 1999 ZZZZ DDD V *
# *
#/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/*/
#-----------------------------------------------------------------------------
#
# based on web500gw.c of Frank Richter, TU Chemnitz-Zwickau, DE
#
# first edition: 95/07/28, /KSp
#
# $Id: Makefile.openldap,v 1.6 1999/09/10 15:01:15 zrnsk01 Exp $
#
#-----------------------------------------------------------------------------
#########################################################################
###
### Tailor the following to your local settings
###
#########################################################################
# where is your LDAP client library located
LDAP_RUNTIME=/LDAP
LDAP_SOURCE =/LDAP/ldap-3.3
LIBDIR= $(LDAP_RUNTIME)/lib
INCDIR= $(LDAP_RUNTIME)/include
# where is some version information for your LDAP client library
LDAPDIR= $(LDAP_SOURCE)/build
# select your compiler (DEFAULT=cc) and uncomment ACFLAGS and/or COPTS
# to have options for the linker and/or compiler
CC= gcc
# ACFLAGS=
# COPTS= -Aa -O # cc on a HP box
COPTS= -Wall -ansi -pedantic -O2
# uncomment next line when compiling on SUN
# LXNET = -lxnet
# we don't have any special definitions for the current distribution
# DEFINES=
#########################################################################
###
### You should leave the following definitions untouched
###
#########################################################################
SRCS = tweb.c strng.c init.c queries.c server.c \
x500.c html.c support.c checkclient.c \
charray.c ch_malloc.c dn.c regular.c
OBJS = tweb.o strng.o init.o queries.o server.o \
x500.o html.o support.o checkclient.o \
charray.o ch_malloc.o dn.o regular.o
GWOBJS = $(OBJS) gwversion.o
CFLAGS = $(COPTS) -I$(INCDIR) $(ACFLAGS) $(DEFINES) $(GWVERS)
LIBS = -lldap -llber $(KRBLIBFLAG) $(KRBLIBS) $(LXNET)
DLIBS = $(LIBDIR)/libldap.a $(LIBDIR)/liblber.a
gw: gwversion.o
$(CC) $(ALDFLAGS) -o $@ $(GWOBJS) -L$(LIBDIR) $(LIBS)
mv $@ tweb
gwversion.c: $(OBJS) $(DLIBS)
rm -f $@
(u=$${USER-root} v=`cat $(LDAPDIR)/version` d=`pwd` h=`hostname` t=`date`; \
sed -e "s|%WHEN%|$${t}|" \
-e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \
-e "s|%VERSION%|$${v}|" \
< Versiongw.c > $@)
lint:;
lint -I. $(SRCS)
5lint:;
/usr/5bin/lint -I. $(SRCS)
clean:;
rm -f *.o core a.out gwversion.c tweb
depend:;
$(LDAPDIR)/mkdep $(CFLAGS) $(SRCS)
# DO NOT DELETE THIS LINE -- mkdep uses it.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY

91
contrib/tweb/README Normal file
View File

@ -0,0 +1,91 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* README *
* *
* Function:..Introduction to the WWW-X.500 gateway TWEB *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* September 14 1995 Z D D V V *
* Last modification: Z D D V V *
* January 19 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/*/
IMPORTANT HINT FOR UPGRADING TO VERSION 2.3.x:
the config-syntax of ALLOW-STRING DENY-STRING GRANT REFUSE has changed:
now regular expressions are used enabling shorter config strings.
the language-files have been extended. Please use the newly provided
language-files or update your old ones.
INTRODUCTION
TWEB is based on the Web500gw implementation by Frank Richter,
Technische Universitaet Chemnitz-Zwickau, which is based on the
go500gw implementation by Tim Howes, University of Michigan.
TWEB was compiled and tested on LINUX with cc, HPUX 9.05 with the
HP-ANSI C compiler, as well as SunOS 4.1.2 with the SUN C compiler.
TWEB was also compiled with gcc on all platforms.
The UMICH LDAP client library version 3.0 or 3.3
( URL:ftp://terminator.rs.itd.umich.edu/ldap/ldap-3.3.tar.Z )
must be installed on the machine (library path and include file
path is configured in Makefile). With QUIPU ICR-2.x the ISODE-
provided LDAP libraries should be used. As such, TWEB only supports
LDAP version 2 with the University of Michigan type C API. TWEB is
also adapted for the OpenLDAP LDAP library, release version 1.1.2
(http://www.openldap.org).
An upgrade to LDAP version 3 and a C API standadized by the IETF
is planned for a not so far away future, most probably in step
with the OpenLDAP package.
TWEB, as provided here is a fully functional core gateway, which
is extended at the author's site by some local features. These
extensions are included into the same code base, so that some
"#ifdef TUE_TEL" or "#ifdef AMBIX" pre-processor statements can
be found throughout the code.
Have a look at the doc sub-directory to get some further documentation.
INSTALLATION
The installation and configuration of TWEB is described in the
GETTING-STARTED file. After making and testing the basic TWEB
you should have a look to file FEATURE-LIST to learn about the
several configuration parameters TWEB provides for runtime
configuration of the program.
SUPPORT
Bug reports and flames (but also critical comments) please send to
tweb-support@mail500.uni-tuebingen.de.
For general discussion (e.g., about interesting new features,
which should be supported), there is a discussion list at
tweb-l@mail500.uni-tuebingen.de.
Send requests for subscription to
tweb-l-request@mail500.uni-tuebingen.de.
TWEB development team, Tuebingen, September, 9th, 1999

View File

@ -0,0 +1,3 @@
# go away
User-agent: *
Disallow: /

View File

@ -0,0 +1,267 @@
#*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
# *
# tweb.conf.0 *
# *
# Function:..Configuration-file for TWEB *
# *
# *
# *
# Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
# Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
# neuer Dienste, Universitaet Tuebingen, GERMANY *
# *
# ZZZZZ DDD V V *
# Creation date: Z D D V V *
# July 26 1996 Z D D V V *
# Last modification: Z D D V V *
# December 18 1998 ZZZZ DDD V *
# *
#/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/*/
#==========================================================================
# $Id: tweb.conf.0.dist,v 1.6 1999/09/10 15:01:21 zrnsk01 Exp $
# THE PARAMETERS IN THIS FILE AND THE CORRESPONDING CONFIG-FILE.1
# ARE PRE-SET TO PROVIDE A BASIC FUNCTIONALITY.
#
# IF YOU LIKE, YOU CAN CHECK FOR FURTHER DISPLAY-OBJECTs, SORT,
# SEARCH-ONLY AND MODIFY DEFINITIONS IN THE SECOND PART OF THE FILE.
#
# TO ACTIVATE A CERTAIN FEATURE, THE CORRESPONDING LINES HAVE TO
# BE DE-COMMENTED
#########################################################################
###
### the description, how to display an object upon read
###
# FIRST-PAGE is the main view, SECOND-PAGE a linked page with more
# (e.g., not so important) information
#
# given is a list of attributes, with labels for each and the method,
# how to display the content of the attribute
DISPLAY-OBJECT pers
# 1.Bild
FIRST-PAGE cn Name DEFAULT
personalTitle Titel DEFAULT
organizationalStatus Dienststellung DEFAULT
description Arbeitsgebiet DEFAULT
telephoneNumber Gesch&auml;fts-Telefon DEFAULT
facsimileTelephoneNumber Fax DEFAULT
mail E-Mail-Adresse MAILTO
textEncodedORaddress X400-Adresse DEFAULT
postalAddress Anschrift MULTILINE
roomNumber Raum DEFAULT
labeledURI URL URI
# 2.Bild (see more)
SECOND-PAGE sn Nachname DEFAULT
roleOccupant Funktionstr&auml;ger HREF
memberOfGroup E-Mail-Verteiler DEFAULT
homepostalAddress Heimat-Anschrift MULTILINE
homePhone Privat-Telefon DEFAULT
pager Pager DEFAULT
lastModifiedTime "letztmalig ge&auml;ndert" DATE
lastModifiedBy "letztmalig ge&auml;ndert von" DEFAULT
DISPLAY-OBJECT organization
# 1.Bild
FIRST-PAGE o Name DEFAULT
ou Name DEFAULT
l Ort DEFAULT
description Beschreibung DEFAULT
postalAddress Postanschrift MULTILINE
telephoneNumber Telefon DEFAULT
facsimileTelephoneNumber Fax DEFAULT
labeledURI URL URI
# 2.Bild (see more)
SECOND-PAGE st Bundesland DEFAULT
seeAlso "weitere Informationen" MOVETO
lastModifiedTime "letztmalig ge&auml;ndert" DATE
lastModifiedBy "letztmalig ge&auml;ndert von" DEFAULT
DISPLAY-OBJECT rfc822MailList
# 1. Bild
FIRST-PAGE description Beschreibung DEFAULT
joinable abonnierbar BOOLEAN
associatedDomain E-Mail-Domain DEFAULT
rfc822RequestsTo "Anfragen an" MAILTO
requestsTo "Anfragen an" HREF
owner Eigent&uuml;mer HREF
# 2. Bild
SECOND-PAGE lastModifiedTime "letzte &Auml;nderung" DATE
lastModifiedBy "ge&auml;ndert durch" DEFAULT
DISPLAY-OBJECT country
# 1.Bild
FIRST-PAGE friendlyCountryName L&auml;ndernamen DEFAULT
associatedDomain Domain DEFAULT
manager Manager HREF
labeledURI URL URI
# 2.Bild (see more)
SECOND-PAGE masterDSA Master-DSA HREF
slaveDSA Slave-DSA HREF
lastModifiedTime "letztmalig ge&auml;ndert" DATE
lastModifiedBy "letztmalig ge&auml;ndert von" DEFAULT
lastUpdateTime "letztmalig ge&auml;ndert" DATE
DISPLAY-OBJECT default
# 1.Bild
FIRST-PAGE jpegPhoto Foto JPEG
photo Foto BMP
cn Name DEFAULT
sn Nachname DEFAULT
textEncodedMtaName MTA-Name DEFAULT
relatedMHSdomain MHS-Domain DEFAULT
description Beschreibung DEFAULT
multiLineDescription Beschreibung MULTILINE
info "Allgemeines" DEFAULT
productName Produktname DEFAULT
mail Mail-Adresse MAILTO
telephoneNumber Telefon DEFAULT
facsimileTelephoneNumber Fax DEFAULT
labeledURL URL URL
memberOfGroup E-Mail-Verteiler DEFAULT
member Mitglied HREF
owner Eigent&uuml;mer HREF
requestsTo "Anfragen an" HREF
errorsTo "Fehler an" HREF
krbName Kerberos-Name DEFAULT
postalAddress Postanschrift MULTILINE
l Ort DEFAULT
textEncodedPSAP Netz-Adresse DEFAULT
presentationAddress Netz-Adresse DEFAULT
supportedApplicationContext Anwendung DEFAULT
publicAccess Zugang DEFAULT
availability Verf&uuml;gbarkeit DEFAULT
knowledgeInformation Kontakt DEFAULT
seeAlso "siehe auch" HREF
roleOccupant Stelleninhabr HREF
manager Manager HREF
administrator Manager HREF
secretary Sekretariat HREF
associatedName "zugeordneter Name" HREF
responsiblePerson Verantwortlicher HREF
domainComponent Domain DEFAULT
labeledURI URL URI
# 2.Bild (see more)
SECOND-PAGE source Quelle DEFAULT
homePostalAddress Heimat-Anschrift MULTILINE
masterDSA Master-DSA HREF
slaveDSA Slave-DSA HREF
lastModifiedTime "letztmalig ge&auml;ndert" DATE
lastModifiedBy "letztmalig ge&auml;ndert von" DEFAULT
lastUpdateTime "letztmalig ge&auml;ndert" DATE
###
### sorting and display of groups of entries
###
# while browsing and searching, entries below the current position
# in the DIT, or the search results, can be grouped according to some
# SORT rules; these rules determine,
# 1. which objectclass should signal a specific group, and in what
# order the entries should be checked for those objectclasses
# (the sequential order of the objectclasses given below),
# 2. what label should be applied to a group (" " means none),
# 3. the order of groups during output,
# 4. the display type for an object of the given object class
# when display´ing a read result, and
# 5. the attribute, that will control sort order of entries
# within each group
# the last two parameters are optional, and will default to display
# type ´default´ (see DISPLAY-OBJECTS), and sort attribute sn (surname)
# (if given in the entry, otherwise the RDN itself)
#
# When an entry has none of the listed object classes, it will NOT be
# included into the display !!!
SORT dNSDomain Dom&auml;ne 8
domain Faxanschl&uuml;sse 9
rfc822MailList X.500-E-Mail-Verteiler 10 rfc822MailList
organizationalPerson Mitarbeiter 1 pers registeredAddress
residentialPerson Privat-Personen 2 pers registeredAddress
person "sonstige Personen" 3 pers registeredAddress
locality Gebiete 7 organization
organization Organisationen 5 organization
organizationalUnit Unterorganisationen 6 organization
alias Verweise 11
country L&auml;nder 4 country
###
### the position of certain language-specific support-files
###
# a help file (accessible via http://host:port/H)
HELPFILE tweb.help.0
# converting certain RDNs to a more user-friendly form)
FRIENDLYFILE ldapfriendly.0
# header and footer beeing attached to every HTML page (not BASEDN)
HEADER tweb.header.0
FOOTER tweb.footer.0
# a special message beeing attached to a HTML page when a allowed
# user accesses the gateway (see ALLOW-STRING/DENY-STRING in tweb.rc)
ALLOW-MSG allow.msg.0
###
### some more settings for (language-specific) gateway-switches (see tweb.rc)
###
# GW-SWITCH "ROOT" http://<my-world-relay.my-domain>:<port0>/M
# "c=<my-country-ID>" http://<my-country-relay.my-domain>:<port0>/
###
### where to prevent listing and provide for searching only
###
# a (list of) DN(s), where no person lists should be display´ed, but
# a search box only (e.g., because to many person are contained in
# here, so list results would be too long); also, which header and
# footer files will be display´ed at that position
# SEARCH-ONLY "ou=<some-ou>, o=<my-organization>, c=<my-country-ID>" search-only.head.0 search-only.foot.0
###
### modifying entries via TWEB
###
# when the user is allowed to modify her own entry, MODIFY/MODATTR will
# describe, what can be modified
#
# BEWARE: this feature is not allowed at the University of Tuebingen,
# so the code is not tested very well; usage is on own risc
# objects of what class can be modified
# (for each class a seperate description>)
# MODIFY person
# what attributes can be modified
# a label in the HTTP formular is given for each attribute,
# together with the maximum count of values, beeing accepted
# in the input area
# MODATTR personalTitle Titel 1
# organizationalStatus Dienststellung 1
# description Beschreibung 2
# telephoneNumber Telefon 2
# facsimileTelephoneNumber FAX 2
# mail Mail-Adresse 2
# roomNumber Raum 1
# memberOfGroup Mailgruppe 10
# homePostalAddress Heimatanschrift 1
# homePhone "privat Telefon" 2
# pager Pager 2
# info Information 2

View File

@ -0,0 +1,208 @@
#*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
# *
# tweb.conf.1 *
# *
# Function:..Configuration-File for TWEB-SOFTWARE *
# *
# *
# *
# Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
# Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
# neuer Dienste, Universitaet Tuebingen, GERMANY *
# *
# ZZZZZ DDD V V *
# Creation date: Z D D V V *
# July 26 1995 Z D D V V *
# Last modification: Z D D V V *
# December 18 1998 ZZZZ DDD V *
# *
#/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/*/
#==========================================================================
# $Id: tweb.conf.1.dist,v 1.6 1999/09/10 15:01:21 zrnsk01 Exp $
# FOR DESCRIPTION OF THE PARAMETERS SEE THE CONFIG FILE tweb.conf.0(.dist)
###
### the description, how to display an object upon read
###
DISPLAY-OBJECT person
# main page
FIRST-PAGE cn Name DEFAULT
personalTitle Title DEFAULT
organizationalStatus Status DEFAULT
description Working-Area DEFAULT
telephoneNumber Telephone DEFAULT
facsimileTelephoneNumber Fax DEFAULT
mail E-Mail-Address MAILTO
textEncodedORaddress X400-Address DEFAULT
postalAddress "Postal address" MULTILINE
roomNumber Room DEFAULT
labeledURI URL URI
# additional page
SECOND-PAGE sn Surname DEFAULT
roleOccupant Role-Occupant HREF
memberOfGroup Group-Member DEFAULT
homepostalAddress Home-Address MULTILINE
homePhone Home-Phone DEFAULT
pager Pager DEFAULT
lastModifiedTime "Last modified Time" DATE
lastModifiedBy "Last modified by" DEFAULT
DISPLAY-OBJECT organization
# main page
FIRST-PAGE o Name DEFAULT
ou Name DEFAULT
l Locality DEFAULT
description Description DEFAULT
postalAddress "Postal address" MULTILINE
telephoneNumber Telephone DEFAULT
facsimileTelephoneNumber Fax DEFAULT
labeledURI URL URI
# additional page
SECOND-PAGE st State DEFAULT
seeAlso "More Information" MOVETO
lastModifiedTime "Last modified Time" DATE
lastModifiedBy "Last modified by" DEFAULT
DISPLAY-OBJECT rfc822MailList
# main page
FIRST-PAGE description Description DEFAULT
joinable Joinable BOOLEAN
associatedDomain E-Mail-Domain DEFAULT
rfc822RequestsTo "Requests to" MAILTO
requestsTo "Requests to" HREF
owner Owner HREF
# additional page
SECOND-PAGE lastModifiedTime "Last modified Time" DATE
lastModifiedBy "Last modified by" DEFAULT
DISPLAY-OBJECT country
# main page
FIRST-PAGE friendlyCountryName Country-Name DEFAULT
associatedDomain Domain DEFAULT
manager Manager HREF
labeledURI URL URI
# additional page
SECOND-PAGE masterDSA Master-DSA HREF
slaveDSA Slave-DSA HREF
lastModifiedTime "Last modified Time" DATE
lastModifiedBy "Last modified by" DEFAULT
lastUpdateTime "Last update Time" DATE
DISPLAY-OBJECT default
# main page
FIRST-PAGE jpegPhoto Photo JPEG
photo Photo BMP
cn Name DEFAULT
sn Surname DEFAULT
textEncodedMtaName MTA-Name DEFAULT
relatedMHSdomain MHS-Domain DEFAULT
description Description DEFAULT
multiLineDescription Description MULTILINE
info "More Information" DEFAULT
productName Productname DEFAULT
mail Mail-Address MAILTO
telephoneNumber Telephone DEFAULT
facsimileTelephoneNumber Fax DEFAULT
labeledURL URL URL
memberOfGroup "Member of Group" DEFAULT
member Member HREF
owner Owner HREF
requestsTo "Requests to" HREF
errorsTo "Errors to" HREF
krbName Kerberos-Name DEFAULT
postalAddress Postal-Address MULTILINE
l Locality DEFAULT
textEncodedPSAP "Network address" DEFAULT
presentationAddress "Network address" DEFAULT
supportedApplicationContext Application DEFAULT
publicAccess Access DEFAULT
availability Availability DEFAULT
knowledgeInformation Contact DEFAULT
seeAlso "See also" HREF
roleOccupant Role-Occupant HREF
manager Manager HREF
administrator Manager HREF
secretary Secretary HREF
associatedName "Associated Name" HREF
responsiblePerson "Responsible person" HREF
domainComponent Domain DEFAULT
labeledURI URL URI
# 2.Page (see more)
SECOND-PAGE source Source DEFAULT
homePostalAddress Home-Address MULTILINE
masterDSA Master-DSA HREF
slaveDSA Slave-DSA HREF
lastModifiedTime "Last modified Time" DATE
lastModifiedBy "Last modified by" DEFAULT
lastUpdateTime "Last update Time" DATE
###
### sorting and display of groups of entries
###
SORT dNSDomain Domain 8
domain Fax 9
rfc822MailList X.500-E-Mail-List 10 rfc822MailList
organizationalPerson Staff 1 person registeredAddress
residentialPerson Residentials 2 person registeredAddress
person Persons 3 person registeredAddress
locality Localities 7 organization
organization Organizations 5 organization
organizationalUnit "Organizational Units" 6 organization
alias Aliases 11
country Countries 4 country
###
### the position of certain language-specific support-files
###
HELPFILE tweb.help.1
FRIENDLYFILE ldapfriendly.1
HEADER tweb.header.1
FOOTER tweb.footer.1
ALLOW-MSG allow.msg.1
###
### some more settings for (language-specific) gateway-switches (see tweb.rc)
###
# GW-SWITCH "ROOT" http://<my-world-relay.my-domain>:<port1>/M
# "c=<my-country-ID>" http://<my-country-relay.my-domain>:<port1>/
###
### where to prevent listing and provide for searching only
###
# SEARCH-ONLY "ou=<some-ou>, o=<my-organization>, c=<my-country-ID>" search-only.head.1 search-only.foot.1
###
### modifying entries via TWEB
###
# MODIFY person
# MODATTR personalTitle Title 1
# organizationalStatus Status 1
# description Description 2
# telephoneNumber Telephone 2
# facsimileTelephoneNumber Fax 2
# mail "E-Mail address" 2
# roomNumber Room 1
# memberOfGroup Group-Member 10
# homePostalAddress "Home address" 1
# homePhone "Home phone" 2
# pager Pager 2
# info Information 2

View File

@ -0,0 +1,150 @@
#*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
# *
# tweb.lang.0 *
# *
# Function:..Language-File for TWEB-SOFTWARE *
# *
# *
# *
# Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
# Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
# neuer Dienste, Universitaet Tuebingen, GERMANY *
# *
# ZZZZZ DDD V V *
# Creation date: Z D D V V *
# February 14 1996 Z D D V V *
# Last modification: Z D D V V *
# February 20 1997 ZZZZ DDD V *
# *
#/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/*/
#
# $Id: tweb.lang.0.dist,v 1.6 1999/09/10 15:01:22 zrnsk01 Exp $
0 de
1 [not used]
2 [not used]
3 [not used]
4 [not used]
5 Kommando nicht implementiert!
6 Nicht gefunden
7 Last-Modified
8 &Auml;ndere Ergebnisse:
9 &Auml;nderungs-Ergebnisse f&uuml;r
10 &Auml;nderungen:
11 Fehler w&auml;hrend &Auml;nderungs-Operation:
12 L&Ouml;SCHE alten Wert
13 von Attribut
14 Der Fehler-Kode war
15 &Auml;nderung
16 Erfolgreich ausgef&uuml;hrt
17 Lese diesen ge&auml;nderten Wert
18 Benutzer-Passwort
19 &Auml;ndere diesen Eintrag erneut
20 Die angegebene Abfrage war nicht spezifisch genug, wodurch ein Sizelimit
&uuml;berschritten wurde, wobei die ersten paar &Uuml;bereinstimmungen
zur&uuml;ckgegeben wurden. Falls Sie nicht den gesuchten Eintrag
gefunden haben, machen Sie bitte eine genauere Abfrage,
zum Beispiel mit Vor- und Nachnamen.
21 Die Anzahl der gefundenen Eintr&auml;ge hat eine systemseitig
vorgegebene Obergrenze &uuml;berschritten. Falls der gesuchte Eintrag
in der dargestellten Liste nicht vorhanden ist, nutzen Sie die
<STRONG>Such</STRONG>-Option, um das Gesuchte genauer zu spezifizieren.
22 Fehler
23 X.500 - WWW Fehler:
24 Beim Durchsuchen von X.500 tauchte ein Fehler auf
25 Der Fehlercode war
26 Es ist keine zus&auml;tzliche Information erh&auml;ltlich.
27 Liste unterhalb von
28 aktuelle Position:
29 About
30 Suche:
31 Wir haben nicht die entsprechenden Zugriffsrechte, um hier eine globale
Suche zu starten, aber wenn Sie wissen, wen Sie suchen, benutzen Sie die
<STRONG>Such</STRONG>-Option oben mit dem Namen des
gew&uuml;nschten Eintrages.
32 Habe nichts unter diesem Eintrag gefunden. Sie k&ouml;nnen den Eintrag
selbst lesen, oder eine Suche probieren ...
33 (eingeschr&auml;nkte Liste
34 siehe Fu&szlig;note
35 suche in
36 Keine Suchergebnisse:
37 Habe nichts gefunden ...
38 f&uuml;r
39 Suchergebnisse:
40 Suchergebnisse f&uuml;r
41 <H2>X.500 - WWW Fehler:</H2><P>Bei der Darstellung des X.500 Eintrages
tauchte ein Fehler auf. <P>Keine bekannte Object-Klasse
f&uuml;r diesen Eintrag.<P>
42 Weitere Informationen
43 VORSICHT: Dies ist noch <B>EXPERIMENTELL</B>!!!
44 Geben Sie das Passwort f&uuml;r diesen Eintrag ein
45 wenn Sie ihn
46 &uuml;bermitteln wollen
47 &Auml;NDERN
48 wollen
49 Fehlendes Passwort!
50 Unbekanntes Argument
51 &Auml;ndern
52 altes Passwort
53 VORSICHT: Dies ist noch EXPERIMENTELL!!!
54 Fehler in der Abfrage: Kein Wert
55 f&uuml;r
56 Fehler in der Abfrage: Kein alter Wert
57 <B>Fehler w&auml;hrend der Modifikation:</B><P>Neuen Wert HINZUF&Uuml;GEN
58 zum Attribut
59 Der Fehlercode war
60 <B>Fataler Fehler:</B><BR>Konnte den alten Wert nicht zur&uuml;cksetzen
61 auf Attribut
62 Setze den alten Wert wieder
63 auf Attribut
64 Mail an:
65 Aus datenschutzrechtlichen Gr&uuml;nden werden <strong>keine</strong>
umfangreichen Personenlisten ausgegeben. Falls die gesuchte Person
in der angezeigten Teilliste nicht vorhanden ist, verwenden Sie die
<STRONG>Such</STRONG>-Option, um die gesuchte Person genauer
zu spezifizieren.<BR>
66 Einstufige Suche
67 suche unterhalb nach...
68 SUCHEN
69 Eingabe l&ouml;schen
70 Eintrag
71 Eintr&auml;ge
72 Eintr&auml;ge zuruecksetzen
73 en
74 gel&ouml;scht
75 ersetzt
76 hinzugef&uuml;gt
77 Welt
78 Ja
79 Nein
80 <B>Fataler Fehler:</B><BR>Konnte den Wert nicht modifizieren
81 bei Attribut
82 http://ambix.uni-tuebingen.de/cgi-bin/selbst
83 http://ambix.uni-tuebingen.de/selbstinfo.html
84 <FORM METHOD=POST ACTION=%s>Selbsteintrag:
85 <INPUT type=hidden name="aloc" value="%s">
<INPUT TYPE="submit" name="worker" VALUE="Angestellte">
86 <INPUT type=hidden name="sloc" value="%s">
<INPUT TYPE="submit" name="studie" VALUE="Studierende">
87 </FORM>
88 Ung&uuml;ltige Anfrage
89 <EM>Fehlender Such-Filter!</EM>
90 <EM>Fehlender Scope!</EM>
91 [not used]
92 <EM>Fehlender Suchbegriff!</EM> <P>Bitte geben Sie einen Suchbegriff an!
93 <EM>Fehlender DN!</EM>
94 <EM>Fehlendes Passwort!</EM>
95 <EM>Unbekannte Abfrage!</EM>
96 <H1>ZUGRIFF VERWEIGERT</H1>
Die angefragten Daten stehen &uuml;ber diesen Server nicht zur
Verf&uuml;gung!<br>Bitte benutzen Sie folgende URL:
97 <H1>ZUGRIFF VERWEIGERT</H1>
98 ...lesen
99 %s<H6>Daten erstellt durch %s <br>
&copy; TWEB: Zentrum f&uuml;r Datenverarbeitung,
Universit&auml;t T&uuml;bingen, Deutschland</H6>
100 BODY BGCOLOR=#ffffe0 TEXT=#000000 LINK=#0000a0 VLINK=#00a000 font-family="times serif"
101 <HR>
102 <BR><H1>Der Name Ihres Hosts ist nicht verfuegbar. Sie sehen deshalb nicht alle Daten!</H1><BR>
103 [not used]
104 Wenn Sie mehr Daten sehen wollen, schalten Sie Ihren Proxy-Server aus !

View File

@ -0,0 +1,136 @@
#*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
# *
# tweb.lang.1 *
# *
# Function:..Language-File for TWEB-SOFTWARE *
# *
# *
# *
# Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
# Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
# neuer Dienste, Universitaet Tuebingen, GERMANY *
# *
# ZZZZZ DDD V V *
# Creation date: Z D D V V *
# February 14 1996 Z D D V V *
# Last modification: Z D D V V *
# February 20 1997 ZZZZ DDD V *
# *
#/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/*/
#
# $Id: tweb.lang.1.dist,v 1.6 1999/09/10 15:01:22 zrnsk01 Exp $
0 en
1 [not used]
2 [not used]
3 [not used]
4 [not used]
5 Command not implemented!
6 Not found
7 Last-Modified
8 Modify results:
9 Modify results for
10 Changes:
11 Error during modify operation:
12 DELETE old value
13 from attribute
14 The error code was
15 change
16 successfully done
17 Read this modified entry
18 userPassword
19 Modify this entry again
20 The query you specified was not specific enough, causing a size limit to be exceeded and the first several matches found to be returned.<br>If you did not find the match you were looking for, try issuing a more specific query, for example one that contains both first and last name.<br>
21 Not all entries could be returned because a size limit was exceeded.<br>There is no way to defeat this feature, but if you know who you are looking for, try choosing the <STRONG>Search</STRONG> option listed above and specifying the name of the entry you want.<br>
22 Error
23 X.500 - WWW Error:
24 An error occurred searching X.500
25 The error code was
26 No additional information is available.
27 Move upwards to
28 current location:
29 About
30 search:
31 We don't have the access right to do a global search here. If you know who you are looking for, try choosing the <STRONG>Search</STRONG> option listed above and specifying the name of the entry you want.<br>
32 Didn't find anything below this entry! You can read the entry itself or try a search ...
33 (restricted list
34 see below
35 search in
36 No search results:
37 Didn't find anything...
38 for
39 Search results:
40 Search results for
41 <H2>X.500 - WWW Error:</H2><P>An error occurred showing X.500 entry. <P>No known object-class for this entry.<P>
42 See more attributes
43 Beware, this is still <B>EXPERIMENTAL</B>!!!
44 Enter the password of this entry
45 if you want to
46 submit
47 MODIFY
48 it
49 Missing Password!
50 Unknown argument
51 Modify
52 oldPassword
53 Beware, this is still EXPERIMENTAL!!!
54 Error in query: No value
55 for
56 Error in query: No oldvalue
57 <B>Error during modify operation:</B><P><P>ADD new value
58 to attribute
59 The error code was
60 <B>Fatal Error:</B><BR>Couldn't reset the old value
61 to attribute
62 Reset the old value
63 to attribute
64 mailto:
65 Due to Legal Rights no extended lists of persons will be displayed.
If the requested person is not in the list shown, please use the
<STRONG>Search</STRONG>-option with a more significant personal name.
<BR>
66 Onelevel search
67 search below for...
68 SEARCH
69 DELETE INPUT
70 entry
71 entries
72 RESET Values
73 s
74 deleted
75 replaced
76 added
77 The World
78 Yes
79 No
80 <B>Fatal Error:</B><BR>Couldn't modify the value
81 at attribute
82 http://ambix.uni-tuebingen.de/cgi-bin/selbst
83 http://ambix.uni-tuebingen.de/selbstinfo.html
84 <FORM METHOD=POST ACTION=%s>Self-subscription:
85 <INPUT type=hidden name="aloc" value="%s">
<INPUT TYPE="submit" name="worker" VALUE="Staff">
86 <INPUT type=hidden name="sloc" value="%s">
<INPUT TYPE="submit" name="studie" VALUE="Students">
87 </FORM>
88 Bad request
89 <EM>Missing filter!</EM>
90 <EM>Missing scope!</EM>
91 [not used]
92 <EM>Missing search value!</EM> <P>Please specify a search value.
93 <EM>Missing DN!</EM>
94 <EM>Missing password!</EM>
95 <EM>Unknown query!</EM>
96 <H1>ACCESS DENIED</H1>
The requested data are not delivered via this server!<br>
Please use the following URL:
97 <H1>ACCESS DENIED</H1>
98 ...read it
99 %s<H6>Data composed by %s <br>
&copy; TWEB: Zentrum fuer Datenverarbeitung,
Universitaet Tuebingen, GERMANY</H6>
100 BODY BGCOLOR=#ffffe0 TEXT=#000000 LINK=#0000a0 VLINK=#00a000
101 <HR>
102 <BR><H1>The name of your host is not available. Therefore you don't see the whole database!</H1><BR>
103 [not used]
104 If you want to see more data, please inactivate your proxy-server !

View File

@ -0,0 +1,233 @@
#*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
# *
# tweb.rc.... *
# *
# Function:..Ressource-File for TWEB *
# *
# *
# *
# Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
# Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
# neuer Dienste, Universitaet Tuebingen, GERMANY *
# *
# ZZZZZ DDD V V *
# Creation date: Z D D V V *
# July 26 1995 Z D D V V *
# Last modification: Z D D V V *
# January 11 1999 ZZZZ DDD V *
# *
#/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/*/
#==========================================================================
# $Id: tweb.rc.dist,v 1.6 1999/09/10 15:01:22 zrnsk01 Exp $
##########################################################################
# #
# set the following variables to your local addresses (NEEDED) #
# check also for the location of certain help files #
# and proper timeout #
# #
##########################################################################
# the base port, TWEB is listening on;
# indizes for the languages are added to this base port number
# (e.g., TWEB with language 1 is listening on port (WEBPORT + 1))
WEBPORT <the-base-port-tweb-should-listen-to>
# the host and port, your x500 server (e.g., UMICH slapd) is listening on
LDAPD <the-host-running-your-ldap-server>
LDAPPORT <the-port-of-that-ldapserver>
#------------------------------------------------------------------------#
# the DN, TWEB will consider it´s home, together with header and
# footer files to be display´ed at that position
#
# the BASEDN will be accessed, when NO DN is given (http://host:port/
# the BASEDN will be stripped off from hyperlinks beeing display´ed
# access to DIT areas NOT below BASEDN will be denied, if STRICT-BASEDN
# (see tweb.rc(.dist)) is activ
#
# BEWARE: HEADER AND FOORTER FILE NAMES ARE ONLY THE BASE NAMES; THE
# CORRESPONDING WORKING FILES MUST HAVE EXTENSIONS OF '.x'
# WITH x INDICATING THE DESIRED GATEWAY LANGUAGE NUMBER (0-9)
BASEDN "o=<my-organization>, c=<my-country-ID>" tweb-base.head tweb-base.foot
#------------------------------------------------------------------------#
# assuming you have copied the binary into the TWEB_conFiles directory,
# the ETCDIR directory should be a parallel directory of the current one
ETCDIR ../LDAP_etc/
# the filter file directs the mode, TWEB will search for entries
# (e.g., first search input as is in attribute cn, then search
# for any one word in attributes cn and/or sn ... )
FILTERFILE ldapfilter.conf
# the time in secs, TWEB will try to get a connection to the x500 server
TIMEOUT 240
##########################################################################
# #
# check the following variables for proper access rights #
# and handling of entry lists/legal hints #
# (NOT NEEDED FOR FIRST START-UP) #
# #
##########################################################################
# DN and password of an x500 entry, TWEB will use, when access of the
# user to the servers data is without restrictions
#
# WEBDN "cn=<TWEB-DN-1>, o=<your-organization>, c=<your-country>"
# WEBPW <TWEB-PW-1>
# DN (and password) of an x500 entry, TWEB will use, when access of the
# user to the servers data is restricted (e.g., external users);
# a NULL password (by not configuring) will lead to anonymous access,
# irrespective, whether the DN is given or not
#
# WEBDN2 "cn=<TWEB-DN-2>, o=<your-organization>, c=<your-country>"
# WEBPW2 <TWEB-PW-2>
# Refuse/grant service to certain IP hosts/domains names;
# both settings will be checked when deciding deniel of service;
# the most special definition for the host given will dominate
# (settings can be given by using regular expressions, to cover more than
# one host/domain with one expression; alternatives, which should be
# or'ed must be seperated by '|')
# (continuations can be given on follow-up lines, whith no additional
# character at the end of the previous line, and an indentation by
# TAB or SPACE on the follow-up line)
#
# REFUSE some-host(\.some-sub-domain)?\.some-domain$|another-domain$|
# ^some-initial-char[0-9]+.+\.some-domain$
# GRANT (host1|host2|host3).*\.another-domain$
# When service is granted to the requesting host, allow-string/deny-string
# decide on full or restricted access to the servers data; in both cases
# one of WEBDN1/WEBDN2 (or anonymous if not configured) is used for
# accessing the server;
# ACLs on the server must be set accourding to the required visibility of
# data (see description of ACLs in the servers documentation)
# (host/domain names are given as with GRANT/REFUSE)
#
# ALLOW-STRING my-domain$
# DENY-STRING some-special-host/sub-domain-in-my-domain\.my-domain$
# Consider WWW proxies as not authorized to get un-restricted access
# NO-PROXY
# Consider the explicit list of proxies as authorized to get full access
# (the list is as colon-seperated list of host names)
# ALLOW-PROXY proxy.in.my.domain:some-proxy.in.another.domain
# Refuse access to DNs, outside the scope of TWEBs BASEDN
# (this is necessary, if no referral mechanism is working on the
# x500 server level; e.g., with slapd in the UMICH package)
# STRICT-BASEDN
# Activate anti-hacking code: count access from a range of IP adresses
# (IP-Group) to the gateway during a timeslice (randomly selected between
# a minimum and maximum number of secs); if the count exceeds a pre-
# defined maximum, refuse service for a certain number of timeslices;
# after that resume service for the IP-Group
# Print statistics for number of accesses from all IP-Groups to file,
# at regular intervalls
#
# COMREFUSE TMIN TMAX MAX_ACCEPT SUSPEND_CYCLE STAT_CYCLE STAT_FILE
COMREFUSE 100 200 40 12 43200 /LDAP/ldap-3.0/tweb-1.0/hack-stats
#------------------------------------------------------------------------#
# The maximum number of entries display'ed on any one HTML page
MAXCOUNT 2000
# During searching/browsing restrict the number of person entries to the
# given number; numbers apply to each of the person groups given by the
# SORT parameter
# STRICT means, even allowed access will be restricted in numbers
# NO-BROWSE means, during browsing no person entries are shown at all
# MAX-PERSON 5 STRICT NO-BROWSE
# List of (parts of ) RDNs, which should not be display'ed
# For the current release, strings are seperated by BLANK, with forced
# matching to the beginning or end of an RDN signalled by '|';
# in a future release, this will be replaced by regular expressions,
# very like as in GRANT/REFUSE and beasts
NO-SHOW-RDN "|cn=Dummy| netz| LDAP-SAP Mail500|"
# Print a legal message for restricted users;
# normally, this message is printed at the end of the HTML page,
# with ON-TOP, the message can be printed near the top of the page
#
# LEGAL ON-TOP
##########################################################################
# #
# configure TWEB gateway-switching #
# #
##########################################################################
# Gateway-switching is an original feature of the TWEB, www-x500-gateway.
# Switching enables TWEB to generate hyper-links, that are directed towards
# other well-known gateways. Following those hyper-links will lead the
# user to those gateways, effectively balancing the load between a net
# of gateways. Another benefit is the 'Corporate Identity' each gateway
# can implement for an organizations own directory data.
#
# Gateway-switching can be configured statically, in the config files
# tweb.rc and/or tweb.conf.? , or dynamically, via hints in the
# directory data to be display'ed.
#
# Select dynamic gateway-switching: TWEB will look for labeleduri
# attributes within each entry to be display'ed as a hyper-link
# before constructing the host-part of the hyper-link URL; the
# labelleduri attribut must follow the syntax:
# <base-url-of-the-other-gateway> <some-label> (gw[-<language-key>])
# The DN of the entry will be appended to the base-url, if the language
# selection matches, or no specific selection is given (gw)
#
DYNAMIC-GW
# Configure static gateway switches; they may be replaced at run-time by
# dynamic switches (in tweb.rc, gateways, which only support one language
# are given; gatways supporting more languages are defined in the
# tweb.conf.? files)
GW-SWITCH "l=DFN,c=DE" http://ambix.uni-tuebingen.de:8889/
##########################################################################
# #
# some miscelleneous configuration parameters #
# #
##########################################################################
# the labelling of buttons/links leading to gateways with other languages
LANGUAGE Deutsch
English
# the hierarchy above the current DIT position is presented as a
# pull down menu and an action button, or as a list of hyperlinks
PULL-DOWN-MENUS
# entries are kept for some time in a WWW browser´s or proxy´s cache,
# before expiring
CACHE-EXPIRE-DEFAULT 900
# digits at the end of RDNs (e.g., to make RDNs unique) are stripped
# off before displaying; in the config parameter a list of object
# classes with stripping in the RDN parts is given
# STRIP-PIN |toc_profs|person|toc_primas|toc_cperson|toc_funcs|toc_pextra|
# when MODIFY is configured (in tweb.conf.x), entries belonging to
# the object class(es) given here can NOT be modified
# NO-MODIFY |toc_primas|

41
contrib/tweb/Versiongw.c Normal file
View File

@ -0,0 +1,41 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* Versiongw.c *
* *
* Function:..File for TWEB-SOFTWARE *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* February 13 1996 Z D D V V *
* Last modification: Z D D V V *
* August 26 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: Versiongw.c,v 1.6 1999/09/10 15:01:16 zrnsk01 Exp $
*
*/
/*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Tuebingen, Gremany. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*/
char version[] = "TWEB 2.3.4 (%WHEN%)";
char Version[] = " TWEB 2.3.4 (%WHEN%)\t%WHOANDWHERE%";
char copyright[] = "TWEB Version 2.3.4";
char sccsid[] = "@(#) TWEB 2.3.4 - 1995-1999, University of Tuebingen, DE";

85
contrib/tweb/ch_malloc.c Normal file
View File

@ -0,0 +1,85 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* ch_malloc.c *
* *
* Function:..Alloc-Functions with Error-Handling *
* *
* from LDAP3.2 University of Michigan *
* *
* Patch: unsigned long --> size_t fuer size-Parameter *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* April 16 1996 Z D D V V *
* Last modification: Z D D V V *
* December 31 1998 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: ch_malloc.c,v 1.6 1999/09/10 15:01:16 zrnsk01 Exp $
*
*/
#include "tgeneral.h"
#include "tglobal.h"
#include "ch_malloc_exp.h"
#include "support_exp.h"
/* ch_malloc.c - malloc routines that test returns from malloc and friends */
PUBLIC char * ch_malloc( size )
size_t size;
{
char *new;
if ( (new = (char *) calloc(1, size )) == NULL ) {
if (dosyslog) syslog( LOG_INFO, "malloc of %d bytes failed\n", size );
exit_tweb( 1 );
}
return( new );
}
/* end of function: ch_malloc */
PUBLIC char * ch_realloc( block, size )
char *block;
size_t size;
{
char *new;
if ( block == NULL ) {
return( ch_malloc( size ) );
}
if ( (new = (char *) realloc( block, size )) == NULL ) {
if (dosyslog) syslog( LOG_INFO, "realloc of %d bytes failed\n", size );
exit_tweb( 1 );
}
return( new );
}
/* end of function: ch_realloc */
PUBLIC char * ch_calloc( nelem, size )
size_t nelem;
size_t size;
{
char *new;
if ( (new = (char *) calloc( nelem, size )) == NULL ) {
if (dosyslog) syslog( LOG_INFO, "calloc of %d elems of %d bytes failed\n",
nelem, size );
exit_tweb( 1 );
}
return( new );
}
/* end of function: ch_calloc */

View File

@ -0,0 +1,34 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* ch_malloc_exp.h *
* *
* Function:..File for TWEB-SOFTWARE *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* April 16 1996 Z D D V V *
* Last modification: Z D D V V *
* November 21 1996 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: ch_malloc_exp.h,v 1.6 1999/09/10 15:01:16 zrnsk01 Exp $
*
*/
#ifndef _CH_MALLOC_EXP_
#define _CH_MALLOC_EXP_
PUBLIC char * ch_malloc();
PUBLIC char * ch_realloc();
PUBLIC char * ch_calloc();
#endif /* _CH_MALLOC_EXP_ */

179
contrib/tweb/charray.c Normal file
View File

@ -0,0 +1,179 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* charray.c.. *
* *
* Function:..Array-Handling-Functions *
* *
* from LDAP3.2 University of Michigan *
* *
* Patch: NULL-Pointers are caught in Arrays/Strings *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* April 16 1996 Z D D V V *
* Last modification: Z D D V V *
* December 21 1998 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: charray.c,v 1.6 1999/09/10 15:01:16 zrnsk01 Exp $
*
*/
#include "tgeneral.h"
#include "charray_exp.h"
#include "ch_malloc_exp.h"
/* charray.c - routines for dealing with char * arrays */
PUBLIC void charray_add( a, s )
char ***a;
char *s;
{
int n;
if ( s == NULL )
return;
if ( *a == NULL ) {
*a = (char **) ch_malloc( 2 * sizeof(char *) );
n = 0;
} else {
for ( n = 0; *a != NULL && (*a)[n] != NULL; n++ ) {
; /* NULL */
}
*a = (char **) ch_realloc( (char *) *a,
(n + 2) * sizeof(char *) );
}
(*a)[n++] = strdup(s);
(*a)[n] = NULL;
}
/* end of function: charray_add */
PUBLIC void charray_merge( a, s )
char ***a;
char **s;
{
int i, n, nn;
if ( s == NULL )
return;
for ( n = 0; *a != NULL && (*a)[n] != NULL; n++ ) {
; /* NULL */
}
for ( nn = 0; s[nn] != NULL; nn++ ) {
; /* NULL */
}
*a = (char **) ch_realloc( (char *) *a, (n + nn + 1) * sizeof(char *) );
for ( i = 0; i < nn; i++ ) {
(*a)[n + i] = s[i];
}
(*a)[n + nn] = NULL;
}
/* end of function: charray_merge */
PUBLIC void charray_free( array )
char **array;
{
char **a;
if ( array == NULL ) {
return;
}
for ( a = array; *a != NULL; a++ ) {
if ( *a != NULL ) {
free( *a );
}
}
free( (char *) array );
}
/* end of function: charray_free */
PUBLIC int charray_inlist( a, s )
char **a;
char *s;
{
int i;
if (( a == NULL ) || ( s == NULL ))
return( 0 );
for ( i = 0; a[i] != NULL; i++ ) {
if ( strcasecmp( s, a[i] ) == 0 ) {
return( 1 );
}
}
return( 0 );
}
/* end of function: charray_inlist */
PUBLIC char ** charray_dup( a )
char **a;
{
int i;
char **new;
if ( a == NULL )
return( NULL );
for ( i = 0; a[i] != NULL; i++ )
; /* NULL */
new = (char **) ch_malloc( (i + 1) * sizeof(char *) );
for ( i = 0; a[i] != NULL; i++ ) {
new[i] = strdup( a[i] );
}
new[i] = NULL;
return( new );
}
/* end of function: charray_dup */
PUBLIC char ** str2charray( str, brkstr )
char *str;
char *brkstr;
{
char **res;
char *s;
int i;
char *str1;
if (( str == NULL ) || ( brkstr == NULL )) return( (char **) NULL );
str1 = strdup(str);
i = 1;
for ( s = str1; *s; s++ ) {
if ( strchr( brkstr, *s ) != NULL ) {
i++;
}
}
res = (char **) ch_malloc( (i + 1) * sizeof(char *) );
i = 0;
for ( s = strtok( str1, brkstr ); s != NULL; s = strtok( NULL,
brkstr ) ) {
res[i++] = strdup( s );
}
res[i] = NULL;
free(str1);
return( res );
}
/* end of function: str2charray */

View File

@ -0,0 +1,37 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* charray_exp.h *
* *
* Function:..File for TWEB-SOFTWARE *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* April 16 1996 Z D D V V *
* Last modification: Z D D V V *
* November 21 1996 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: charray_exp.h,v 1.6 1999/09/10 15:01:16 zrnsk01 Exp $
*
*/
#ifndef _CHARRAY_EXP_
#define _CHARRAY_EXP_
PUBLIC void charray_add();
PUBLIC void charray_merge();
PUBLIC void charray_free();
PUBLIC int charray_inlist();
PUBLIC char ** charray_dup();
PUBLIC char ** str2charray();
#endif /* _CHARRAY_EXP_ */

258
contrib/tweb/checkclient.c Normal file
View File

@ -0,0 +1,258 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* checkclient.c *
* *
* Function:..Client-Check-Funktions *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* March 7 1996 Z D D V V *
* Last modification: Z D D V V *
* March 19 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: checkclient.c,v 1.6 1999/09/10 15:01:16 zrnsk01 Exp $
*
*/
#include "tgeneral.h"
#include "tglobal.h"
#include "init_exp.h"
#include "charray_exp.h"
#include "checkclient.h"
#include "regular_exp.h"
PRIVATE int check4access (host, glob)
char *host;
GLOB_STRUCT *glob;
/*
* check if host ends in a valid domain.
* return OK if so, NOTOK otherwise
*/
{
return(
(glob->allow_string ? checkad(host, glob->comp_allow, glob) : OK) &&
(glob->deny_string ? !checkad(host, glob->comp_deny, glob) : OK));
}
/* end of function: check4access */
PRIVATE int checkad (host, string, glob)
char *host;
regexp *string;
GLOB_STRUCT *glob;
{
char nhost[BUFSIZ];
strcpy(nhost, host ? host : "unknown.xxx");
return( tweb_regexec( string, nhost ));
}
/* end of function: checkad */
/* Analyse Web-Client-Type / proxy + Log-Message */
PUBLIC void checkwwwclient (fp, ip_addr, ip_port, hp, glob)
FILE *fp;
char *ip_addr;
unsigned int ip_port;
struct hostent *hp;
GLOB_STRUCT *glob;
{
char in[BUFSIZ];
char agent[BUFSIZ], via[BUFSIZ];
char *host = hp ? hp->h_name : "unknown";
*via = *agent = '\0';
if(!((glob->grant ? checkad(host, glob->comp_grant, glob) : OK) &&
(glob->refuse ? !checkad(host, glob->comp_refuse, glob) : OK))){
if (dosyslog)
syslog (LOG_INFO, "%s REFUSED <%08d>",
glob->server_connection_msg, glob->svc_cnt);
fflush(fp);
if (http == 1) PRINT_HTML_HEADER;
fprintf( fp, HTML_HEAD_TITLE, "ACCESS DENIED", glob->la[100]);
disp_file(glob, glob->header, fp);
fprintf(fp, "%s", glob->la[97]);
disp_file(glob, glob->footer, fp);
PRINT_HTML_FOOTER;
close_ldap_connections(glob);
exit_tweb(0);
}
glob->is_proxy = FALSE;
while(fgets( in, BUFSIZ-1, fp ) && *trimright(in, WSPACE) ) {
if(strstr(in, "User-Agent:")){
strcpy(agent, in);
if(strstr(str_tolower(in), PROXY_TOKEN1) ||
strstr(in, PROXY_TOKEN2))
glob->is_proxy = TRUE;
}
if(strstr(in, "Via:")){
strcpy(via, in);
glob->is_proxy = TRUE;
}
}
if (dosyslog){
char useragent[BUFSIZ];
sprintf(useragent, "%s (%s,%u) %s",
*agent ? agent : "User-Agent: unknown",
ip_addr, ip_port, via);
glob->user_agent_msg = strdup(useragent);
}
/* check if access is allowed ... */
glob->allowed =
( hp
&& ((check4access(str_tolower(hp->h_name), glob) == OK))
&& !( glob->no_proxy && glob->is_proxy
&& !charray_inlist(glob->allow_proxy, hp->h_name)
)
);
}
/* end of function: checkwwwclient */
PUBLIC void decide_access(glob)
GLOB_STRUCT *glob;
{
if(!glob->allowed) {
/* access from a non allowed computer
==> put webdn/webpw on a alternative value (if existant) */
glob->webdn = glob->webdn2;
glob->webpw = glob->webpw2;
glob->noauth = TRUE;
if (dosyslog) syslog (LOG_INFO, "%s DENIED <%08d>",
glob->server_connection_msg, glob->svc_cnt);
} else {
/* if allowed and not strict: list persons without limits */
if (!glob->strict) glob->max_person = 0;
if (dosyslog) syslog (LOG_INFO, "%s ALLOWED <%08d>",
glob->server_connection_msg, glob->svc_cnt);
}
if (dosyslog) syslog (LOG_INFO, "%s <%08d>",
glob->user_agent_msg, glob->svc_cnt);
/* non configured max-person means full listing */
if (!glob->max_person) glob->max_person = 100000;
/* if result-lists shall be restricted: configure display of
privacy-message */
glob->legal = glob->legal && (!glob->allowed || glob->strict);
/* if browsing should be restricted: configure no_browse-variable */
glob->no_browse = glob->no_browse &&
(glob->noauth || glob->strict);
}
/* end of function: decide_access */
/* Read ip_refuse dat_file and build up the data structure */
PUBLIC void get_ip_refuse_clients(glob)
GLOB_STRUCT *glob;
{
if ( glob->ip_refuse ) {
FILE *rfp;
char inLine[BUFSIZ];
char *inLineP;
size_t buflen = REFU_BUFSIZ;
size_t curlen = (size_t) 1;
if(!(rfp = fopen(glob->ip_refuse->dat_file, "r"))) {
return;
}
if ( glob->ip_refuse->refu_str ) free( glob->ip_refuse->refu_str );
glob->ip_refuse->refu_str = ch_calloc( 1, REFU_BUFSIZ );
*glob->ip_refuse->refu_str = '&';
while(fgets(inLine, BUFSIZ-1, rfp)) {
int inLen;
if ( ( inLineP = strchr( inLine, '#' ) )) *inLineP = '\0';
inLineP = trim(inLine, " \t\n");
if ( *inLineP == '\0' ) continue;
inLen = strlen( inLineP );
if ( !( curlen + inLen + 1 < buflen )) {
glob->ip_refuse->refu_str =
ch_realloc( glob->ip_refuse->refu_str,
buflen + REFU_BUFSIZ );
buflen += REFU_BUFSIZ;
}
sprintf( glob->ip_refuse->refu_str, "%s%s&",
glob->ip_refuse->refu_str, inLineP );
curlen += inLen;
}
fclose( rfp );
}
} /* get_ip_refuse_clients */
/* Routine needed to initialize structure in init.c */
/* Test the incomming IP address for denial */
PUBLIC int
check_ip_denial( ip_connection, glob )
struct sockaddr_in *ip_connection;
GLOB_STRUCT *glob;
{
int res = OK;
if ( glob->ip_refuse ) {
char ip_address[18];
sprintf( ip_address, "&%s&", inet_ntoa( ip_connection->sin_addr ));
if ( strstr( glob->ip_refuse->refu_str, ip_address ))
res = NOTOK;
}
return( res );
} /* check_ip_denial */
/* re-read IP-REFUSE file if necessary */
PUBLIC void
re_readIPrefuse( glob )
GLOB_STRUCT *glob;
{
static int ip_refuse_reload = 0;
if ( glob->ip_refuse &&
!( ++ip_refuse_reload % glob->ip_refuse->rereadcycle )) {
get_ip_refuse_clients( glob );
}
} /* re_readIPrefuse */

View File

@ -0,0 +1,41 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* checkclient.h *
* *
* Function:..File for TWEB-SOFTWARE *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* March 18 1996 Z D D V V *
* Last modification: Z D D V V *
* March 19 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: checkclient.h,v 1.6 1999/09/10 15:01:16 zrnsk01 Exp $
*
*/
#include "checkclient_exp.h"
#include "regular_exp.h"
#include "support_exp.h"
#include "x500_exp.h"
#include "charray_exp.h"
#include "ch_malloc_exp.h"
#ifndef _CHECKCLIENT_
#define _CHECKCLIENT_
#define PROXY_TOKEN1 " via "
#define PROXY_TOKEN2 "gateway"
PRIVATE int checkad();
PRIVATE int check4access();
#endif /* _CHECKCLIENT_ */

View File

@ -0,0 +1,35 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* checkclient_exp.h *
* *
* Function:..File for TWEB-SOFTWARE *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* March 18 1996 Z D D V V *
* Last modification: Z D D V V *
* March 19 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: checkclient_exp.h,v 1.6 1999/09/10 15:01:16 zrnsk01 Exp $
*
*/
#ifndef _CHECKCLIENT_EXP_
#define _CHECKCLIENT_EXP_
PUBLIC void checkwwwclient();
PUBLIC void decide_access();
PUBLIC void get_ip_refuse_clients();
PUBLIC int check_ip_denial();
PUBLIC void re_readIPrefuse();
#endif /* _CHECKCLIENT_EXP_ */

200
contrib/tweb/dn.c Normal file
View File

@ -0,0 +1,200 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* dn.c....... *
* *
* Function:..DN-Handling-Functions *
* *
* from LDAP3.2 University of Michigan *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* April 24 1996 Z D D V V *
* Last modification: Z D D V V *
* December 14 1996 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: dn.c,v 1.6 1999/09/10 15:01:16 zrnsk01 Exp $
*
*/
/* dn.c - routines for dealing with distinguished names */
#include "tgeneral.h"
#include "strng_exp.h"
#include "dn.h"
/*
* dn_normalize - put dn into a canonical format. the dn is
* normalized in place, as well as returned.
*/
PUBLIC char * dn_normalize( dn )
char *dn;
{
char *d, *s;
int state, gotesc;
/* Debug( LDAP_DEBUG_TRACE, "=> dn_normalize \"%s\"\n", dn, 0, 0 ); */
gotesc = 0;
state = B4TYPE;
for ( d = s = dn; *s; s++ ) {
switch ( state ) {
case B4TYPE:
if ( ! SPACE( *s ) ) {
state = INTYPE;
*d++ = *s;
}
break;
case INTYPE:
if ( *s == '=' ) {
state = B4VALUE;
*d++ = *s;
} else if ( SPACE( *s ) ) {
state = B4EQUAL;
} else {
*d++ = *s;
}
break;
case B4EQUAL:
if ( *s == '=' ) {
state = B4VALUE;
*d++ = *s;
} else if ( ! SPACE( *s ) ) {
/* not a valid dn - but what can we do here? */
*d++ = *s;
}
break;
case B4VALUE:
if ( *s == '"' ) {
state = INQUOTEDVALUE;
*d++ = *s;
} else if ( ! SPACE( *s ) ) {
state = INVALUE;
*d++ = *s;
}
break;
case INVALUE:
if ( !gotesc && SEPARATOR( *s ) ) {
while ( SPACE( *(d - 1) ) )
d--;
state = B4TYPE;
if ( *s == '+' ) {
*d++ = *s;
} else {
*d++ = ',';
}
} else if ( gotesc && !NEEDSESCAPE( *s ) &&
!SEPARATOR( *s ) ) {
*--d = *s;
d++;
} else {
*d++ = *s;
}
break;
case INQUOTEDVALUE:
if ( !gotesc && *s == '"' ) {
state = B4SEPARATOR;
*d++ = *s;
} else if ( gotesc && !NEEDSESCAPE( *s ) ) {
*--d = *s;
d++;
} else {
*d++ = *s;
}
break;
case B4SEPARATOR:
if ( SEPARATOR( *s ) ) {
state = B4TYPE;
*d++ = *s;
}
break;
default:
#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION
# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010
# define LDAP_DEBUG_ANY 0xffff
if ( ldap_debug & LDAP_DEBUG_ANY )
fprintf( stderr, "dn_normalize - unknown state %d\n", state );
if ( ldap_syslog & LDAP_DEBUG_ANY )
syslog( ldap_syslog_level,
"dn_normalize - unknown state %d\n", state );
# endif
#else
Debug( LDAP_DEBUG_ANY,
"dn_normalize - unknown state %d\n", state, 0, 0 );
#endif
break;
}
if ( *s == '\\' ) {
gotesc = 1;
} else {
gotesc = 0;
}
}
*d = '\0';
/* Debug( LDAP_DEBUG_TRACE, "<= dn_normalize \"%s\"\n", dn, 0, 0 ); */
return( dn );
}
/* end of function: dn_normalize */
/*
* dn_normalize_case - put dn into a canonical form suitable for storing
* in a hash database. this involves normalizing the case as well as
* the format. the dn is normalized in place as well as returned.
*/
PUBLIC char * dn_normalize_case( dn )
char *dn;
{
/* normalize format */
dn_normalize( dn );
/* normalize case */
str_toupper( dn );
return( dn );
}
/* end of function: dn_normalize_case */
/*
* dn_issuffix - tells whether suffix is a suffix of dn. both dn
* and suffix must be normalized.
*/
PUBLIC int dn_issuffix( dn, suffix )
char *dn;
char *suffix;
{
int dnlen, suffixlen;
if ( dn == NULL ) {
return( 0 );
}
suffixlen = strlen( suffix );
dnlen = strlen( dn );
if ( suffixlen > dnlen ) {
return( 0 );
}
return( strcasecmp( dn + dnlen - suffixlen, suffix ) == 0 );
}
/* end of function: dn_issuffix */

43
contrib/tweb/dn.h Normal file
View File

@ -0,0 +1,43 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* dn.h....... *
* *
* Function:..Header-Datei fuer TWEB-Software *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* April 24 1996 Z D D V V *
* Last modification: Z D D V V *
* November 21 1996 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: dn.h,v 1.6 1999/09/10 15:01:16 zrnsk01 Exp $
*
*/
#ifndef _DN_
#define _DN_
#define DNSEPARATOR(c) (c == ',' || c == ';')
#define SEPARATOR(c) (c == ',' || c == ';' || c == '+')
#define SPACE(c) (c == ' ' || c == '\n')
#define NEEDSESCAPE(c) (c == '\\' || c == '"')
#define B4TYPE 0
#define INTYPE 1
#define B4EQUAL 2
#define B4VALUE 3
#define INVALUE 4
#define INQUOTEDVALUE 5
#define B4SEPARATOR 6
#include "dn_exp.h"
#endif /* _DN_ */

33
contrib/tweb/dn_exp.h Normal file
View File

@ -0,0 +1,33 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* dn_exp.h... *
* *
* Function:..Header-Datei fuer TWEB-Software *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* April 24 1996 Z D D V V *
* Last modification: Z D D V V *
* November 21 1996 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: dn_exp.h,v 1.6 1999/09/10 15:01:17 zrnsk01 Exp $
*
*/
#ifndef _DN_EXP_
#define _DN_EXP_
PUBLIC char * dn_normalize();
PUBLIC char * dn_normalize_case();
PUBLIC int dn_issuffix();
#endif /* _DN_EXP_ */

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,12 @@
doc/Presentation/README
=======================
This directory contains documentation concerning TWEB that was presented
at different occasions.
- DANTE-01-99.ps
Presentation of the dynamic features of TWEB (i.e., gateway-switching
and dynamic re-configuration) at the DANTE NameFlow meeting, January,
18th, 1999, in Utrecht, NL.

939
contrib/tweb/html.c Normal file
View File

@ -0,0 +1,939 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* html.c..... *
* *
* Function:..WorldWideWeb-X.500-Gateway - HTML-Procedures *
* Based on web500gw.c 1.3 written by Frank Richter, TU Chemmniz *
* which is based on go500gw by Tim Howes, University of *
* Michigan - All rights reserved *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* August 16 1995 Z D D V V *
* Last modification: Z D D V V *
* May 28 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: html.c,v 1.6 1999/09/10 15:01:17 zrnsk01 Exp $
*
*/
#include "tgeneral.h"
#include "tglobal.h"
#include "html.h"
#include "init_exp.h"
#include "support_exp.h"
#ifdef TUETEL
#include "tueTel_exp.h"
#endif
PUBLIC void print_attr(ld, fp, dn, label, tattr, e, flag, doNotShow, glob)
LDAP *ld;
FILE *fp;
char *dn;
char *label;
char *tattr;
LDAPMessage *e;
int flag;
char *doNotShow;
GLOB_STRUCT *glob;
{
char **val;
int i, gotone = 0, firstline = TRUE, valid_label = FALSE;
static char *nlabel;
char imageChar = 'J';
char strbuf[BUFSIZ];
int first_of_same = TRUE;
nlabel = ldap_friendly_name(glob->friendlyfile, label, &fm);
if ( (val = ldap_get_values( ld, e, tattr )) == NULL )
return;
/* check if only 1 value and this one is in "doNotShow"
if((doNotShow) && (val[1] == NULL) && (strcmp(val[0],doNotShow) == 0))
return;
*/
for ( i = 0; val[i]; i++ ) {
sprintf(strbuf, "(%s)", glob->la[0]);
if(!strncasecmp(val[i], strbuf, 4)) {
strcpy(val[i], val[i]+4);
}
else if(val[i][0] == '(' && val[i][3] == ')' ) {
val[i][0] = '\0';
continue;
}
if (!doNotShow || strncasecmp (val[i], doNotShow, strlen (val[i])))
valid_label = TRUE;
else
val[i][0] = '\0';
}
if(!valid_label) {
ldap_value_free (val);
return;
}
fprintf( fp, "\n<DT><B>%s</B><DD>", nlabel );
/* handle photo-requests */
if((flag == BMP) || (flag == JPEG2GIF) || (flag == JPEG)) {
photof(fp, flag, imageChar, dn, tattr);
return;
}
for ( i = 0; val[i] != NULL; i++ ) {
char *vali;
if(!*label ) first_of_same = FALSE;
if(!*val[i]) continue;
vali = char2html(val[i]);
if (flag == URL) {
urlf(fp, vali);
#ifdef TUE_TEL
} else if (flag == TFUNCPERS) {
tfuncpersf(fp, vali, ld, glob);
#endif
} else if (flag == DYNAMICDN) {
dynamicdnf(fp, vali, glob);
} else if (flag == INDEXURL) {
indexurlf(fp, vali, dn, glob);
} else if (flag == URI) {
urif(fp, vali, glob);
} else if (flag == PGPKEY) {
pgpkeyf(fp, vali, &firstline);
} else if ( ( flag == MULTILINE ) || (strchr(vali, '$') &&
strncmp(vali, "{T.61}", 6) != 0 )) {
multilinef(fp, vali, &first_of_same, &firstline, &gotone, nlabel);
} else if (flag == BOOLEAN) {
booleanf(fp, val[i], glob);
} else if (flag == DATE) {
datef(fp, val[i]);
} else if (flag == MAILTO) {
mailtof(fp, val[i], vali);
} else if (flag == HREF) {
hreff(fp, val[i], vali, glob);
} else if (flag == MOVETO) {
movetof(fp, val[i], vali, glob);
} else if (flag == PRE) {
pref(fp, vali, glob);
} else if (flag == HEADER) {
headerf(fp, vali, glob);
} else if (flag == REFERRAL) {
referralf(fp, vali, glob);
#ifdef TUE_TEL
} else if(flag == FAXTABLE) {
faxtablef(fp, val, &firstline);
#endif
} else
defaultf(fp, vali, &firstline);
}
ldap_value_free( val );
}
/* end of function: print_attr */
PUBLIC void form_attr(ld, fp, label, tattr, e, multiline, add_empty, glob)
LDAP *ld;
FILE *fp;
char *label;
char *tattr;
LDAPMessage *e;
int multiline;
int add_empty;
GLOB_STRUCT *glob;
{
char **val, *s;
char buffer[1024];
int i, gotone = 0, line = 0;
static char *nlabel;
nlabel = ldap_friendly_name(glob->friendlyfile, label, &fm);
if ( (val = ldap_get_values( ld, e, tattr )) == NULL ) {
if (add_empty > 0)
if(multiline)
fprintf( fp, "<DT><B>%s</B><DD><TEXTAREA NAME=\"%s=\" ROWS=4 COLS=30></TEXTAREA><BR>\n",
nlabel, tattr);
else
fprintf( fp, "<DT><B>%s</B><DD><INPUT NAME=\"%s=\" SIZE=30 ><BR>\n",
nlabel, tattr);
return;
}
fprintf( fp, "\n<DT><B>%s</B><DD>", nlabel );
buffer[0] ='\0';
for ( i = 0; val[i] != NULL; i++ ) {
if ( multiline ) {
char *s, *p;
buffer[0] ='\0';
if ( gotone )
fprintf( fp, "<DT><B>%s</B><DD>", nlabel);
p = s = val[i];
while ( ( s = strchr( s, '$' )) ) {
*s++ = '\0';
while ( isspace( *s ) )
s++;
if ( line == 0 ) {
sprintf(buffer, "%s", p);
line++;
} else {
sprintf(buffer, "%s\n%s", buffer, p);
line++;
}
p = s;
}
if (line++ == 0) {
sprintf(buffer, "%s", p);
} else {
sprintf(buffer, "%s\n%s", buffer, p);
}
s = form_encode(buffer);
fprintf( fp,
"<TEXTAREA NAME=\"%s=%s\" ROWS=%d COLS=30>%s</TEXTAREA><BR>\n",
tattr, s, line + 1, s);
/* fprintf( fp, "<INPUT NAME=\"%s=%s\" SIZE=30,%d VALUE=\"%s\"> <BR>\n", tattr, s, line + 1, s); */
gotone = 1;
line = 0;
} else {
s = form_encode(val[i]);
fprintf( fp, "<INPUT NAME=\"%s=%s\" SIZE=\"%d\" VALUE=\"%s\"><BR>\n", tattr, s,
strlen(val[i]) > 30 ? strlen(val[i]) + 3 : 30, s);
}
}
if (add_empty > i)
fprintf( fp, "<INPUT NAME=\"%s=\" SIZE=30 ><BR>\n", tattr);
ldap_value_free( val );
}
/* end of function: form_attr */
PUBLIC void do_pict(ld, fp, dn, type, glob)
LDAP *ld;
FILE *fp;
char *dn;
int type;
GLOB_STRUCT *glob;
{
int rc, i;
struct berval **val;
char cmd[128], buffer[1024];
char *s;
FILE *op, *tp;
LDAPMessage *res, *e;
struct stat st;
char *cPtr, *ptype;
char *tattr;
if ( (rc = ldap_search_s( ld, dn, LDAP_SCOPE_BASE, "objectClass=*",
NULL, 0, &res )) != LDAP_SUCCESS ) {
do_error(fp, rc, NOT_FOUND, glob);
return;
}
if ( (e = ldap_first_entry( ld, res )) == NULL ) {
do_error(fp, -2, SERVER_ERROR, glob);
return;
}
/*
* old behaviour: use "photo" or "jpegPhoto" attribute
* as indicated by type-argument.
*/
tattr = (type == 0 ? "photo" : "jpegPhoto");
/* NEW: if attr is added to URL via "+" use that attribute */
if( ( cPtr = strQuoteChr(dn,'+')) )
tattr = ++cPtr;
if ( (val = ldap_get_values_len( ld, e, tattr)) == NULL )
return;
s = tmpnam( NULL );
tp = fopen( s, "w+");
if (type == 0) { /* g3fax photo -> xbm */
sprintf(cmd, "%s > %s", G3TOXBM, s);
if (debug) fprintf(stderr, "%ld bytes FAX!! %s\n",
val[0]->bv_len, cmd);
ptype = "x-xbitmap";
} else if (type == 1) { /* jpeg -> gif */
sprintf(cmd, "%s > %s", JPEGTOGIF, s);
if (debug) fprintf(stderr, "%ld bytes JPEG!! %s\n",
val[0]->bv_len, cmd);
ptype = "gif";
} else { /* jpeg direct */
sprintf(cmd, "cat > %s", s);
if (debug) fprintf(stderr, "%ld bytes JPEG!! %s\n",
val[0]->bv_len, cmd);
ptype = "jpeg";
}
if (http == 1) {
fprintf(fp, "HTTP/1.0 %d OK<br>MIME-Version: 1.0<br>",
DOCUMENT_FOLLOWS );
fprintf(fp, "Content-type: image/%s<br>", ptype );
}
if (request == HEAD) {
fflush(fp);
exit_tweb (1);
}
if ((op = popen(cmd, "w")) == NULL )
return;
fwrite(val[0]->bv_val, val[0]->bv_len, 1, op);
pclose(op);
if (stat(s, &st) == 0 && http == 1) {
fprintf(fp, "Content-length: %lu<br>", st.st_size);
if (debug) fprintf(stderr, "Image size: %lu\n", st.st_size);
}
fprintf(fp, "<br>\n\n");
while (( i = fread(buffer, 1, 1024, tp))) fwrite(buffer, 1, i, fp);
fclose(tp);
if (unlink(s) == -1) {
if (debug) perror("Couldn't unlink temp image file");
}
fflush(fp);
}
/* end of function: do_pict */
PUBLIC void do_audio(ld, fp, dn, type, glob)
LDAP *ld;
FILE *fp;
char *dn;
int type;
GLOB_STRUCT *glob;
{
int rc;
struct berval **val;
LDAPMessage *res, *e;
struct timeval timeout;
timeout.tv_sec = glob->timeout;
timeout.tv_usec = 0;
if ( (rc = ldap_search_st( ld, dn, LDAP_SCOPE_BASE, "objectClass=*",
NULL, 0, &timeout, &res )) != LDAP_SUCCESS ) {
do_error(fp, rc, NOT_FOUND, glob);
return;
}
if ( (e = ldap_first_entry( ld, res )) == NULL ) {
do_error(fp, -2, SERVER_ERROR, glob);
return;
}
if ( (val = ldap_get_values_len( ld, e, "audio" )) == NULL )
return;
if (http == 1) {
fprintf(fp, "HTTP/1.0 %d OK\nMIME-Version: 1.0\nServer: %s\n",
DOCUMENT_FOLLOWS, version);
fprintf(fp, "Content-type: audio/basic<P>Content-length: %ld\n\n",
val[0]->bv_len);
}
if (request == HEAD) {
fflush(fp);
exit_tweb (1);
}
fwrite(val[0]->bv_val, val[0]->bv_len, 1, fp);
fflush(fp);
}
/* end of function: do_audio */
PUBLIC void do_sizelimit(fp, type, glob)
FILE *fp;
int type;
GLOB_STRUCT *glob;
{
fprintf(fp, type ? glob->la[21] : glob->la[20]);
}
/* end of function: do_sizelimit */
PUBLIC void do_error(fp, code, status, glob)
FILE *fp;
int code;
int status;
GLOB_STRUCT *glob;
{
char *s = "";
if (http == 1) {
switch (status) {
case BAD_REQUEST: s = "Bad request"; break;
case AUTH_REQUIRED: s = "Authorization required"; break;
case FORBIDDEN: s = "Forbidden"; break;
case NOT_FOUND: s = "Not found"; break;
case SERVER_ERROR: s = "Server error"; break;
case NOT_IMPLEMENTED: s = "Not implemented"; break;
default: s = "Unknown error";
}
fprintf(fp, "HTTP/1.0 %03d %s\nMIME-Version: 1.0\nContent-Type: text/html\n\n", status, s);
}
if (request == HEAD) {
fflush(fp);
exit_tweb (1);
}
fprintf( fp, HTML_HEAD_TITLE, glob->la[22], glob->la[100]);
fprintf( fp, "\n<H2>%s %s</H2>\n%s <P>%s <EM> %d: %s.</EM><P>%s<br></BODY></HTML>", glob->la[23], s, glob->la[24], glob->la[25], code, ldap_err2string( code ), glob->la[26] );
}
/* end of function: do_error */
PUBLIC void explain_error (fp, error, status, glob )
FILE *fp;
char *error;
int status;
GLOB_STRUCT *glob;
{
char *s = "Unknown error";
if (http == 1) {
switch (status) {
case BAD_REQUEST: s = "Bad request"; break;
case AUTH_REQUIRED: s = "Authorization required"; break;
case FORBIDDEN: s = "Forbidden"; break;
case NOT_FOUND: s = "Not found"; break;
case SERVER_ERROR: s = "Server error"; break;
case NOT_IMPLEMENTED: s = "Not implemented"; break;
default: s = "Unknown error";
}
fprintf(fp, "HTTP/1.0 %03d %s\n",status, s);
fprintf(fp, "MIME-Version: 1.0\n");
fprintf(fp, "Content-Type: text/html\n\n");
}
if (request == HEAD) {
fflush(fp);
exit_tweb (1);
}
fprintf( fp, HTML_HEAD_TITLE, glob->la[22], glob->la[100]);
fprintf( fp, "<H2>%s: %s</H2>\n", glob->la[22], s);
fprintf( fp, "%s</BODY>\n</HTML>", error);
}
/* end of function: explain_error */
/* Make "Move upwards" Header */
PUBLIC void make_header (fp, dn, action, glob)
FILE *fp;
char *dn;
int action;
GLOB_STRUCT *glob;
{
char **s, **t, hrdn[1024];
int cnt, i, j;
pGW_SWITCH_LINE gw_ptr;
char url[BUFSIZ];
if(glob->pull_down_menus) {
make_header_pull_down(fp, dn, action, glob);
return;
}
hrdn[0] = '\0';
if ( strlen(dn) == 0) /* the root */
return;
s = ldap_explode_dn( dn, 1 );
t = ldap_explode_dn( dn, 0 );
strcpy(url, "M");
for(gw_ptr = glob->gw_switch->list; gw_ptr; gw_ptr = gw_ptr->next)
if (!strcasecmp(gw_ptr->dn, "ROOT"))
strcpy(url, gw_ptr->url);
fprintf( fp, "<strong>%s </strong><MENU>\n<LI> <A HREF=\"%s\">%s</A>\n",
glob->la[27], url, glob->la[77]);
for (cnt=0; t[cnt]; cnt++);
for (i = cnt - 1; i > 0 && s[i]; i--) {
strcpy(hrdn, hex_encode(t[i]));
for (j = i + 1; j < cnt ; j++) {
strcat(hrdn, hex_encode(", "));
strcat(hrdn,hex_encode(t[j]));
}
strcpy(url, "/");
for(gw_ptr = glob->gw_switch->list; gw_ptr; gw_ptr = gw_ptr->next)
if (!dn_cmp(hex_encode (gw_ptr->dn), hrdn))
strcpy(url, url_complete(gw_ptr->url, hrdn, "M"));
if(strcmp(url, "/"))
fprintf( fp, "<LI> <A HREF=\"%s\">%s</A>\n",
url, i == cnt - 1 ?
ldap_friendly_name( glob->friendlyfile, s[i], &fm ) :
s[i]);
else
fprintf( fp, "<LI> <A HREF=\"%sM%s\">%s</A>\n",
url, hrdn, i == cnt - 1 ?
ldap_friendly_name( glob->friendlyfile, s[i], &fm ) :
s[i]);
hrdn[0] = '\0';
}
fprintf( fp, "</MENU>\n");
ldap_value_free(s);
ldap_value_free(t);
}
/* end of function: make_header */
/* Make "Move upwards" Header with pull-down-menus*/
PUBLIC void make_header_pull_down (fp, dn, action, glob)
FILE *fp;
char *dn;
int action;
GLOB_STRUCT *glob;
{
char **s, **t, hrdn[1024];
int cnt, i, j;
pGW_SWITCH_LINE gw_ptr;
char url[BUFSIZ];
hrdn[0] = '\0';
if ( strlen(dn) == 0) /* the root */
return;
s = ldap_explode_dn( dn, 1 );
t = ldap_explode_dn( dn, 0 );
strcpy(url, "M");
for(gw_ptr = glob->gw_switch->list; gw_ptr; gw_ptr = gw_ptr->next)
if (!strcasecmp(gw_ptr->dn, "ROOT"))
strcpy(url, gw_ptr->url);
fprintf( fp, "<FORM ACTION=\"/D\">\n");
fprintf( fp,
"<INPUT TYPE=submit VALUE=\"%s\"> -&gt; <SELECT NAME=\"H\">\n",
glob->la[27]);
fprintf( fp, "<OPTION VALUE=\"%s\">%s\n", url, glob->la[77]);
for (cnt=0; t[cnt]; cnt++);
for (i = cnt - 1; i > 0 && s[i]; i--) {
strcpy(hrdn, hex_encode(t[i]));
for (j = i + 1; j < cnt ; j++) {
strcat(hrdn, hex_encode(", "));
strcat(hrdn,hex_encode(t[j]));
}
strcpy(url, "/");
for(gw_ptr = glob->gw_switch->list; gw_ptr; gw_ptr = gw_ptr->next)
if (!dn_cmp(hex_encode (gw_ptr->dn), hrdn))
strcpy(url, url_complete(gw_ptr->url, hrdn, "M"));
if(strcmp(url, "/"))
fprintf( fp, "<OPTION VALUE=\"%s\" %s>%s\n", url,
i==1 ? "SELECTED" : "", i == cnt - 1 ?
ldap_friendly_name( glob->friendlyfile, s[i], &fm ) :s[i]);
else
fprintf( fp, "<OPTION VALUE=\"%sM%s\" %s>%s\n",
url, hrdn, i==1 ? "SELECTED" : "", i == cnt - 1 ?
ldap_friendly_name( glob->friendlyfile, s[i], &fm ) :s[i]);
hrdn[0] = '\0';
}
fprintf( fp, "</SELECT></FORM>\n");
ldap_value_free(s);
ldap_value_free(t);
}
/* end of function: make_header_pull_down */
PUBLIC char * url_complete (gwp_url, rdn, separator)
char *gwp_url, *rdn, *separator;
{
static char url[BUFSIZ];
char *strptr;
strcpy(url, gwp_url);
if(!strchr (gwp_url, '=')) {
if (!strncasecmp (url, "http://", 7)) {
if ( ( strptr = strchr (url+7, '/')) ) *(++strptr) = '\0';
else strcat (url, "/");
} else *url = '\0';
sprintf (url, "%s%s%s", url, separator, rdn);
}
return(url);
}
/* end of function: url_complete */
PRIVATE void photof(fp, flag, imageChar, dn, tattr)
FILE *fp;
int flag;
char imageChar;
char *dn;
char *tattr;
{
switch(flag) {
case BMP : imageChar = 'G'; break;
case JPEG2GIF: imageChar = 'I'; break;
case JPEG : imageChar = 'J'; break;
}
fprintf( fp, "<IMG ALT=\"Photo\" SRC=\"%c%s\"+%s>\n",
imageChar, hex_encode(dn), tattr);
}
/* end of function: photof */
PRIVATE void urlf(fp, vali)
FILE *fp;
char *vali;
{
char *cp;
if ((cp = strchr(vali, '$')) != NULL) {
*cp++ = '\0';
fprintf( fp, "%s%c\n", vali,
(vali[0] ? ':' : ' '));
fprintf(fp," <A HREF=\"%s\"> %s</A><BR>\n",
cp, cp);
} else
fprintf( fp, "%s<BR>\n", vali);
}
/* end of function: urlf */
PRIVATE void dynamicdnf(fp, vali, glob)
FILE *fp;
char *vali;
GLOB_STRUCT *glob;
{
fprintf(fp," <A HREF=\"%s/M%s\"> %s</A><BR>\n",
#ifdef TUE_TEL
dn2server(vali, glob),
#else
"",
#endif
vali, vali);
}
/* end of function: dynamicdnf */
/* Allow href dn-lable flexible configuration via INDEXURL */
PRIVATE void indexurlf(fp, vali, entrydn, glob)
FILE *fp;
char *vali;
char *entrydn;
GLOB_STRUCT *glob;
{
char *cp;
char dnbuf[BUFSIZ], *strptr, **dn;
char rulebuf[BUFSIZ], *disp_item;
int arrsize, first;
char entrydnbuf[BUFSIZ], dit_dnbuf[BUFSIZ];
int index;
if (((cp = strchr(vali, ' ')) != NULL) && glob->index_url) {
*cp++ = '\0';
index = atoi(cp);
if ( index < 0 || index >= INDEX_RULE_SIZE )
return;
if (!glob->index_url->rarr[index].rule) {
return;
}
/* case entrydn out of range */
strcpy(entrydnbuf, entrydn);
strcpy(dit_dnbuf, glob->index_url->rarr[index].dit_dn);
dn_normalize(entrydnbuf);
dn_normalize(dit_dnbuf);
if(!dn_issuffix(entrydnbuf, dit_dnbuf)){
fprintf(fp," <A HREF=\"%s\"> %s</A><BR>\n", vali, cp);
return;
}
/* return if url doesn't contain cn= ( no dn ) */
if(!(strptr = strstr(vali, "cn=")))
return;
strcpy(dnbuf, strptr);
hex_decode(dnbuf);
dn = ldap_explode_dn(dnbuf, 1);
for(arrsize=0; dn[arrsize]; arrsize++)
;
if(arrsize && glob->strip_pin)
trimright(dn[0], " 1234567890");
fprintf(fp," <A HREF=\"%s\">", vali);
strcpy(rulebuf, glob->index_url->rarr[index].rule);
first = 1;
for(disp_item = strtok(rulebuf, ","); disp_item;
disp_item = strtok(NULL, ",")) {
if(abs(atoi(disp_item)) >= arrsize) continue;
if(*disp_item == '-') {
fprintf(fp,"%s%s", !first ? ", " : "",
dn[arrsize + atoi(disp_item) - 1]);
} else {
fprintf(fp,"%s%s", !first ? ", " : "", dn[atoi(disp_item)]);
}
first = 0;
}
fprintf(fp,"</A><BR>\n");
} else
fprintf( fp, "%s<BR>\n", vali);
}
/* end of function: indexurlf */
PRIVATE void urif(fp, vali, glob)
FILE *fp;
char *vali;
GLOB_STRUCT *glob;
{
char *cp;
if(glob->gw_switch->dynamic && strstr(vali, "(gw"))
return;
if ((cp = strchr(vali, ' ')) != NULL) {
*cp++ = '\0';
fprintf(fp," <A HREF=\"%s\"> %s</A><BR>\n", vali, cp);
} else
fprintf( fp, "%s<BR>\n", vali);
}
/* end of function: urif */
/* function for ldap-referrals etc. */
PRIVATE void referralf(fp, vali, glob)
FILE *fp;
char *vali;
GLOB_STRUCT *glob;
{
char *cp;
if(glob->gw_switch->dynamic && strstr(vali, "(gw"))
return;
if ((cp = strchr(vali, ' ')) != NULL) {
*cp++ = '\0';
fprintf(fp," <A HREF=\"http://%s:%d/W%s\"> %s</A><BR>\n",
glob->hostname, glob->webport, vali, cp);
} else
fprintf(fp," <A HREF=\"http://%s:%d/W%s\"> %s</A><BR>\n",
glob->hostname, glob->webport, vali, vali);
}
/* end of function: referralf */
PRIVATE void pgpkeyf(fp, vali, firstline)
FILE *fp;
char *vali;
int *firstline;
{
char *s, *p;
fprintf( fp, "<TT>\n");
p = s = vali;
while ( ( s = strstr( s, " $" )) ) {
*s++ = '\0'; /* delete BLANK */
*s++ = '\0'; /* delete DOLLAR */
while ( isspace( *s ) )
s++;
if ( *firstline == TRUE ) {
fprintf( fp, "<DT>%s<BR>\n", p );
*firstline = FALSE;
} else if (!strncasecmp(p, "Version", 7)) {
fprintf( fp, "%s<BR><BR>\n", p );
} else {
fprintf( fp, "%s<BR>\n", p );
}
p = s;
}
if ( *firstline == TRUE ) {
fprintf( fp,"<DT>%s<BR>", p );
*firstline = FALSE;
} else {
fprintf( fp, "%s\n", p );
}
fprintf( fp, "</TT>\n");
}
/* end of function: pgpkeyf */
PRIVATE void multilinef(fp, vali, first_of_same, firstline, gotone, nlabel)
FILE *fp;
char *vali;
int *first_of_same;
int *firstline;
int *gotone;
char *nlabel;
{
char *s, *p;
if ( !*first_of_same && *gotone)
fprintf( fp, "<BR>");
if ( *gotone && *first_of_same)
fprintf( fp, "<DT><B>%s</B><DD>", nlabel);
else if (!*first_of_same)
fprintf( fp, "<BR>");
p = s = vali;
/* PATCH to process MULTILINE correctly:
replace strstr() instead of strchr(), in order not to missinterpret
DOLLAR in Text ; /KSp, 95/06/28
*/
/*
while ( s = strchr( s, '$' ) ) {
*/
while ( ( s = strstr( s, " $" )) ) {
*s++ = '\0'; /* delete BLANK */
*s++ = '\0'; /* delete DOLLAR */
while ( isspace( *s ) )
s++;
/*
if (dosyslog)
syslog (LOG_INFO, "multiLineAttr: %s", p);
*/
fprintf( fp, "%s<BR>\n", p );
if ( *firstline == TRUE )
*firstline = FALSE;
p = s;
}
if ( *firstline ) {
fprintf( fp, "%s<BR>\n", p );
} else {
fprintf( fp, "%s", p );
}
*gotone = 1;
*firstline = FALSE;
*first_of_same = FALSE;
}
/* end of function: multilinef */
PRIVATE void booleanf(fp, val_i, glob)
FILE *fp;
char *val_i;
GLOB_STRUCT *glob;
{
if (!strcmp(val_i, "TRUE")) fprintf( fp, "%s<BR>\n", glob->la[78]);
else fprintf( fp, "%s<BR>\n", glob->la[79]);
}
/* end of function: booleanf */
PRIVATE void datef(fp, val_i)
FILE *fp;
char **val_i;
{
fprintf( fp, "%s<BR>\n", format_date(&val_i, "%A, %d-%h-%y %T GMT"));
}
/* end of function: datef */
PRIVATE void mailtof(fp, val_i, vali)
FILE *fp;
char *val_i;
char *vali;
{
fprintf (fp, "<A HREF=\"mailto:%s\">%s</A><BR>\n", val_i, vali);
}
/* end of function: mailtof */
PRIVATE void hreff(fp, val_i, vali, glob)
FILE *fp;
char *val_i;
char *vali;
GLOB_STRUCT *glob;
{
char *ufn;
char op = 'R';
ufn = friendly_dn( val_i, glob );
fprintf( fp, "<A HREF=\"/%c%s\">%s</A><BR>\n", op,
hex_encode(val_i), ufn ? ufn : vali);
if ( ufn ) {
free( ufn );
}
}
/* end of function: hreff */
PRIVATE void movetof(fp, val_i, vali, glob)
FILE *fp;
char *val_i;
char *vali;
GLOB_STRUCT *glob;
{
char *ufn;
char op = 'M';
ufn = friendly_dn( val_i, glob );
fprintf( fp, "<A HREF=\"/%c%s\">%s</A><BR>\n", op,
hex_encode(val_i), ufn ? ufn : vali);
if ( ufn ) {
free( ufn );
}
}
/* end of function: movetof */
PRIVATE void headerf(fp, vali, firstline)
FILE *fp;
char *vali;
int *firstline;
{
fprintf( fp, "<DT>");
fprintf( fp, "<H1>");
fprintf( fp,"%s", vali );
fprintf( fp, "</H1>\n");
}
/* end of function: headerf */
PRIVATE void pref(fp, vali, firstline)
FILE *fp;
char *vali;
int *firstline;
{
fprintf( fp, "<DT>");
fprintf( fp, "<PRE>");
fprintf( fp,"%s", vali );
fprintf( fp, "</PRE>\n");
}
/* end of function: pref */
PRIVATE void defaultf(fp, vali, firstline)
FILE *fp;
char *vali;
int *firstline;
{
if ( *firstline == TRUE ) {
fprintf( fp,"%s", vali );
*firstline = FALSE;
} else {
fprintf( fp, "<BR>\n%s", vali );
}
}
/* end of function: defaultf */

50
contrib/tweb/html.h Normal file
View File

@ -0,0 +1,50 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* html.h..... *
* *
* Function:..File for TWEB-SOFTWARE *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* April 19 1996 Z D D V V *
* Last modification: Z D D V V *
* May 14 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: html.h,v 1.6 1999/09/10 15:01:17 zrnsk01 Exp $
*
*/
#ifndef _HTML_
#define _HTML_
#include "html_exp.h"
#include "dn_exp.h"
PRIVATE void photof();
PRIVATE void urlf();
PRIVATE void urif();
PRIVATE void referralf();
PRIVATE void dynamicdnf();
PRIVATE void indexurlf();
PRIVATE void pgpkeyf();
PRIVATE void multilinef();
PRIVATE void booleanf();
PRIVATE void datef();
PRIVATE void mailtof();
PRIVATE void hreff();
PRIVATE void movetof();
PRIVATE void pref();
PRIVATE void headerf();
PRIVATE void defaultf();
PRIVATE void make_header_pull_down();
#endif /* _HTML_ */

41
contrib/tweb/html_exp.h Normal file
View File

@ -0,0 +1,41 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* html_exp.h. *
* *
* Function:..File for TWEB-SOFTWARE *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* February 13 1996 Z D D V V *
* Last modification: Z D D V V *
* November 21 1996 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: html_exp.h,v 1.6 1999/09/10 15:01:17 zrnsk01 Exp $
*
*/
#ifndef _HTML_EXP_
#define _HTML_EXP_
PUBLIC void print_attr(/*ld, fp, dn, label, tattr, e, flag, doNotShow, glob*/);
PUBLIC void form_attr(/*ld, fp, label, tattr, e, multiline, add_empty, glob*/);
PUBLIC void do_pict(/*ld, fp, dn, type, glob*/);
PUBLIC void do_audio(/*ld, fp, dn, type, glob*/);
PUBLIC void do_sizelimit(/*fp, type, glob*/);
PUBLIC void do_error(/*fp, code, status, glob*/);
PUBLIC void explain_error (/*fp, error, status, glob */);
PUBLIC void make_header (/*fp, dn, action, glob*/);
PUBLIC char * url_complete (/*gwp_url, rdn, separator*/);
#endif /* _HTML_EXP_ */

1858
contrib/tweb/init.c Normal file

File diff suppressed because it is too large Load Diff

289
contrib/tweb/init.h Normal file
View File

@ -0,0 +1,289 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* init.h..... *
* *
* Function:..File for TWEB-SOFTWARE *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* July 21 1995 Z D D V V *
* Last modification: Z D D V V *
* May 14 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: init.h,v 1.6 1999/09/10 15:01:17 zrnsk01 Exp $
*
*/
#ifndef _INIT_
#define _INIT_
#include <getopt.h>
#include "strng_exp.h"
#include "init_exp.h"
#include "charray_exp.h"
#include "ch_malloc_exp.h"
#include "support_exp.h"
#ifdef TUE_TEL
# include "tueTel_exp.h"
#endif
#ifdef AMBIXGW
# include "ambix_exp.h"
#endif
/* Usage-Text */
#define USAGE "\nUSAGE: %s -Lx[yz..] [-p webport] [-x ldaphost]\
\n\t\t[-P ldapport] [-b basedn] [-f filterfile] [-l logger] [-d]\n\
\n\
A short description of TWEB WWW2X.500-Gateway: \n\n\
(does not compensate reading the README files\n\
and the correct configuration)\n\
\n\
Options:\n\n\
-L:\ttells TWEB the numbers of the languages that have to be started,\n\
\twherewith are also created the language-buttons\n\
\tExample: tweb -L01 starts TWEB in german und english\n\
-p:\tnames the port on which the gateway is to be reached\n\
-x:\tnames the LDAP-Hosts\n\
-P:\tnames the port of the LDAP-Server\n\
-b:\tnames the DN where the gateway shall start by default\n\
-f:\tnames the ldapfilter-file\n\
-l:\tswitches on logging for example LOCAL3\n\
-d:\tswitches on debugging (no sub-processes!)\n\
\n"
/* Funktions in the init-module */
PRIVATE int webdn();
PRIVATE int webpw();
PRIVATE int webdn2();
PRIVATE int webpw2();
PRIVATE int webport();
PRIVATE int timeout();
PRIVATE int ldapd();
PRIVATE int ldapportf();
PRIVATE int hostname();
PRIVATE int header();
PRIVATE int footer();
PRIVATE int index_url();
PRIVATE int allow_msg();
PRIVATE int helpfilef();
PRIVATE int filterfilef();
PRIVATE int etcdir();
PRIVATE int friendlyfilef();
PRIVATE int grant();
PRIVATE int refuse();
PRIVATE int allow_string();
PRIVATE int allow_proxy();
PRIVATE int subtree_search();
PRIVATE int deny_string();
PRIVATE int show_defoc();
PRIVATE int display();
PRIVATE int basednf();
PRIVATE int search_only();
PRIVATE int gw_switch();
PRIVATE int modify();
PRIVATE int ind_attrs();
PRIVATE int ind_attribute();
PRIVATE int maxcount();
PRIVATE int cache_expire();
PRIVATE int max_person();
PRIVATE int caching_terms();
PRIVATE int comrefuse();
PRIVATE int language();
PRIVATE void f_test();
PRIVATE void main_loop();
PRIVATE int strip_pin();
PRIVATE int prefer_ref_uris();
PRIVATE int pull_down_menus();
PRIVATE int no_proxy();
PRIVATE int disp_sea_rdn();
PRIVATE int strict_basedn();
PRIVATE int dynamic_gw();
PRIVATE int legal();
PRIVATE int no_show_rdn();
PRIVATE int no_modify();
PRIVATE int sort();
PRIVATE int firstPage();
PRIVATE int secondPage();
PRIVATE int modattr();
PRIVATE void usage();
PRIVATE int parse();
PRIVATE int parse2();
PRIVATE int table_disp();
PRIVATE int form_button();
PRIVATE int ip_refuse();
/* Sub-tables to analyse the DISPLAY-Keys */
static PARSE_ENTRY first_table[] = {
{"SECOND-PAGE", secondPage, NULL},
{ NULL, NULL, NULL }
};
static PARSE_ENTRY display_table[] = {
{"FIRST-PAGE", firstPage, first_table},
{ NULL, NULL, NULL }
};
/* Sub-tables to analyse the MODIFY-Keys */
static PARSE_ENTRY modify_table[] = {
{"MODATTR", modattr, NULL},
{ NULL, NULL, NULL }
};
/* Sub-tables to analyse the IND_ATTRS-Keys */
static PARSE_ENTRY ind_attrs_table[] = {
{"IND_ATTRS", ind_attribute, NULL},
{ NULL, NULL, NULL }
};
/* The main-table for key-word-parsing */
static PARSE_ENTRY parse_table[] = {
{"WEBDN", webdn, NULL},
{"WEBPW", webpw, NULL},
{"WEBDN2", webdn2, NULL},
{"WEBPW2", webpw2, NULL},
{"WEBPORT", webport, NULL},
{"TIMEOUT", timeout, NULL},
{"TWEBHOST", hostname, NULL},
{"LDAPD", ldapd, NULL},
{"LDAPPORT", ldapportf, NULL},
{"HEADER", header, NULL},
{"FOOTER", footer, NULL},
{"INDEX-URL", index_url, NULL},
{"ALLOW-MSG", allow_msg, NULL},
{"HELPFILE", helpfilef, NULL},
{"FILTERFILE", filterfilef, NULL},
{"ETCDIR", etcdir, NULL},
{"FRIENDLYFILE", friendlyfilef, NULL},
{"GRANT", grant, NULL},
{"REFUSE", refuse, NULL},
{"ALLOW-STRING", allow_string, NULL},
{"ALLOW-PROXY", allow_proxy, NULL},
{"SUBTREE-SEARCH", subtree_search, NULL},
{"DENY-STRING", deny_string, NULL},
{"SHOW-DEFAULT-OC", show_defoc, NULL},
{"DISPLAY-OBJECT" , display, display_table},
{"BASEDN", basednf, NULL},
{"SEARCH-ONLY", search_only, NULL},
{"GW-SWITCH", gw_switch, NULL},
{"MODIFY", modify, modify_table},
{"INDIRECT-ATTRS", ind_attrs, ind_attrs_table},
{"MAXCOUNT", maxcount, NULL},
{"CACHE-EXPIRE-DEFAULT", cache_expire, NULL},
{"MAX-PERSON", max_person, NULL},
{"CACHING-TERMS", caching_terms, NULL},
{"COMREFUSE", comrefuse, NULL},
{"LANGUAGE", language, NULL},
{"STRIP-PIN", strip_pin, NULL},
{"PREFER-REF-URIS", prefer_ref_uris, NULL},
{"PULL-DOWN-MENUS", pull_down_menus, NULL},
{"NO-PROXY", no_proxy, NULL},
{"DISP-SEA-RDN", disp_sea_rdn, NULL},
{"STRICT-BASEDN", strict_basedn, NULL},
{"DYNAMIC-GW", dynamic_gw, NULL},
{"LEGAL", legal, NULL},
{"NO-SHOW-RDN", no_show_rdn, NULL},
{"NO-MODIFY", no_modify, NULL},
{"SORT", sort, NULL},
{"TABLES", table_disp, NULL},
{"FORM-BUTTON", form_button, NULL},
#ifdef AMBIXGW
{"SELBSTEINTRAG", selbsteintrag, NULL},
#endif
#ifdef TUE_TEL
{"DIT-CONFIG", dit_config, NULL},
{"PHONEWORLD", phoneworld, NULL},
{"TON-URLS", ton_urls, NULL},
#endif
{"IP-REFUSE", ip_refuse, NULL},
{ NULL, NULL, NULL }
};
/* tables to compute DISPLAY-types to integer */
STRDISP disp_types[] = {
{ "DEFAULT", 3, 0 },
{ "MAILTO", 4, 6 },
{ "MULTILINE", 5, 1 },
{ "JPEG", 4, 9 },
{ "JPEG2GIF", 8, 10 },
{ "BMP", 3, 8 },
{ "HREF", 4, 2 },
{ "URL", 3, 5 },
{ "FINGER", 6, 3 },
{ "DATE", 4, 4 },
{ "MOVETO", 4, 7 },
{ "BOOLEAN", 9, 11 },
{ "URI", 3, 12 },
{ "PGPKEY", 6, 13 },
{ "INDEXURL", 8, 14 },
{ "DYNAMICDN", 9, 15 },
{ "REFERRAL", 8, 20 },
{ "PRE", 3, 21 },
{ "HEADER", 6, 22 },
#ifdef TUE_TEL
{ "PHONREFSHORT", 12, 16 },
{ "PHONREFLONG", 11, 17 },
{ "TFUNCPERS", 9, 18 },
{ "FAXTABLE", 8, 19 },
#endif
{ NULL, 0, 0 }
};
/* tables to compute syslog-options to integer */
static STRDISP syslog_types[] = {
{ "LOCAL0", 6, LOG_LOCAL0 },
{ "LOCAL1", 6, LOG_LOCAL1 },
{ "LOCAL2", 6, LOG_LOCAL2 },
{ "LOCAL3", 6, LOG_LOCAL3 },
{ "LOCAL4", 6, LOG_LOCAL4 },
{ "LOCAL5", 6, LOG_LOCAL5 },
{ "LOCAL6", 6, LOG_LOCAL6 },
{ "LOCAL7", 6, LOG_LOCAL7 },
{ NULL, 0, 0 }
};
/* Defaults */
#define DEFAULT_TIMEOUT 120
#define DEFAULT_MAXCOUNT 200
#define MAX_EXPIRE 604800
/* Variable for the Anti-Hack-Code */
extern COMREFUSE *comRefuseP;
struct timeval timestore[5]; /* Time assigned to events:
0 -> after accept, 1-> after dns,
2 -> after check4access,
3 -> before list_output/print_attr */
int items_displayed = 0; /* number of items showed on
do_menu/do_search*/
#endif /* _INIT_ */

382
contrib/tweb/init_exp.h Normal file
View File

@ -0,0 +1,382 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* init_exp.h. *
* *
* Function:..File for TWEB-SOFTWARE *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* July 21 1995 Z D D V V *
* Last modification: Z D D V V *
* May 11 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: init_exp.h,v 1.6 1999/09/10 15:01:17 zrnsk01 Exp $
*
*/
#ifndef _INIT_EXP_
#define _INIT_EXP_
#ifdef TUE_TEL
# include "tueTel_exp.h"
#endif
#include "regular_exp.h"
PUBLIC int get_str_param(/* FILELINE *inLine, char **str,
GLOB_STRUCT *glob, int lower */);
PUBLIC void getopts ();
PUBLIC void check ();
PUBLIC void init();
PUBLIC void output();
PUBLIC void langinit();
PUBLIC void langoutput();
PUBLIC void get_lang();
PUBLIC void file_test();
PUBLIC int do_readf();
PUBLIC void get_index_url_rules();
PUBLIC void re_read_index_url_rules();
extern STRDISP disp_types[];
/* A pointer to an integer-function */
typedef int (*IFP)();
/* One line in the config-file, with line-counter */
typedef struct _fileline {
char value[BUFSIZ];
int count;
} FILELINE;
/* Table-structure to parse the key-words in the config- und rc-files */
typedef struct _parse_keys {
char *keyWord;
IFP keyFunc;
struct _parse_keys *subTable;
} PARSE_ENTRY;
/* Maximum number of sub-lists in order to display result-lists */
#define MAX_OCS 128
/* List of attributes which will be displayed (on 1./2. page) */
typedef struct _display_line {
char *attribute; /* the X.500-Attribute */
char *label; /* the Label of the Web-Page */
char *type; /* the Format-Type as String (C-Option) */
int ty; /* the Format-Type as Int (print-Funkt.) */
struct _display_line *next; /* the next Attribute */
} DISPLAY_LINE, *pDISPLAY_LINE;
/* List of Object-Classes which shall be displayed */
typedef struct _display {
char *ocs; /* the X.500-Object-Class(es) */
DISPLAY_LINE *first_page; /* Attribute on the first page */
DISPLAY_LINE *second_page; /* Attribute on the second page */
struct _display *next; /* the next Objekt-Class(es) */
} DISPLAY, *pDISPLAY;
/* List of attributes which may be modified */
typedef struct _modify_line {
char *attribute; /* the X.500-attribute */
char *label; /* the Label in the modification-formulare */
int count; /* the maximmum number of attribute-values */
struct _modify_line *next; /* the next attribute */
} MODIFY_LINE, *pMODIFY_LINE;
/* List of Object-Class(es) which may be modified */
typedef struct _modify {
char *ocs; /* the X.500-Object-Class(es) */
MODIFY_LINE *modattr; /* the modifyable attributes */
struct _modify *next; /* the next Object-Class(es) */
} MODIF, *pMODIF;
/*attributes which are read from another entry */
typedef struct _ind_attr_arr {
char *key; /* pers for person etc. */
int replace; /* 2 -> function, 1 -> replace, 0 -> append */
char *attr; /* functionname / referenced attribute */
char *host; /* on which host to look */
int port; /* on which port to look */
char *base; /* where to look for ref-entry */
LDAPMessage **e; /* Pointer to the result */
LDAP *ld; /* Pointer to the matching LDAP-Struct */
} IND_ATTR_ARR;
typedef struct _ind_attrs {
char *ref_attr; /* name of the reference-attribute */
IND_ATTR_ARR *valid_nodes; /* valid nodes array (only in 1st element) */
IND_ATTR_ARR *ia_arr; /* supported keys, attrs and bases */
struct _ind_attrs *next; /* the next ind_attr */
} IND_ATTRS, *pIND_ATTRS;
/* Support-structure to sort the result-lists */
typedef struct _dncompare {
char *string; /* Sort-String */
char *href; /* Hyper-Link for the sorted entry */
char *raw; /* Raw data: -> <name>[<attr>=<value>&..%..$.. */
} DNLIST, *pDNLIST;
/* Structure to sort the result-lists object-class/attribute-related */
typedef struct _sort_line {
char *object_class; /* Object-class by which is sorted */
char *label; /* Label to display sub-lists */
int priority; /* Sequence for list-output */
char *display_class; /* dedicated display-class */
DISPLAY *display_class_ptr; /* Pointer therefor */
char *sort_attr; /* Attribut by which sorting is done */
pDNLIST *dnList; /* Entries in the sub-list */
int dnLast; /* Amount of entries in the sub-list */
int restricted; /* 1 -> sub-list was restricted : 0 -> not*/
struct _sort_line *next; /* the next Object-Class */
} SORT_LINE, *pSORT_LINE;
/* Structure to handle caching */
typedef struct _caching_terms_line {
int time; /* time to cache */
char *access_type; /* type of access */
int rdn_oc; /* 1 -> rdn, 0 -> oc -lookup */
char *pattern; /* mach-pattern: oc/rdn */
struct _caching_terms_line *next; /* the next line */
} CACHING_TERMS_LINE, *pCACHING_TERMS_LINE;
/* DN of the TWEB-Homepage, including header and footer thereof */
typedef struct _basedn_line {
char *dn;
char **dnarray;
char *head;
char *foot;
} BASEDN_LINE;
/* List of rules for table-button and table display */
typedef struct _table_display {
int allow; /* 1 -> tables only if allowed, 0 -> in any case */
char *select_oc; /* table-button only if
objectclass contains select_oc */
char *button_label; /* label for table-request-button */
char *dn_extension; /* extension behind button Xdn?MENU */
struct _table_display *next;
} TABLE_DISPLAY, *pTABLE_DISPLAY;
/* List of organisational units where only searching is permitted,
including header and footer thereof */
typedef struct _search_only_line {
char *dn;
char *head;
char *foot;
struct _search_only_line *next;
} SEARCH_ONLY_LINE, *pSEARCH_ONLY_LINE;
/* Anti-Hack Structure */
typedef struct _comrefuse {
int tmin;
int tdiff;
int maxAccept;
int suspendCycle;
time_t statCycle;
char *statFile;
} COMREFUSE;
/* static list of Gateway-Switches */
typedef struct _gw_switch_line {
char *dn; /* the DN of the organization(al unit) */
char *url; /* the URL of the gateway to be called */
struct _gw_switch_line *next; /* the next Gateway-Switch */
} GW_SWITCH_LINE, *pGW_SWITCH_LINE;
/* the head of the Gateway-Switch-list */
typedef struct _gw_switch {
int dynamic; /* is dynamic switching allowed */
char *lagws; /* language dependant recognition of
GW-Switch-entries in X.500
(language independant recognition is
implemented by macro) */
GW_SWITCH_LINE *list; /* the static list of switches */
} GW_SWITCH, *pGW_SWITCH;
/* static list of already available ldap-connections */
typedef struct _ld_list {
LDAP *ld; /* pointer to the ldap-structure */
char *host; /* The corresponding host */
int port; /* The corresponding port */
struct _ld_list *next; /* the next */
} LD_LIST, *pLD_LIST;
typedef struct _index_url_rule {
char *rule; /* Atribute providing data */
char *dit_dn; /* DN supporting config */
} INDEX_URL_RULE;
typedef struct _index_url {
char *dat_file; /* File providing data */
#define INDEX_RULE_SIZE 20
INDEX_URL_RULE rarr[INDEX_RULE_SIZE]; /* array with rules */
int rereadcycle; /* frequency to reread */
} INDEX_URL;
/* Structure to hold config of buttons leading to form-scripts */
typedef struct _form_button {
int read_menu; /* 1-> button in do_read; 0-> in do_menu */
char *object_class; /* display the button on presence of this
object-class*/
char *method; /* cgi method: GET .. */
char *script_url; /* URL of CGI-Script */
char *text; /* text in front of button */
char *dn_name; /* name of dn in hidden form */
char *form_name; /* name of form (submit-button) */
char *button_label; /* label of submit-button */
struct _form_button *next; /* the next FORM_BUTTON definition */
} FORM_BUTTON, *pFORM_BUTTON;
typedef struct _ip_refuse {
char *dat_file; /* File providing data */
char *refu_str; /* String of refused clients */
#define REFU_BUFSIZ 256
#define REFU_STRDELIM "&"
int rereadcycle; /* frequency to reread */
} IP_REFUSE;
/* the central structure of TWEB with the configuration of the gateway */
typedef struct _glob_struct {
char *webdn; /* GW-DN in case of authorisded access */
char *webpw; /* GW-PW in case of authorisded access */
char *webdn2; /* GW-DN in case of non-authorisded access */
char *webpw2; /* GW-PW in case of non-authorisded access */
int webport; /* the Port the GW is listening on */
int timeout; /* how long does the gateway wait for the DSA*/
time_t stat_slice; /* Time for the anti-Hack + Statistic */
char *ldapd; /* the computer LDAPD is running on */
int ldapport; /* the Port thereof */
char *grant; /* ':'-separated list of domains with access */
char *refuse; /* ':'-separated list of domains
without access */
char *allow_string; /* ':'-separated list of domains
supported with authorised access */
char *deny_string; /* ':'-separated list of domains
supported with restricted access */
regexp *comp_grant; /* compiled regular expressions for GRANT */
regexp *comp_refuse; /* compiled regular expressions for REFUSE */
regexp *comp_allow; /* compiled regular expressions for ALLOW_ST */
regexp *comp_deny; /* compiled regular expressions for DENY_ST. */
char **allow_proxy; /* ':'-separated list of proxy-servers
supported with authorised access */
char **subtree_search; /* ':'-separated list of objectclasses
where to make subtree_search instead of
single_level_search */
DISPLAY *display; /* presentation of Objects */
DISPLAY *default_display_type; /* pointer to the default display descript */
BASEDN_LINE *basedn; /* the entry-page of TWEB */
SEARCH_ONLY_LINE *search_only; /* where only searching is supported */
GW_SWITCH *gw_switch; /* the Gateway-Switching */
MODIF *modify; /* what may be modified within TWEB */
IND_ATTRS *ind_attrs; /*attributes which are read from
another entry */
int cache_expire; /* caching-time for proxies in seconds */
CACHING_TERMS_LINE *caching_terms; /* cache-control-rules */
int maxcount; /* maximum amount of result-lists */
int max_person; /* maximum amount of persons displayed */
COMREFUSE *comrefuse; /* Anti-Hack Structure */
TABLE_DISPLAY *tables; /* listings also as tables by button-request */
INDEX_URL *index_url; /* how to display search-results of index
-> display-type INDEX-URL */
FORM_BUTTON *form_button; /* display buttons leading to forms */
char *tables_marker; /* flag for menu with tables += their config */
char **language; /* the language links on a html-page */
char lang[2]; /* the number of the "own" language */
char *olang; /* the other languages */
char *no_show_rdn; /* String with "unvisible" DN parts */
char *no_modify; /* Objectclasses without MODIFY-button */
SORT_LINE *sort; /* how shall the results be sorted */
SORT_LINE *sorty[MAX_OCS]; /* Array with the sorted lists */
char **sort_attribs; /* Array with the sort-attributes */
char *myname; /* the programname */
char *argv0; /* ARGV[0] */
char *hostname; /* the name of the computer TWEB
is running on*/
int virtualport; /* port if defined is set in every link
instead of webport (may always
lead requests over www4ward) */
char *header; /* the header for the standardpage */
char *footer; /* the footer for the standardpage */
char *allow_msg; /* file containing allow-message */
char *helpfile; /* the helpfile */
char *filterfile; /* the filterfile for LDAP-search */
char *etcdir; /* the directory containing the supportfiles */
char *friendlyfile; /* the file for "more friendly" DNs */
char *acfilename; /* the name of the actual config-file */
time_t nowtime; /* actual time in tics */
time_t expiretime; /* time for cache to expire in tics */
char *nowtimestr; /* actual timestring in GMT */
char *strip_pin; /* truncation of PINs at named sort_ocs */
char *expiretimestr; /* timestring for cache to expire in GMT */
char *server_connection_msg; /* TCP Connection-message */
char *user_agent_msg; /* User-Agent message */
char *menu_filter; /* menu_filter */
#define LANG_ARR_SIZE 110
char la[LANG_ARR_SIZE][BUFSIZ]; /* language-specific text-fragments */
LD_LIST *ld_list; /* List of open LDAP-Connections */
char **raw_attrs; /* Attributes to be shown with raw_access */
size_t svc_cnt; /* A counter for the number of requests */
#ifdef TUE_TEL
DIT_CONFIG *dit_config; /* container for relations between DNs and
responsible host:port */
TON_URLS *ton_urls; /* TONs in addition to DNs */
char *phoneworld; /* visibility of phonebook */
#endif
IP_REFUSE *ip_refuse; /* refuse certain hosts by ip-addr */
#ifdef AMBIXGW
char *selbsteintrag[10]; /* some strings for AMBIX-selfentry */
#endif
unsigned show_defoc : 1, /* respect unknown OCs while sorting */
strict : 1, /* restriction of person-lists also in the
authorised case */
restricted : 1, /* hard restriction of the extent of the list*/
persRestricted : 1, /* restriction of person-lists (legal) */
prefer_ref_uris : 1, /* take over labeledURIS from
referenced objects */
is_proxy : 1, /* did the request come from a proxy-server */
pull_down_menus : 1, /* move upwards with pull-down-menus */
no_proxy : 1, /* no local proxy-servers */
strict_basedn : 1, /* no access outside BASEDN */
no_browse : 1, /* no person-lists while browsing */
noauth : 1, /* dynamic flag for question of authorisation*/
caching : 1, /* shall be cached by proxy-server */
legal : 1, /* display privacy-text */
legal_top : 1, /* display privacy-text on top */
unknown_host : 1, /* connection from unknown */
allowed : 1; /* access allowed for decide_access */
unsigned raw_data : 1, /* provide raw-data instead of html */
ldap_referral_mode : 1, /* TWEB displayes foreign ldap-url */
disp_sea_rdn : 1; /* display only rdns as search-result */
} GLOB_STRUCT, *pGLOB_STRUCT;
/* the function the gateway is initialized with */
void init();
#endif /* _INIT_EXP_ */

735
contrib/tweb/queries.c Normal file
View File

@ -0,0 +1,735 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* queries.c.. *
* *
* Function:..WorldWideWeb-X.500-Gateway - Server-Functions *
* Based on web500gw.c 1.3 written by Frank Richter, TU Chemmniz *
* which is based on go500gw by Tim Howes, University of *
* Michigan - All rights reserved *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* August 16 1995 Z D D V V *
* Last modification: Z D D V V *
* May 11 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: queries.c,v 1.6 1999/09/10 15:01:18 zrnsk01 Exp $
*
*/
#include "queries.h"
PUBLIC void do_queries( s, glob , ip_addr, ip_port, hp)
int s;
GLOB_STRUCT *glob;
char *ip_addr;
unsigned int ip_port;
struct hostent *hp;
{
char buf[100*BUFSIZ], *query, *tail;
int len;
FILE *fp;
int rc, tblsize;
struct timeval timeout;
fd_set readfds;
LDAP *ld;
char tstring[100];
/* get time for performance log */
gettimeofday(&timestore[2], NULL);
/* open output-port to waiting client */
if ( (fp = fdopen( s, "a+")) == NULL ) {
perror( "fdopen" );
exit_tweb( 1 );
}
tblsize = getdtablesize();
timeout.tv_sec = glob->timeout;
timeout.tv_usec = 0;
FD_ZERO( &readfds );
FD_SET( fileno( fp ), &readfds );
time(&glob->nowtime);
time(&glob->expiretime);
if(glob->cache_expire) {
glob->expiretime += glob->cache_expire;
glob->caching =TRUE;
}
free(glob->nowtimestr);
free(glob->expiretimestr);
strftime(tstring, 99, GMT_FORMAT, gmtime(&glob->nowtime));
glob->nowtimestr = strdup(tstring);
strftime(tstring, 99, GMT_FORMAT2, gmtime(&glob->expiretime));
glob->expiretimestr = strdup(tstring);
/* get client-query out from the system */
if((rc=select(tblsize,(fd_set *)&readfds,NULL,NULL,&timeout))<=0)
exit_tweb( 1 );
if ( fgets( buf, sizeof(buf), fp ) == NULL )
exit_tweb( 1 );
/* Analyse Web-Client-Type / proxy + log-message */
checkwwwclient(fp, ip_addr, ip_port, hp, glob);
len = strlen( buf );
if ( debug ) {
fprintf( stderr, "got %d bytes\n", len );
lber_bprint( buf, len );
}
/* strip of white spaces */
query = trim (buf, WSPACE);
rewind (fp);
/* strip "HTTP" from the end of the request */
if ((tail = strstr(query, " HTTP")) != NULL ||
(tail = strstr(query, " http")) != NULL) {
http = 1;
*tail = '\0';
}
/* recognize GET/HEAD */
if (!strncasecmp (query, "get", 3)) {
request = GET;
query += 3;
} else if (!strncasecmp (query, "head", 4)) {
request = HEAD;
query += 4;
} else {
/* Error because of neither GET- nor HEAD-request */
do_error(fp, -2, NOT_IMPLEMENTED, glob);
/* fprintf(fp, "HTTP/1.0 501 %s<br>", glob->la[5]); */
rewind(fp);
exit_tweb( 1 );
}
/* strip off leading white space and '/' */
while ( isspace( *query ) || *query == '/') {
++query;
}
/* Now the real request is to be analized and served */
/* refuse robots if according robots.txt file exists */
if (!strcasecmp(query, "robots.txt")){
if (http == 1) PRINT_PLAIN_HEADER;
disp_file(glob, ROBOTS_TXT_FILE, fp);
exit_tweb(0);
}
#ifdef TUE_TEL
if( glob->ton_urls && *query == cTON) {
if(!glob->ton_urls->admin)
glob->allowed = 0;
if(glob->ton_urls->pass_oc) {
glob->max_person = 10000;
glob->no_browse = FALSE;
}
}
#endif
decide_access(glob);
/* get time for performance log */
gettimeofday(&timestore[3], NULL);
/* perform handling of pulldown/form retcodes
-> gwswitch-redirect || pass */
if(*query == cPULLDOWN) {
if(strstr(query, "http")) {
/* redirection */
query += 4;
hex_decode(query);
PRINT_REDIRECT_HEADER;
PRINT_HTML_FOOTER;
exit_tweb(0);
} else {
/* pass */
query += 7;
hex_decode(query);
}
}
/* perform handling of buttons/form retcodes
-> gwswitch-redirect || pass */
if(*query == cBUTTON) {
char *strptr;
query += 2;
strptr = strrchr( query, '=' );
*strptr = '\0';
if(strstr(query, "http")) {
/* redirection */
hex_decode(query);
PRINT_REDIRECT_HEADER;
PRINT_HTML_FOOTER;
exit_tweb(0);
} else {
/* pass */
hex_decode(query);
}
}
/* 1. requests that may be served without DSA */
switch (*query) {
/* display Help-File */
case cHELP:
if (dosyslog)
syslog (LOG_INFO, "working on query: %c (%s,%u) <%08d>",
cHELP, ip_addr, ip_port, glob->svc_cnt);
if (http == 1) PRINT_HTML_HEADER;
fprintf(fp, "<HTML><HEAD>");
disp_file(glob, glob->helpfile, fp);
PRINT_HTML_FOOTER;
rewind(fp);
exit_tweb( 0 );
/* request error-explanation */
case cERROR:
if (dosyslog)
syslog (LOG_INFO, "working on query: %c (%s,%u) <%08d>",
cERROR, ip_addr, ip_port, glob->svc_cnt);
/* fprintf(fp, HTML_HEAD_TITLE, "Errors", glob->la[100]);
*/
do_error( fp, 0 , 1, glob );
rewind(fp);
exit_tweb( 0 );
/* RCC: remote configuration control */
case cCONFIG:
if (dosyslog)
syslog (LOG_INFO, "working on query: %c (%s,%u) <%08d>",
cCONFIG, ip_addr, ip_port, glob->svc_cnt);
if (http == 1) PRINT_HTML_HEADER;
fprintf(fp, HTML_HEAD_TITLE, "Configuration", glob->la[100]);
output(fp, glob, TRUE);
langoutput(fp, glob, TRUE);
PRINT_HTML_FOOTER;
rewind(fp);
exit_tweb(0);
/* query access-statistic */
case cSTATS:
if (dosyslog)
syslog (LOG_INFO, "working on query: %c (%s,%u) <%08d>",
cSTATS, ip_addr, ip_port, glob->svc_cnt);
if (http == 1) PRINT_HTML_HEADER;
fprintf(fp, HTML_HEAD_TITLE, "Statistics", glob->la[100]);
fprintf(fp,
"\n<strong>#############STATISTIC-DISPLAY#############</strong><br>\n" );
fprintf( fp, "\n%s\n\n<p>\n", version );
(void) put_hackStats (fp, 0);
PRINT_HTML_FOOTER;
rewind (fp);
exit_tweb (0);
/* NOT REACHED */
}
/* with ldap-referral use this host + port + use do_read */
/* query looks like this: Wldap://host:port/dn */
if ( *query == cREFERRAL ) {
char *host, *port, *dn = NULL;
glob->ldap_referral_mode = 1;
if ( ( host = strstr( query, "ldap://" ) ) ) {
host += 7;
if ( ( port = strchr( host, ':' ) ) ) {
*port++ = '\0';
if ( ( dn = strchr( port, '/' ) ) ) {
*dn = '\0';
glob->ldapd = strdup ( host );
glob->ldapport = atoi ( port );
*dn = cREAD;
query = dn;
}
}
}
if ( !dn )
exit_tweb( 1 );
}
/* from here on there is needed a connection to the DSA */
if ( (ld = ldap_open( glob->ldapd, glob->ldapport )) == NULL ) {
if ( debug ) perror( "ldap_open" );
do_error( fp, LDAP_SERVER_DOWN, SERVER_ERROR, glob);
rewind(fp);
exit_tweb( 1 );
}
if(glob->caching_terms)
trade_cache(fp, ld, query, glob);
/* performance of STRICT-BASEDN (blind out accesses != BASEDN) */
if(glob->strict_basedn)
strict_basednf(fp, ld, query, glob);
/* 2. queries with binding of the owner */
switch (*query) {
/* request of the modification-formulare */
case cGETMOD:
/* log the request without password */
hex_decode(query);
if (dosyslog) {
char qbuf[BUFSIZ], *qbufp;
strcpy(qbuf, query);
if( ( qbufp = strchr(qbuf, '?')) )
*qbufp = '\0';
syslog (LOG_INFO, "working on query: %s (%s,%u) <%08d>",
qbuf, ip_addr, ip_port, glob->svc_cnt);
}
rewind(fp);
/* follow aliases while searching */
#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION
# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010
ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_ALWAYS );
# endif
#else
ld->ld_deref = LDAP_DEREF_ALWAYS;
#endif
if ( !searchaliases )
#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION
# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010
ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_FINDING );
# endif
#else
ld->ld_deref = LDAP_DEREF_FINDING;
#endif
/* send WWW-Formulare with contence of the desired entry
to the client */
do_form( ld, fp, ++query, glob);
ldap_unbind (ld);
close_ldap_connections(glob);
rewind(fp);
exit_tweb (0);
/* return of the modification-formulare */
case cDOMOD:
/* log the request in readable form without password if desired */
if (dosyslog) {
char qbuf[100*BUFSIZ], *qbufp;
strcpy(qbuf, query);
if( ( qbufp = strchr (qbuf, '?')) )
*qbufp = '\0';
hex_decode(qbuf+1);
syslog (LOG_INFO, "working on query: %s (%s,%u) <%08d>",
qbuf, ip_addr, ip_port, glob->svc_cnt);
}
/* perform modification with the original request */
do_modify( ld, fp, ++query, glob);
ldap_unbind (ld);
close_ldap_connections(glob);
rewind(fp);
exit_tweb (0);
/* NOT REACHED */
}
/* perform all the other requests */
/* log the request in readable form first */
hex_decode(query);
if (dosyslog)
syslog (LOG_INFO, "working on query: %s (%s,%u) <%08d>",
*query ? trimright(query, WSPACE) : "BASEDN", ip_addr, ip_port,
glob->svc_cnt);
/* accesses with resolvation of alias-entries */
#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION
# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010
ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_ALWAYS );
# endif
#else
ld->ld_deref = LDAP_DEREF_ALWAYS;
#endif
if ( !searchaliases )
#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION
# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010
ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_FINDING );
# endif
#else
ld->ld_deref = LDAP_DEREF_FINDING;
#endif
/* bind to DSA by order of the user as Web-DN
(if with DN1 or DN2 was decided at check4access) */
#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION
# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010
/* a dummy call as long as socket connections are not settled
* with OpenLDAP
*/
if ( dosyslog )
syslog( LOG_INFO, "do_queries(): calling ldap_simple_bind_s()...\n" );
# else
if ( dosyslog )
syslog( LOG_INFO, "do_queries(): calling ldap_simple_bind_s()...\n" );
# endif
#endif
if ( (rc=ldap_simple_bind_s( ld, glob->webdn, glob->webpw ))
!= LDAP_SUCCESS ) {
if ( debug ) ldap_perror( ld, "ldap_simple_bind_s" );
do_error( fp, rc, SERVER_ERROR, glob);
rewind(fp);
exit_tweb( 1 );
}
/* 3. requests to the GW by order of the user */
switch ( *query++ ) {
/* read entry */
case cREAD:
do_read( ld, fp, query, 0, glob );
break;
/* display second page */
case cREADALL:
do_read( ld, fp, query, 1, glob);
break;
/* search entries */
case cSEARCH:
do_search( ld, fp, query, glob );
break;
/* list entries (browsing) */
case cLIST:
do_menu( ld, fp, query, "", glob );
break;
#ifdef TUE_TEL
/* list entries (browsing TON instead of DN) */
case cTON:
if(glob->ton_urls)
do_ton( ld, fp, query, glob );
break;
#endif
/* request GIF-photo (Photo in X.500 as JPEG) */
case cGIF:
do_pict( ld, fp, query, 1, glob);
break;
/* display JPEG-Photo */
case cJPEG:
do_pict( ld, fp, query, 2, glob);
break;
/* display X.500-G3FAX-Photo */
case cG3FAX:
do_pict( ld, fp, query, 0, glob);
break;
/* play Audio-attribute */
case cAUDIO:
do_audio( ld, fp, query, 0, glob);
break;
/* eXtended query format */
case cEXTENDED:
do_xtend( ld, fp, query, 0, glob);
break;
/* Default (empty query) is browsing of BASEDN */
default:
do_menu( ld, fp, glob->basedn->dn, "", glob );
break;
}
/* Job done, terminate connection to the DSA and bye! */
ldap_unbind (ld);
close_ldap_connections(glob);
rewind(fp);
exit_tweb( 0 );
/* NOT REACHED */
}
/* end of function: do_queries */
PUBLIC void timeoutf(sig)
int sig;
{
/* fprintf(stderr, "timeout!"); */
exit_tweb(0);
}
/* end of function: timeoutf */
PRIVATE void strict_basednf(fp, ld, query, glob)
FILE *fp;
LDAP *ld;
char *query;
GLOB_STRUCT *glob;
{
char dnbuf[BUFSIZ], basednbuf[BUFSIZ], *strptr;
LDAPMessage *res, *e;
int rc, flag = 0, i, j;
struct timeval timeout;
char *url = NULL, **uri, *urlnola = NULL;
pGW_SWITCH_LINE gw_ptr;
char *url_tmp;
char **dnarray, **bdnarray;
#ifdef TUE_TEL
/* Patch for TONS */
if( glob->ton_urls && (*query == cTON))
return;
#endif
/* Patch for FORMs/PULLDOWNs (cPULLDOWN) */
if( glob->pull_down_menus && (*query == cPULLDOWN))
return;
/* Patch for FORMs/BUTTONs (cBUTTONs) */
if( glob->pull_down_menus && (*query == cBUTTON))
return;
if(*query)
strcpy(dnbuf, query+1);
else
strcpy(dnbuf, "\0");
hex_decode(dnbuf);
strcpy(basednbuf, glob->basedn->dn);
if( ( strptr = strchr(dnbuf, '?')) )
*strptr = '\0';
if( *query && !dn_issuffix( dn_normalize(dnbuf), dn_normalize(basednbuf))) {
dnarray = dn2charray(dnbuf);
bdnarray = glob->basedn->dnarray;
strcpy(dnbuf, "\0");
if (glob->gw_switch) {
for(gw_ptr = glob->gw_switch->list;
!flag && gw_ptr; gw_ptr = gw_ptr->next) {
if (!dn_cmp ("root", gw_ptr->dn)) {
flag = 1;
url = gw_ptr->url;
}
}
}
if(!flag) {
fprintf(stderr, "Fehler:strict_basedn w/o root-switch!!!!\n");
exit_tweb(0);
}
for(j=0; bdnarray[j] && dnarray[j]; j++) {
char *dnbufb;
flag = 0;
dnbufb = strdup(dnbuf);
sprintf(dnbuf, "%s%s%s", dnarray[j], *dnbuf ? "," : "" , dnbufb);
if ( glob->gw_switch && glob->gw_switch->dynamic) {
if ( (rc=ldap_simple_bind_s( ld, glob->webdn, glob->webpw ))
!= LDAP_SUCCESS ) {
if ( debug ) ldap_perror( ld, "ldap_simple_bind_s" );
do_error( fp, rc, SERVER_ERROR, glob);
rewind(fp);
exit_tweb( 1 );
}
timeout.tv_sec = glob->timeout;
timeout.tv_usec = 0;
if ( (rc = ldap_search_st( ld, dnbuf, LDAP_SCOPE_BASE, "objectClass=*",
NULL, 0, &timeout, &res )) != LDAP_SUCCESS ) {
/* do_error(fp, rc, NOT_FOUND, glob);
*/
continue;
}
if ( (e = ldap_first_entry( ld, res )) == NULL ) {
do_error(fp, -2, SERVER_ERROR, glob);
return;
}
uri = ldap_get_values( ld, e, "labeledURI" );
for(i=0; uri && uri[i] && *uri[i]; i++) {
char *sp;
if( ( sp = strchr(uri[i], ' ')) ) {
*sp++ = '\0';
if(strstr(sp, glob->gw_switch->lagws)) {
flag = 1;
url = uri[i];
break;
} else if(strstr(sp, GWS))
urlnola = uri[i];
}
}
}
if(!flag && urlnola) {
url = urlnola;
flag = 1;
}
if (glob->gw_switch) {
for(gw_ptr = glob->gw_switch->list;
!flag && gw_ptr; gw_ptr = gw_ptr->next) {
if (!dn_cmp (dnbuf, gw_ptr->dn)) {
flag = 1;
url = gw_ptr->url;
}
}
}
if(strcmp(bdnarray[j], dnarray[j]))
break;
}
if (http == 1) PRINT_HTML_HEADER;
fprintf( fp, HTML_HEAD_TITLE, "ACCESS DENIED", glob->la[100]);
disp_file(glob, glob->header, fp);
fprintf( fp, "%s\n", glob->la[96]);
url_tmp = strdup(url_complete(url, query, ""));
fprintf( fp, "<P><A HREF=\"%s\"><b>%s</b></A>\n",
url_tmp, url_tmp);
disp_file(glob, glob->footer, fp);
PRINT_HTML_FOOTER;
ldap_unbind (ld);
close_ldap_connections(glob);
exit_tweb(0);
}
}
/* end of function: strict_basednf */
PRIVATE void trade_cache(fp, ld, query, glob)
FILE *fp;
LDAP *ld;
char *query;
GLOB_STRUCT *glob;
{
pCACHING_TERMS_LINE ca_ptr;
char dnbuf[BUFSIZ], rdn[BUFSIZ], *strptr;
char tstring[100];
int resflag;
int rc;
struct timeval timeout;
LDAPMessage *res, *e;
char **vals = NULL;
resflag = 0;
if(*query)
strcpy(dnbuf, query+1);
else
strcpy(dnbuf, glob->basedn->dn);
hex_decode(dnbuf);
if( ( strptr = strchr(dnbuf, '?')) )
*strptr = '\0';
strcpy(rdn, dnbuf);
if( ( strptr = strQuoteChr(rdn, ',')) )
*strptr = '\0';
for(ca_ptr = glob->caching_terms; ca_ptr; ca_ptr = ca_ptr->next) {
if((toupper(*query) == toupper(*ca_ptr->access_type)) ||
( !*query && (toupper(*ca_ptr->access_type) == 'M'))) {
if(ca_ptr->rdn_oc && (strstr(str_tolower(rdn), ca_ptr->pattern) ||
(*ca_ptr->pattern == '*'))) {
time(&glob->expiretime);
glob->expiretime += ca_ptr->time;
free(glob->expiretimestr);
strftime(tstring, 99, GMT_FORMAT2, gmtime(&glob->expiretime));
glob->expiretimestr = strdup(tstring);
glob->caching = TRUE;
}
if(!ca_ptr->rdn_oc) {
if(!resflag) {
if ( (rc=ldap_simple_bind_s( ld, glob->webdn, glob->webpw ))
!= LDAP_SUCCESS ) {
if ( debug ) ldap_perror( ld, "ldap_simple_bind_s" );
do_error( fp, rc, SERVER_ERROR, glob);
rewind(fp);
exit_tweb( 1 );
}
timeout.tv_sec = glob->timeout;
timeout.tv_usec = 0;
if ( (rc = ldap_search_st( ld, dnbuf, LDAP_SCOPE_BASE, "objectClass=*",
NULL, 0, &timeout, &res )) != LDAP_SUCCESS ) {
do_error(fp, rc, NOT_FOUND, glob);
return;
}
if ( (e = ldap_first_entry( ld, res )) == NULL ) {
do_error(fp, -2, SERVER_ERROR, glob);
return;
}
vals = ldap_get_values( ld, e, "objectClass" );
resflag = 1;
}
if(charray_inlist( vals, ca_ptr->pattern )) {
time(&glob->expiretime);
glob->expiretime += ca_ptr->time;
free(glob->expiretimestr);
strftime(tstring, 99, GMT_FORMAT2, gmtime(&glob->expiretime));
glob->expiretimestr = strdup(tstring);
glob->caching = TRUE;
}
}
}
}
}
/* end of function: trade_cache */

85
contrib/tweb/queries.h Normal file
View File

@ -0,0 +1,85 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* queries.h.. *
* *
* Funktion:..WorldWideWeb-X.500-Gateway - Server-Functions *
* Based on web500gw.c 1.3 written by Frank Richter, TU Chemmniz *
* which is based on go500gw by Tim Howes, University of *
* Michigan - All rights reserved *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: : Z D D V V *
* August 16 1995 Z D D V V *
* Last modification: Z D D V V *
* May 10 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: queries.h,v 1.6 1999/09/10 15:01:18 zrnsk01 Exp $
*
*/
#ifndef _QUERIES_
#define _QUERIES_
#include "tgeneral.h"
#include "tglobal.h"
#include "init_exp.h"
#include "checkclient_exp.h"
#include "support_exp.h"
#include "queries_exp.h"
#include "x500_exp.h"
#include "html_exp.h"
#include "server_exp.h"
#include "dn_exp.h"
#include "charray_exp.h"
#ifdef TUE_TEL
#include "tueTel_exp.h"
#endif
/* Macros for request-recognition */
/* 1. without DSA */
#define cHELP 'H'
#define cERROR 'E'
#define cCONFIG 'C'
#define cSTATS 'K'
#define cPULLDOWN 'D'
#define cBUTTON 'B'
/* 2. with user-bind */
#define cGETMOD 'F'
#define cDOMOD 'Y'
/* 3. with GW-bind */
#define cREAD 'R'
#define cREADALL 'L'
#define cSEARCH 'S'
#define cLIST 'M'
#ifdef TUE_TEL
#define cTON 'T'
#endif
#define cGIF 'I'
#define cJPEG 'J'
#define cG3FAX 'G'
#define cAUDIO 'A'
#define cREFERRAL 'W'
#define cEXTENDED 'X'
#define GMT_FORMAT "%a, %d %b %Y %T GMT"
#define GMT_FORMAT2 "Expires: %a, %d %b %Y %T GMT\n"
#define ROBOTS_TXT_FILE "robots.txt"
PRIVATE void strict_basednf();
PRIVATE void trade_cache();
#endif /* _QUERIES_ */

View File

@ -0,0 +1,33 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* queries_exp.h *
* *
* Function:..File for TWEB-SOFTWARE *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* February 13 1996 Z D D V V *
* Last modification: Z D D V V *
* November 21 1996 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: queries_exp.h,v 1.6 1999/09/10 15:01:18 zrnsk01 Exp $
*
*/
#ifndef _QUERIES_EXP_
#define _QUERIES_EXP_
PUBLIC void do_queries(/* s, glob , ip_addr, ip_port*/);
PUBLIC void timeoutf(/*sig*/);
#endif /* _QUERIES_EXP_ */

1211
contrib/tweb/regular.c Normal file

File diff suppressed because it is too large Load Diff

137
contrib/tweb/regular.h Normal file
View File

@ -0,0 +1,137 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* regular.h.. *
* *
* Function:..Routine for TWEB *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* January 20 1998 Z D D V V *
* Last modification: Z D D V V *
* December 31 1998 ZZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: regular.h,v 1.6 1999/09/10 15:01:19 zrnsk01 Exp $
*
*/
#ifndef _REGULAR_
#define _REGULAR_
/* definition number opnd? meaning */
#define END 0 /* no End of program. */
#define BOL 1 /* no Match "" at beginning of line. */
#define EOL 2 /* no Match "" at end of line. */
#define ANY 3 /* no Match any one character. */
#define ANYOF 4 /* str Match any character in this string. */
#define ANYBUT 5 /* str Match any character not in this string. */
#define BRANCH 6 /* node Match this alternative, or the next... */
#define BACK 7 /* no Match "", "next" ptr points backward. */
#define EXACTLY 8 /* str Match this string. */
#define NOTHING 9 /* no Match empty string. */
#define STAR 10 /* node Match this (simple) thing 0 or more times. */
#define PLUS 11 /* node Match this (simple) thing 1 or more times. */
#define OPEN 20 /* no Mark this point in input as start of #n. */
/* OPEN+1 is number 1, etc. */
#define CLOSE ((OPEN)+(NSUBEXP)+1) /* no Analogous to OPEN. */
/*
* Opcode notes:
*
* BRANCH The set of branches constituting a single choice are hooked
* together with their "next" pointers, since precedence prevents
* anything being concatenated to any individual branch. The
* "next" pointer of the last BRANCH in a choice points to the
* thing following the whole choice. This is also where the
* final "next" pointer of each individual branch points; each
* branch starts with the operand node of a BRANCH node.
*
* BACK Normal "next" pointers all implicitly point forward; BACK
* exists to make loop structures possible.
*
* STAR,PLUS '?', and complex '*' and '+', are implemented as circular
* BRANCH structures using BACK. Simple cases (one character
* per match) are implemented with STAR and PLUS for speed
* and to minimize recursive plunges.
*
* OPEN,CLOSE ...are numbered at compile time.
*/
/*
* A node is one char of opcode followed by two chars of "next" pointer.
* "Next" pointers are stored as two 8-bit pieces, high order first. The
* value is a positive offset from the opcode of the node containing it.
* An operand, if any, simply follows the node. (Note that much of the
* code generation knows about this implicit relationship.)
*
* Using two bytes for the "next" pointer is vast overkill for most things,
* but allows patterns to get big without disasters.
*/
#define OP(p) (*(p))
#define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
#define OPERAND(p) ((p) + 3)
/*
* See regmagic.h for one further detail of program structure.
*/
/*
* Utility definitions.
*/
#ifndef CHARBITS
#define UCHARAT(p) ((int)*(unsigned char *)(p))
#else
#define UCHARAT(p) ((int)*(p)&CHARBITS)
#endif
#define FAIL(m) { tweb_regerror(m); return(NULL); }
#define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?')
#define META "^$.[()|?+*\\"
/*
* Flags to be passed up and down.
*/
#define HASWIDTH 01 /* Known never to match null string. */
#define SIMPLE 02 /* Simple enough to be STAR/PLUS operand. */
#define SPSTART 04 /* Starts with * or +. */
#define WORST 0 /* Worst case. */
/*
* Global work variables for regcomp().
*/
PRIVATE char *regparse; /* Input-scan pointer. */
PRIVATE int regnpar; /* () count. */
PRIVATE char regdummy;
PRIVATE char *regcode; /* Code-emit pointer; &regdummy = don't. */
PRIVATE long regsize; /* Code size. */
/*
* Forward declarations for regcomp()'s friends.
*/
#ifndef STATIC
#define STATIC static
#endif
PRIVATE char *tweb_reg();
PRIVATE char *tweb_regbranch();
PRIVATE char *tweb_regpiece();
PRIVATE char *tweb_regatom();
PRIVATE char *tweb_regnode();
PRIVATE char *tweb_regnext();
PRIVATE void tweb_regc();
PRIVATE void tweb_reginsert();
PRIVATE void tweb_regtail();
PRIVATE void tweb_regoptail();
#ifdef STRCSPN
STATIC int tweb_strcspn();
#endif
#endif /* _REGULAR_ */

View File

@ -0,0 +1,56 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* regular_exp.h *
* *
* Function:..Routine for TWEB *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* January 20 1998 Z D D V V *
* Last modification: Z D D V V *
* January 20 1998 ZZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: regular_exp.h,v 1.6 1999/09/10 15:01:19 zrnsk01 Exp $
*
*/
#ifndef _REGULAR_EXP_
#define _REGULAR_EXP_
/*
* Definitions etc. for regexp(3) routines.
*
* Caveat: this is V8 regexp(3) [actually, a reimplementation thereof],
* not the System V one.
*/
#define NSUBEXP 10
typedef struct regexp {
char *startp[NSUBEXP];
char *endp[NSUBEXP];
char regstart; /* Internal use only. */
char reganch; /* Internal use only. */
char *regmust; /* Internal use only. */
int regmlen; /* Internal use only. */
char program[1]; /* Unwarranted chumminess with compiler. */
} regexp;
extern regexp *tweb_regcomp();
extern int tweb_regexec();
extern void tweb_regsub();
extern void tweb_regerror();
/*
* The first byte of the regexp internal "program" is actually this magic
* number; the start node begins in the second byte.
*/
#define MAGIC 0234
#endif /* _REGULAR_EXP_ */

432
contrib/tweb/server.c Normal file
View File

@ -0,0 +1,432 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* server.c... *
* *
* Function:..WorldWideWeb-X.500-Gateway - Server-Funktions *
* Based on web500gw.c 1.3 written by Frank Richter, TU Chemmniz *
* which is based on go500gw by Tim Howes, University of *
* Michigan - All rights reserved *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* August 16 1995 Z D D V V *
* Last modification: Z D D V V *
* May 6 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: server.c,v 1.6 1999/09/10 15:01:19 zrnsk01 Exp $
*
*/
#include "tgeneral.h"
#include "tglobal.h"
#include "init_exp.h"
#include "checkclient_exp.h"
#include "server.h"
#include "charray_exp.h"
#if defined( TUE_TEL ) || defined( AMBIXGW )
#include "tueTest_exp.h"
#endif
/**
** start_server()
**
** Start the Web-X.500-Server.
**/
PUBLIC void start_server(glob)
GLOB_STRUCT *glob;
{
int s, ns, rc;
int tblsize;
int pid = getpid();
fd_set readfds;
struct hostent *hp;
struct sockaddr_in from;
int fromlen;
void wait4child();
long int idx;
glob->stat_slice = time(&glob->stat_slice);
stat_slice = &glob->stat_slice;
/* if logging is desired via syslog establish connection to syslogd
and write first log-message */
if ( dosyslog ) {
openlog( glob->myname, LOG_PID | LOG_NOWAIT, dosyslog );
syslog( LOG_INFO, "initializing" );
}
/* set up the socket to listen on */
/* the actual port to listen is composed by the base-port
and the language-offset */
s = set_socket( glob->webport + atoi(glob->lang) );
/* arrange to reap children */
(void) signal( SIGCHLD, wait4child );
if ( dosyslog )
syslog (LOG_INFO, "socket: %d", s);
/* Read LDAP-filter for search-operations */
if ( (filtd = ldap_init_getfilter( glob->filterfile )) == NULL ) {
fprintf(stderr,"Cannot open filter file (%s)\n", glob->filterfile );
exit( 1 );
}
/* ### Code for the static server ### */
tblsize = getdtablesize();
syslog (LOG_INFO, "listening for calls...");
/* Initialisation of the Anti-Hack-code */
srand(pid);
if (glob->comrefuse) hackTimer();
bzero((char *) conArr, CARRSIZE * sizeof(int));
bzero((char *) shadowconArr, CARRSIZE * sizeof(long int));
bzero((char *) sumconArr, CARRSIZE * sizeof(long int));
#ifdef TUE_TEL
/* initialisation of dit_config 1st time */
if(glob->dit_config) {
init_dit_config();
}
#endif
/* initialisation of ip_refuse 1st time */
if(glob->ip_refuse) {
get_ip_refuse_clients(glob);
}
/* the server runs in an infinite loop !!! */
for ( ;; ) {
/* listen on the server-port for incoming connections */
FD_ZERO( &readfds );
FD_SET( s, &readfds );
if ((rc=select(tblsize,(fd_set *)&readfds,NULL,NULL,0))==-1) {
if ( debug ) perror( "select" );
continue;
} else if ( rc == 0 ) {
continue;
}
if ( ! FD_ISSET( s, &readfds ) )
continue;
/* got connection for the server: get data */
fromlen = sizeof(from);
/* increment the counter for total connections */
glob->svc_cnt++;
/* get new file-descriptors for the connection */
if ( (ns = accept( s, (struct sockaddr *) &from, &fromlen )) == -1 ) {
/* new fd could not be assigned -> log & bye */
if ( debug ) perror( "accept" );
if ( dosyslog ) {
syslog (LOG_INFO,
"problem with accept, errno=%d, %s <%08d>",
errno, strerror(errno), glob->svc_cnt);
}
continue;
}
/* get time for performance log */
gettimeofday(&timestore[0], NULL);
/* get client-address via DNS */
hp = gethostbyaddr( (char *) &(from.sin_addr.s_addr),
sizeof(from.sin_addr.s_addr), AF_INET );
/* check ip-address for ip_refuse and bye if matched */
if ( check_ip_denial( &from, glob ) == NOTOK ) {
if ( dosyslog )
syslog( LOG_INFO, "IP-REFUSE: access denied for %s <%08d>",
inet_ntoa( from.sin_addr ), glob->svc_cnt);
close (ns);
continue;
}
/* get time for performance log */
gettimeofday(&timestore[1], NULL);
/* Anti-Hack-part */
/* divide Host-IP-addresses in index-groups and count connection */
idx = IP_HACK(from.sin_addr.s_addr);
sumconArr[idx]++;
/* count try if already locked and bye */
if(conArr[idx] < 0) {
shadowconArr[idx]++;
close (ns);
continue;
}
/* if not yet locked and maximum amount of connections is exeeded ->
lock & message & bye
*/
if (glob->comrefuse && (++conArr[idx] > glob->comrefuse->maxAccept)){
if (dosyslog)
syslog(LOG_INFO,
"connection refused for %s (IDX=%d): %d attempts, %d cycles suspended <%08d>",
hp ? hp->h_name : "unknown", idx, conArr[idx],
glob->comrefuse->suspendCycle, glob->svc_cnt);
/* lock for x timecycles */
conArr[idx] = glob->comrefuse->suspendCycle;
/* bye, bye baby */
close (ns);
continue;
}
/* END of Anti-Hack-part */
/* Log the connection */
if ( dosyslog ) {
char msg[BUFSIZ];
sprintf(msg, "TCP connection from %s (%s,%u)",
(hp == NULL) ? "unknown" : hp->h_name,
inet_ntoa( from.sin_addr ), from.sin_port );
glob->server_connection_msg = strdup(msg);
}
if ( debug ) {
fprintf( stderr, "connection from %s (%s)\n",
(hp == NULL) ? "unknown" : hp->h_name,
inet_ntoa( from.sin_addr ) );
}
glob->unknown_host = !hp;
/* OK, now fork a sub-process performing the further communication
to the client; the father-process is listening for further
connections */
switch( pid = fork() ) {
case 0: /* child */
/* the connection to the client should last at most OUT_TIME
thereafter terminate connection */
signal(SIGALRM, timeoutf);
alarm(OUT_TIME);
/* the s-filedescriptor is not needed any more */
close( s );
/* Serve client-request */
do_queries( ns, glob , inet_ntoa( from.sin_addr ), from.sin_port, hp);
break;
case -1: /* failed */
if (dosyslog)
syslog (LOG_INFO, "%s <%08d>",
glob->server_connection_msg, glob->svc_cnt);
perror( "fork" );
break;
default: /* parent */
/* the father-process continues listening */
close( ns );
if ( debug )
fprintf( stderr, "forked child %d\n", pid );
break;
}
}
/* NOT REACHED */
}
/* end of function: start_server */
/**
** set_socket()
**
** Initialise socket to listen on and assign dedicated FD
**/
PRIVATE int set_socket(port)
int port;
{
int s, one;
struct sockaddr_in addr;
if ( (s = socket( AF_INET, SOCK_STREAM, 0 )) == -1 ) {
perror( "socket" );
exit( 1 );
}
/* set option so clients can't keep us from coming back up */
one = 1;
if ( setsockopt( s, SOL_SOCKET, SO_REUSEADDR, (char *) &one,
sizeof(one) ) < 0 ) {
perror( "setsockopt" );
exit( 1 );
}
/* bind to a name */
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = INADDR_ANY;
addr.sin_port = htons( port );
if ( bind( s, (struct sockaddr *) &addr, sizeof(addr) ) ) {
perror( "bind" );
exit( 1 );
}
/* listen for connections */
if ( listen( s, 512 ) == -1 ) {
perror( "listen" );
exit( 1 );
}
if ( debug )
printf( "web500gw listening on port %d\n", port );
return( s );
}
/* end of function: set_socket */
/* If a sub-daemon exists, remove from Process list */
PRIVATE void wait4child(arg)
int arg;
{
int status;
if ( debug ) printf( "parent: catching child status\n" );
while ( wait3( &status, WNOHANG | WUNTRACED, 0 ) > 0 )
; /* NULL */
(void) signal( SIGCHLD, wait4child );
}
/* end of function: wait4child */
/* set signal-handler for Anti-Hack */
PRIVATE void hackTimer()
{
static time_t timer = (time_t) 0;
time_t now = time (&now);
/* re-read IP-REFUSE file if necessary */
re_readIPrefuse( globP );
/* re-read INDEX-URL file if necessary */
re_read_index_url_rules( globP );
if (!timer) {
timer = now + comRefuseP->statCycle;
}
signal(SIGALRM, reset_conMem);
alarm((rand() % comRefuseP->tdiff) + comRefuseP->tmin);
if (now + comRefuseP->tmin > timer) {
timer = put_hackStats (NULL, now) + comRefuseP->statCycle;
*stat_slice = now;
}
}
/* end of function: hackTimer */
/* Signal-handler for Anti-Hack-code */
PRIVATE void reset_conMem()
{
int i;
hackTimer();
for(i=0; i< 8192; i++)
if(conArr[i] >= 0) conArr[i] = 0;
else {
if(++conArr[i] == 0){
if (dosyslog)
syslog(LOG_INFO, "connection accept resumed for IDX=%d; \
%u connection attempts during suspension <%08d>", i, shadowconArr[i],
globP->svc_cnt);
shadowconArr[i] = 0;
}
}
}
/* end of function: reset_conMem */
/* regular output of the access-statistic */
PUBLIC time_t put_hackStats (fp, now)
FILE *fp;
time_t now;
{
int i, bereiche;
int is_html = (fp != NULL);
char *eol = is_html ? "<BR>\n" : "\n";
unsigned long int gesamt = 0;
if (!now) now = time (&now);
if (!fp) fp = fopen (comRefuseP->statFile, "w");
if (fp) {
if (is_html) fprintf (fp, "<PRE><BR>\n");
fprintf (fp, "Access-Statistic TWEB%s", eol);
fprintf (fp, "======================%s", eol);
if (comRefuseP) fprintf (fp, "FILE : %s%s", comRefuseP->statFile, eol);
fprintf (fp, "START: %s%s", format_time (*stat_slice), eol);
fprintf (fp, "END : %s%s%s%s", format_time (now), eol, eol, eol);
for (i = 0, bereiche = 0; i < CARRSIZE; i++) {
if(sumconArr[i]) {
fprintf (fp, "IP-IDX %5d: %8lu%s", i, sumconArr[i], eol);
gesamt += sumconArr[i];
bereiche++;
}
}
if(bereiche > 1) {
fprintf (fp, "----------------------%s", eol);
fprintf (fp, "Total: %8lu ( from %d IP-Ranges )%s",
gesamt, bereiche, eol);
}
if (is_html) {
fprintf (fp, "</PRE><BR>\n");
} else {
bzero((char *) sumconArr, CARRSIZE * sizeof(long int));
fprintf (fp, "\n");
fclose (fp);
}
}
return (now);
} /* put_hackStats */

72
contrib/tweb/server.h Normal file
View File

@ -0,0 +1,72 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* server.h... *
* *
* Funktion:..WorldWideWeb-X.500-Gateway - Server-Funktions *
* Based on web500gw.c 1.3 written by Frank Richter, TU Chemmniz *
* which is based on go500gw by Tim Howes, University of *
* Michigan - All rights reserved *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* August 16 1995 Z D D V V *
* Last modification: Z D D V V *
* December 31 1998 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: server.h,v 1.6 1999/09/10 15:01:19 zrnsk01 Exp $
*
*/
#ifndef _SERVER_
#define _SERVER_
#include "server_exp.h"
#include "queries_exp.h"
#include "support_exp.h"
#ifdef TUE_TEL
#include "tueTel_exp.h"
#endif
#define CARRSIZE 8192
#define MASK_30 0x40000000
#define MASK_20 0x00100000
#define MASK_17 0x00020000
#define MASK_10 0x00000ffc
#define IP_HACK(x) ((((MASK_30 & (x)) != 0) * 4096) + \
(((MASK_20 & (x)) != 0) * 2048) + \
(((MASK_17 & (x)) != 0) * 1024) + \
((MASK_10 & (x)) >> 2))
/* three integer-arrays to count connections */
int conArr[CARRSIZE];
unsigned long int shadowconArr[CARRSIZE];
unsigned long int sumconArr[CARRSIZE];
/* the signal-handler */
PRIVATE void reset_conMem();
/* set the Alarm-Timer */
PRIVATE void hackTimer();
PRIVATE int set_socket();
PRIVATE void wait4child();
/* A pointer to the Anti-Hack-infos in the Glob-structure */
COMREFUSE *comRefuseP = NULL;
time_t *stat_slice;
#endif /* _SERVER_ */

36
contrib/tweb/server_exp.h Normal file
View File

@ -0,0 +1,36 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* server_exp.h... *
* *
* Function:..WorldWideWeb-X.500-Gateway - Server-Funktions *
* Based on web500gw.c 1.3 written by Frank Richter, TU Chemmniz *
* which is based on go500gw by Tim Howes, University of *
* Michigan - All rights reserved *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* February 2 1996 Z D D V V *
* Last modification: Z D D V V *
* December 31 1996 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: server_exp.h,v 1.6 1999/09/10 15:01:19 zrnsk01 Exp $
*
*/
#ifndef _SERVER_EXP_
#define _SERVER_EXP_
/* Statistic Output */
extern time_t put_hackStats();
extern void start_server();
#endif /* _SERVER_EXP_ */

177
contrib/tweb/strng.c Normal file
View File

@ -0,0 +1,177 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* strng.c.... *
* *
* Function:..String Handling Functions *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* February 13 1996 Z D D V V *
* Last modification: Z D D V V *
* November 3 1998 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: strng.c,v 1.6 1999/09/10 15:01:19 zrnsk01 Exp $
*
*/
#include "strng_exp.h"
#include "tgeneral.h"
/*
* Convert string to integer by means of a dispatcherlist
* if string is not in the dispatcher -> return default
*/
PUBLIC int cnvt_str2int (stringVal, dispatcher, defaultVal)
STRDISP_P dispatcher;
int defaultVal;
char *stringVal;
{
int retVal = defaultVal;
STRDISP_P disp;
for (disp = dispatcher; disp->stringVal; disp++) {
if (!strncmp (stringVal, disp->stringVal, disp->abbr)) {
retVal = disp->intVal;
break;
}
}
return (retVal);
} /* cnvt_str2int */
/*
* Truncate characters at the beginning of a string
*/
PUBLIC char * trimleft (s, what)
char *s, *what;
{
return (s + strspn (s, what));
} /* trimleft */
/*
* Truncate characters at the end of a string
*/
PUBLIC char * trimright (s, what)
char *s, *what;
{
char *tmp = s + strlen (s) - 1;
while ((tmp >= s) && strchr (what, *tmp)) *tmp-- = '\0';
return (s);
} /* trimright */
/*
* Truncate characters at the beginning and end of a string
*/
PUBLIC char * trim (s, what)
char *s, *what;
{
(void) trimright (s, what);
return (trimleft (s, what));
} /* trim */
/*
* Convert a string to lower-case "in place"
* uses tolower()
*/
PUBLIC char *str_tolower (source)
char *source;
{
char *target = source;
for (; *target; target++) *target = tolower (*target);
return (source);
} /* str_tolower */
/*
* Convert a string to upper-case "in place"
* uses toupper()
*/
PUBLIC char *str_toupper (source)
char *source;
{
char *target = source;
for (; *target; target++){
*target = toupper (*target);
/* Patch fuer Umlaute */
if(*target == 'ä') *target = 'Ä';
else if(*target == 'ö') *target = 'Ö';
else if(*target == 'ü') *target = 'Ü';
}
return (source);
} /* str_toupper */
/*
* Substitute a character in a string by another
*/
PUBLIC char *tr1 (source, from, to)
char *source;
char from, to;
{
char *target = source - 1;
while ( ( target = strchr( ++target, from )) ) *target = to;
return (source);
} /* tr1 */
PUBLIC int chrcnt(string, c)
char *string;
char *c;
{
int count=0;
string--;
while( ( string = strpbrk(string+1, c)) )
count++;
return(count);
}
/* end of function: chrcnt */
PUBLIC int
qSortByString( a, b )
char **a, **b;
{
return strcmp( *a, *b );
}
/* end of function: qSortByString */

80
contrib/tweb/strng_exp.h Normal file
View File

@ -0,0 +1,80 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* strng_exp.h *
* *
* Function:..String Handling Functions *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* February 13 1996 Z D D V V *
* Last modification: Z D D V V *
* November 3 1998 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: strng_exp.h,v 1.6 1999/09/10 15:01:19 zrnsk01 Exp $
*
*/
#ifndef __STRNG_EXP__
#define __STRNG_EXP__
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
/*
* Structures for the offered Funktions
*/
typedef struct _str2intDispatch {
char *stringVal;
int abbr,
intVal;
} STRDISP, *STRDISP_P;
/*
* The "offered" Funktions
*/
/* Conversion to upper/lower case in the whole string */
char *str_tolower (/* char *string */);
char *str_toupper (/* char *string */);
/* Convert string to integer by means of a dispatcherlist */
/* if string is not in the dispatcher -> return default */
int cnvt_str2int (/* string, dispatcher, default */);
/* Truncate characters at the beginning and end of a string */
char *trimleft (/* char *s, char *what */);
char *trimright (/* char *s, char *what */);
char *trim (/* char *s, char *what */);
/* A special WHAT: whitespaces */
#define WSPACE "\n\r\t "
/* Substitute a character in a string to another */
char *tr1 (/* char *source, char from, char to */);
/* Count the named characters of string2 in string1 */
int chrcnt (/*String1, String2*/);
/* Compare by string values in qsort() */
int qSortByString (/* char **StringP1, char **StringP2 */);
#endif

613
contrib/tweb/support.c Normal file
View File

@ -0,0 +1,613 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* support.c.. *
* *
* Function:..WorldWideWeb-X.500-Gateway - Supporting Routines *
* Based on web500gw.c 1.3 written by Frank Richter, TU Chemmniz *
* which is based on go500gw by Tim Howes, University of *
* Michigan - All rights reserved *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* August 16 1995 Z D D V V *
* Last modification: Z D D V V *
* September 7 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: support.c,v 1.6 1999/09/10 15:01:20 zrnsk01 Exp $
*
*/
#include "tgeneral.h"
#include "tglobal.h"
#include "init_exp.h"
#include "support.h"
/*
* Utilities for dealing with HTML junk
*/
char hex[17] = "0123456789abcdef";
char buffer[1024];
PUBLIC char * hex_decode (in)
char *in;
{
char b, c;
int q = 0;
char *out = in;
while (*in) {
if (*in == '?') /* start search */
q = 1;
if (*in == '%') { /* Hex escape */
in++;
if(!(c = *in++)) break;
b = from_hex(c);
if(!(c = *in++)) break;
*out++ = (b<<4) + from_hex(c);
} else if (q && *in == '+') {
/* '+' is legal in path, in search it's a ' ' */
*out++ = ' ';
in++;
} else {
*out++ = *in++;
}
}
*out = '\0';
return (out);
}
/* end of function: hex_decode */
/* decode in search (for do_modify) */
PUBLIC char * hex_qdecode (in)
char *in;
{
char b, c;
char *out = in;
while (*in) {
if (*in == '%') { /* Hex escape */
in++;
if(!(c = *in++)) break;
b = from_hex(c);
if(!(c = *in++)) break;
*out++ = (b<<4) + from_hex(c);
} else if (*in == '+') { /* we are in search, so: '+' -> ' ' */
*out++ = ' ';
in++;
} else {
*out++ = *in++;
}
}
*out = '\0';
return (out);
}
/* end of function: hex_qdecode */
PUBLIC char * form_encode (in)
char *in;
{
char *out = buffer;
/* bzero(out, 1024); */
while (*in) {
if (*in == '"' || *in == '>' ) {
*out++ = '\\';
}
*out++ = *in++;
}
*out = '\0';
/* fprintf( stderr, "returning - esc: %s.\n", buffer); */
return (buffer);
}
/* end of function: form_encode */
/* gtime(): the inverse of localtime().
This routine was supplied by Mike Accetta at CMU many years ago.
*/
int dmsize[] = {
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
#define dysize(y) \
(((y) % 4) ? 365 : (((y) % 100) ? 366 : (((y) % 400) ? 365 : 366)))
#define YEAR(y) ((y) >= 100 ? (y) : (y) + 1900)
PRIVATE time_t gtime (tm)
struct tm *tm;
{
register int i,
sec,
mins,
hour,
mday,
mon,
year;
register long result;
if ((sec = tm -> tm_sec) < 0 || sec > 59
|| (mins = tm -> tm_min) < 0 || mins > 59
|| (hour = tm -> tm_hour) < 0 || hour > 24
|| (mday = tm -> tm_mday) < 1 || mday > 31
|| (mon = tm -> tm_mon + 1) < 1 || mon > 12)
return ((long) -1);
if (hour == 24) {
hour = 0;
mday++;
}
year = YEAR (tm -> tm_year);
result = 0L;
for (i = 1970; i < year; i++)
result += dysize (i);
if (dysize (year) == 366 && mon >= 3)
result++;
while (--mon)
result += dmsize[mon - 1];
result += mday - 1;
result = 24 * result + hour;
result = 60 * result + mins;
result = 60 * result + sec;
return result;
}
/* end of function: gtime */
PUBLIC char * format_date (s, format)
char **s;
char *format;
{
/* PATCHED by /KSp, 94/04/29 */
static char date[256];
/* ^^^^^^ */
/* END PATCH */
struct tm tm, *ntm;
time_t t;
tm.tm_year = 10*((*s)[0] - '0') + ((*s)[1] - '0');
tm.tm_mon = 10*((*s)[2] - '0') + ((*s)[3] - '0') - 1;
tm.tm_mday = 10*((*s)[4] - '0') + ((*s)[5] - '0');
tm.tm_hour = 10*((*s)[6] - '0') + ((*s)[7] - '0');
tm.tm_min = 10*((*s)[8] - '0') + ((*s)[9] - '0');
tm.tm_sec = 10*((*s)[10] - '0') + ((*s)[11] - '0');
/* PATCHED for HPUX by /KSp, 94/04/28 */
tm.tm_isdst = 0;
#if !defined(__hpux) && !defined(__linux__) && !defined(__sun)
tm.tm_gmtoff = 0;
#endif
/* END PATCH */
t = gtime(&tm);
ntm = gmtime(&t);
strftime(date, 256, format, ntm);
return (date);
}
/* end of function: format_date */
PUBLIC char * friendly_dn (dn, glob)
char *dn;
GLOB_STRUCT *glob;
{
/* PATCHED BY /KSp, 94/04/29 */
/* static char fufn[1024], **s; */
/* ^^^^^^ */
/* END PATCH */
/* Again patched by /KSp, 97/01/25: dynamic mem-allocation */
char *fufn;
if ( ( fufn = calloc( 1, BUFSIZ )) ) {
if (strlen(dn) == 0) {
strcpy( fufn, glob->la[77] );
} else {
int i = 0;
char **s;
s = ldap_explode_dn( dn, 1 );
while (s[i+1]) {
strcat( fufn, s[i++] );
strcat( fufn, ", " );
}
strcat( fufn, ldap_friendly_name( glob->friendlyfile, s[i], &fm ));
}
}
return (fufn);
}
/* end of function: friendly_dn */
PUBLIC char * format_time (whatTime)
time_t whatTime;
{
time_t timer;
static char theTime[_TIMEOUT_LEN+1];
timer = whatTime ? whatTime : time (&timer);
strftime (theTime, (_TIMEOUT_LEN + 1), _LOG_TIME, localtime (&timer));
return (theTime);
} /* end of function: format_time */
PUBLIC char * strQuoteChr(string, c)
char *string;
char c;
{
char *cPtr;
int inQuote = FALSE;
cPtr = string;
while(*cPtr) {
if( *cPtr == '\"')
inQuote = ( (inQuote == TRUE) ? FALSE : TRUE );
if( (*cPtr == c) && (inQuote == FALSE) )
return(cPtr);
cPtr++;
}
return(NULL);
}
/* end of function: strQuoteChr */
PUBLIC char * strrQuoteChr(string, c)
char *string;
char c;
{
char *cPtr;
int inQuote = FALSE;
cPtr = string + strlen(string) - 1;
while(cPtr >= string) {
if( *cPtr == '\"')
inQuote = ( (inQuote == TRUE) ? FALSE : TRUE );
if( (*cPtr == c) && (inQuote == FALSE) )
return(cPtr);
cPtr--;
}
return(NULL);
}
/* end of function: strrQuoteChr */
PUBLIC void disp_file(glob, filename, fp)
GLOB_STRUCT *glob;
char *filename;
FILE *fp;
{
char buf[4096];
FILE *fp2;
if(filename && (fp2 = fopen(filename, "r" ))) {
while ( fgets(buf, 4095, fp2) != NULL )
fprintf( fp, "%s",buf);
fclose(fp2);
}
/* Copyright-Zeile */
if(filename == glob->footer ||
(glob->basedn && filename == glob->basedn->foot))
fprintf( fp, glob->la[99],glob->la[101], copyright );
}
/* end of function: disp_file */
PUBLIC int dn_cmp(dn1, dn2)
char *dn1, *dn2;
{
do {
while(*dn1 == ' ' || *dn1 == '"')
dn1++;
while(*dn2 == ' ' || *dn2 == '"')
dn2++;
if(!*dn1 && !*dn2)
return(FALSE); /* equality */
} while(tolower(*dn1++) == tolower(*dn2++));
return(TRUE);
}
/* end of function: dn_cmp */
/*
* dn_cmp_parts()
*
* comparison of dns by rdn parts. in case of unmatched the part(s) which
* matched can be returned (matched not NULL)
*
* input:
*
* - dn1 (in url format)
* - dn2 ( " )
* - matched (pointer to dynamically allocatable string, or NULL)
*
* output:
*
* - DN_EQUAL | DN_LESS | DN_GREATER | DN_UNMATCHED (with matched allocated)
*/
PUBLIC int
dn_cmp_parts( dn1, dn2, matched )
char *dn1;
char *dn2;
char **matched;
{
char **dn1arr = dn2charray( dn1 );
char **dn2arr = dn2charray( dn2 );
int idx;
int domatch = TRUE;
int result = DN_EQUAL;
for ( idx = 0; dn1arr[idx] && dn2arr[idx]; idx++ ) {
if ( strcasecmp( dn1arr[idx], dn2arr[idx] )) {
domatch = FALSE;
break;
}
}
/* what was the result */
if ( !domatch ) {
if ( matched ) {
char buf[BUFSIZ];
char buf2[BUFSIZ];
int idx2;
*buf = '\0';
for ( idx2 = 0; idx2 < idx; idx2++ ) {
strcpy( buf2, buf );
sprintf( buf, "%s,%s", dn1arr[idx2], buf2 );
}
trimright( buf, "," );
*matched = strdup( buf );
}
result = DN_UNMATCHED;
} else if ( dn1arr[idx] ) result = DN_GREATER;
else if ( dn2arr[idx] ) result = DN_LESS;
charray_free( dn1arr ); charray_free( dn2arr );
return( result );
} /* dn_cmp_parts */
/*
* Comparison of substring lists
*/
PUBLIC int strlstcmp (s1, s2, sep)
char *s1, *s2;
char sep;
{
int retCode = FALSE;
char *target;
char *source;
char *idx, *idx2;
char tmpChar;
if ( !s1 || !s2 )
return( FALSE );
target = str_tolower (strdup (s1));
source = str_tolower (strdup (s2));
idx = source;
while (idx && (idx2 = strchr (idx+1, sep))) {
tmpChar = *(++idx2); *idx2 = '\0';
if (strstr (target, idx)) {
retCode = TRUE;
break;
}
*(idx2) = tmpChar;
idx = --idx2;
}
free (source);
free (target);
return (retCode);
}
/* end of function: strlstcmp */
PUBLIC char *hex_html_encode(string, flag)
char *string;
int flag; /* 0->hex 1->html */
{
static char strbuf[10*BUFSIZ];
char *strptr;
*strbuf = '\0';
for(strptr = string; *strptr; strptr++){
/* 200 a -> &auml; fuer aouAOU */
if((flag==1) && (((int)*strptr&255)==200)) {
if(strchr("aouAOU", *(strptr+1))) {
sprintf(strbuf, "%s&%cuml;", strbuf, *++strptr);
continue;
}
}
/* &#xxx; Handling-Patch */
if((flag==1) && (((int)*strptr&255)>=160)) {
sprintf(strbuf, "%s&#%d;", strbuf, ((int)*strptr&255));
continue;
}
/* end Patch */
if(!encoding_tbl[(int)*strptr&255][flag]) {
sprintf(strbuf, "%s%c", strbuf, *strptr);
} else {
strcat(strbuf, encoding_tbl[(int)*strptr&255][flag]);
}
}
return(strbuf);
}
/* end of function: hex_html_encode */
/* Strips basecount+1 characters of type target at the end of an RDN */
PUBLIC char *dnrcut(rdn, target, basecount)
char *rdn;
char *target;
int basecount;
{
static char buf[BUFSIZ];
char *strptr;
int rdncount, morecount;
rdncount = chrcnt(rdn, target);
if( (morecount = (rdncount - basecount)) > 0) {
strcpy(buf, rdn);
strptr = buf-1;
while(morecount--) {
strptr = strpbrk(strptr+1, target);
}
*strptr = '\0';
} else *buf = '\0';
return(buf);
}
/* end of function: dnrcut */
PUBLIC char **dn2charray(dn)
char *dn;
{
char *dnbuf, *strptr, **a=NULL;
if ( !dn || !*dn ) {
a = (char **) ch_calloc( 1, sizeof( char ** ));
return( a );
}
dnbuf = strdup(dn);
do {
strptr = strrQuoteChr(dnbuf, ',');
if(strptr) {
*strptr++ = '\0';
/*
while(*strptr == ' ')
strptr++;
*/
strptr = trim( strptr, " " );
}
charray_add( &a, strptr ? strptr : trim( dnbuf, " " ));
} while(strptr);
free(dnbuf);
return(a);
}
/* end of function: dn2charray */
/* get the parent DN for a given one */
PUBLIC char *
get_parentDN( dn )
char *dn;
{
char **a = NULL;
char tmp[BUFSIZ];
a = dn2charray( dn );
*tmp = *(tmp + 1) = '\0';
if ( a ) {
char **rdnH;
/* we have to re-build the DN beginning at the last array element */
for ( rdnH = a; *rdnH; rdnH++ )
;
/* re-build DN from it's parts */
rdnH--; rdnH--;
for ( ; rdnH >= a; rdnH-- ) {
sprintf( tmp, "%s,%s", tmp, *rdnH );
}
charray_free( a );
}
/* ignore a leading ',' */
return( strdup( tmp + 1 ));
} /* get_parentDN */
PUBLIC char *elapsed(firsttime, secondtime)
struct timeval firsttime;
struct timeval secondtime;
{
long int elapsedmicrosec, elapsedsec;
char elapsed_string[BUFSIZ];
elapsedsec = secondtime.tv_sec - firsttime.tv_sec;
elapsedmicrosec = secondtime.tv_usec - firsttime.tv_usec;
if(elapsedmicrosec < 0) {
elapsedmicrosec += 1000000;
elapsedsec -= 1;
}
if(elapsedsec > 1000){
elapsedsec = 0;
elapsedmicrosec = 0;
}
sprintf(elapsed_string, "%ld.%.6ld", elapsedsec, elapsedmicrosec);
return(strdup(elapsed_string));
}
/* end of function: elapsed */
/* performance-log on exit */
PUBLIC int exit_tweb(rc)
int rc;
{
struct timeval secondtime;
gettimeofday(&secondtime, NULL);
if(!secondtime.tv_sec || !timestore[0].tv_sec) exit(rc);
if (dosyslog)
syslog (LOG_INFO, "performance: %s#%s#%s#%s#%s#%s#%d seconds <%08d>",
elapsed(timestore[0], secondtime), elapsed(timestore[0],
timestore[1]), elapsed(timestore[1], timestore[2]),
elapsed(timestore[2], timestore[3]),
elapsed(timestore[3], items_displayed ? timestore[4] : secondtime),
items_displayed ? elapsed(timestore[4], secondtime) : "",
items_displayed, globP->svc_cnt);
exit(rc);
}
/* end of function: exit_tweb */

300
contrib/tweb/support.h Normal file
View File

@ -0,0 +1,300 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* support.h.. *
* *
* Function:..WorldWideWeb-X.500-Gateway - Support-Functions *
* Based on web500gw.c 1.3 written by Frank Richter, TU Chemmniz *
* which is based on go500gw by Tim Howes, University of *
* Michigan - All rights reserved *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* August 16 1995 Z D D V V *
* Last modification: Z D D V V *
* September 7 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: support.h,v 1.6 1999/09/10 15:01:20 zrnsk01 Exp $
*
*/
#ifndef _SUPPORT_
#define _SUPPORT_
#include "support_exp.h"
#include "charray_exp.h"
#include "ch_malloc_exp.h"
/* Array for translation */
/* 0: HEX; 1: uml (not used); 2: flatten */
char *encoding_tbl[257][3] = {
/* 0 \0 */ { "%00" , "", NULL },
/* 1  */ { "%01" , "", NULL },
/* 2  */ { "%02" , "", NULL },
/* 3  */ { "%03" , "", NULL },
/* 4  */ { "%04" , "", NULL },
/* 5  */ { "%05" , "", NULL },
/* 6  */ { "%06" , "", NULL },
/* 7  */ { "%07" , "", NULL },
/* 8  */ { "%08" , "", NULL },
/* 9 \t */ { "%09" , "&nbsp;", NULL },
/* 10 \n */ { "%0a" , "\n", NULL },
/* 11 */ { "%0b" , " ", NULL },
/* 12 */ { "%0c" , " ", NULL },
/* 13 */ { "%0d" , " ", NULL },
/* 14  */ { "%0e" , "", NULL },
/* 15  */ { "%0f" , "", NULL },
/* 16  */ { "%10" , "", NULL },
/* 17  */ { "%11" , "", NULL },
/* 18  */ { "%12" , "", NULL },
/* 19  */ { "%13" , "", NULL },
/* 20  */ { "%14" , "", NULL },
/* 21  */ { "%15" , "", NULL },
/* 22  */ { "%16" , "", NULL },
/* 23  */ { "%17" , "", NULL },
/* 24  */ { "%18" , "", NULL },
/* 25  */ { "%19" , "", NULL },
/* 26  */ { "%1a" , "", NULL },
/* 27  */ { "%1b" , "", NULL },
/* 28  */ { "%1c" , "", NULL },
/* 29  */ { "%1d" , "", NULL },
/* 30  */ { "%1e" , "", NULL },
/* 31  */ { "%1f" , "", NULL },
/* 32 */ { "%20" , " ", NULL },
/* 33 ! */ { "%21" , "!", NULL },
/* 34 " */ { "%22" , "&quot;", NULL },
/* 35 # */ { "%23" , "#", NULL },
/* 36 $ */ { NULL, NULL, NULL },
/* 37 % */ { "%25" , "%", NULL },
/* 38 & */ { "%26" , "&amp;", NULL },
/* 39 ' */ { "%27" , "'", NULL },
/* 40 ( */ { "%28" , "(", NULL },
/* 41 ) */ { "%29" , ")", NULL },
/* 42 * */ { "%2a" , "*", NULL },
/* 43 + */ { "%2b" , "+", NULL },
/* 44 , */ { "%2c" , ",", NULL },
/* 45 - */ { NULL, NULL, NULL },
/* 46 . */ { NULL, NULL, NULL },
/* 47 / */ { "%2f" , "/", NULL },
/* 48 0 */ { NULL, NULL, NULL },
/* 49 1 */ { NULL, NULL, NULL },
/* 50 2 */ { NULL, NULL, NULL },
/* 51 3 */ { NULL, NULL, NULL },
/* 52 4 */ { NULL, NULL, NULL },
/* 53 5 */ { NULL, NULL, NULL },
/* 54 6 */ { NULL, NULL, NULL },
/* 55 7 */ { NULL, NULL, NULL },
/* 56 8 */ { NULL, NULL, NULL },
/* 57 9 */ { NULL, NULL, NULL },
/* 58 : */ { "%3a" , ":", NULL },
/* 59 ; */ { "%3b" , ";", NULL },
/* 60 < */ { "%3c" , "&lt;", NULL },
/* 61 = */ { "%3d" , "=", NULL },
/* 62 > */ { "%3e" , "&gt;", NULL },
/* 63 ? */ { "%3f" , "?", NULL },
/* 64 @ */ { "%40" , "@", NULL },
/* 65 A */ { NULL, NULL, NULL },
/* 66 B */ { NULL, NULL, NULL },
/* 67 C */ { NULL, NULL, NULL },
/* 68 D */ { NULL, NULL, NULL },
/* 69 E */ { NULL, NULL, NULL },
/* 70 F */ { NULL, NULL, NULL },
/* 71 G */ { NULL, NULL, NULL },
/* 72 H */ { NULL, NULL, NULL },
/* 73 I */ { NULL, NULL, NULL },
/* 74 J */ { NULL, NULL, NULL },
/* 75 K */ { NULL, NULL, NULL },
/* 76 L */ { NULL, NULL, NULL },
/* 77 M */ { NULL, NULL, NULL },
/* 78 N */ { NULL, NULL, NULL },
/* 79 O */ { NULL, NULL, NULL },
/* 80 P */ { NULL, NULL, NULL },
/* 81 Q */ { NULL, NULL, NULL },
/* 82 R */ { NULL, NULL, NULL },
/* 83 S */ { NULL, NULL, NULL },
/* 84 T */ { NULL, NULL, NULL },
/* 85 U */ { NULL, NULL, NULL },
/* 86 V */ { NULL, NULL, NULL },
/* 87 W */ { NULL, NULL, NULL },
/* 88 X */ { NULL, NULL, NULL },
/* 89 Y */ { NULL, NULL, NULL },
/* 90 Z */ { NULL, NULL, NULL },
/* 91 [ */ { "%5b" , "[", NULL },
/* 92 \ */ { "%5c" , "\\", NULL },
/* 93 ] */ { "%5d" , "]", NULL },
/* 94 ^ */ { "%5e" , "^", NULL },
/* 95 _ */ { NULL, NULL, NULL },
/* 96 ` */ { "%60" , "`", NULL },
/* 97 a */ { NULL, NULL, NULL },
/* 98 b */ { NULL, NULL, NULL },
/* 99 c */ { NULL, NULL, NULL },
/* 100 d */ { NULL, NULL, NULL },
/* 101 e */ { NULL, NULL, NULL },
/* 102 f */ { NULL, NULL, NULL },
/* 103 g */ { NULL, NULL, NULL },
/* 104 h */ { NULL, NULL, NULL },
/* 105 i */ { NULL, NULL, NULL },
/* 106 j */ { NULL, NULL, NULL },
/* 107 k */ { NULL, NULL, NULL },
/* 108 l */ { NULL, NULL, NULL },
/* 109 m */ { NULL, NULL, NULL },
/* 110 n */ { NULL, NULL, NULL },
/* 111 o */ { NULL, NULL, NULL },
/* 112 p */ { NULL, NULL, NULL },
/* 113 q */ { NULL, NULL, NULL },
/* 114 r */ { NULL, NULL, NULL },
/* 115 s */ { NULL, NULL, NULL },
/* 116 t */ { NULL, NULL, NULL },
/* 117 u */ { NULL, NULL, NULL },
/* 118 v */ { NULL, NULL, NULL },
/* 119 w */ { NULL, NULL, NULL },
/* 120 x */ { NULL, NULL, NULL },
/* 121 y */ { NULL, NULL, NULL },
/* 122 z */ { NULL, NULL, NULL },
/* 123 { */ { "%7b" , "{", NULL },
/* 124 | */ { "%7c" , "|", NULL },
/* 125 } */ { "%7d" , "}", NULL },
/* 126 ~ */ { "%7e" , "~", NULL },
/* 127  */ { "%7f" , "", NULL },
/* 128 € */ { "%80" , "", NULL },
/* 129 <20> */ { "%81" , "<EFBFBD>", NULL },
/* 130 */ { "%82" , "", NULL },
/* 131 ƒ */ { "%83" , "ƒ", NULL },
/* 132 „ */ { "%84" , "", NULL },
/* 133 … */ { "%85" , "", NULL },
/* 134 † */ { "%86" , "", NULL },
/* 135 ‡ */ { "%87" , "", NULL },
/* 136 ˆ */ { "%88" , "ˆ", NULL },
/* 137 ‰ */ { "%89" , "", NULL },
/* 138 Š */ { "%8a" , "Š", NULL },
/* 139 */ { "%8b" , "", NULL },
/* 140 Œ */ { "%8c" , "Œ", NULL },
/* 141 <20> */ { "%8d" , "<EFBFBD>", NULL },
/* 142 Ž */ { "%8e" , "Ž", NULL },
/* 143 <20> */ { "%8f" , "<EFBFBD>", NULL },
/* 144 <20> */ { "%90" , "<EFBFBD>", NULL },
/* 145 */ { "%91" , "", NULL },
/* 146 */ { "%92" , "", NULL },
/* 147 “ */ { "%93" , "", NULL },
/* 148 ” */ { "%94" , "", NULL },
/* 149 • */ { "%95" , "", NULL },
/* 150 */ { "%96" , "", NULL },
/* 151 — */ { "%97" , "", NULL },
/* 152 ˜ */ { "%98" , "˜", NULL },
/* 153 ™ */ { "%99" , "", NULL },
/* 154 š */ { "%9a" , "š", NULL },
/* 155 */ { "%9b" , "", NULL },
/* 156 œ */ { "%9c" , "œ", NULL },
/* 157 <20> */ { "%9d" , "<EFBFBD>", NULL },
/* 158 ž */ { "%9e" , "ž", NULL },
/* 159 Ÿ */ { "%9f" , "Ÿ", NULL },
/* 160 */ { "%a0" , "", NULL },
/* 161 */ { "%a1" , "", NULL },
/* 162 */ { "%a2" , "", NULL },
/* 163 */ { "%a3" , "", NULL },
/* 164 */ { "%a4" , "", NULL },
/* 165 */ { "%a5" , "", NULL },
/* 166 */ { "%a6" , "", NULL },
/* 167 */ { "%a7" , "", NULL },
/* 168 */ { "%a8" , "", NULL },
/* 169 */ { "%a9" , "", NULL },
/* 170 */ { "%aa" , "", NULL },
/* 171 */ { "%ab" , "", NULL },
/* 172 */ { "%ac" , "", NULL },
/* 173 */ { "%ad" , "", NULL },
/* 174 */ { "%ae" , "", NULL },
/* 175 */ { "%af" , "", NULL },
/* 176 */ { "%b0" , "", NULL },
/* 177 */ { "%b1" , "", NULL },
/* 178 */ { "%b2" , "", NULL },
/* 179 */ { "%b3" , "", NULL },
/* 180 */ { "%b4" , "", NULL },
/* 181 */ { "%b5" , "", NULL },
/* 182 */ { "%b6" , "", NULL },
/* 183 */ { "%b7" , "", NULL },
/* 184 */ { "%b8" , "", NULL },
/* 185 */ { "%b9" , "", NULL },
/* 186 */ { "%ba" , "", NULL },
/* 187 */ { "%bb" , "", NULL },
/* 188 */ { "%bc" , "", NULL },
/* 189 */ { "%bd" , "", NULL },
/* 190 */ { "%be" , "", NULL },
/* 191 */ { "%bf" , "", NULL },
/* 192 */ { "%c0" , "&Agrave;", "A" },
/* 193 */ { "%c1" , "&Aacute;", "A" },
/* 194 */ { "%c2" , "&Acirc;", "A" },
/* 195 */ { "%c3" , "&Atilde;", "A" },
/* 196 */ { "%c4" , "&Auml;", "Ae" },
/* 197 */ { "%c5" , "&Aring;", "A" },
/* 198 */ { "%c6" , "&AElig;", "AE" },
/* 199 */ { "%c7" , "&Ccedil;", "C" },
/* 200 */ { "%c8" , "&Egrave;", "E" },
/* 201 */ { "%c9" , "&Eacute;", "E" },
/* 202 */ { "%ca" , "&Ecirc;", "E" },
/* 203 */ { "%cb" , "&Euml;", "E" },
/* 204 */ { "%cc" , "&Igrave;", "I" },
/* 205 */ { "%cd" , "&Iacute;", "I" },
/* 206 */ { "%ce" , "&Icirc;", "I" },
/* 207 */ { "%cf" , "&Iuml;", "I" },
/* 208 */ { "%d0" , "&ETH;", "Eth" },
/* 209 */ { "%d1" , "&Ntilde;", "N" },
/* 210 */ { "%d2" , "&Ograve;", "O" },
/* 211 */ { "%d3" , "&Oacute;", "O" },
/* 212 */ { "%d4" , "&Ocirc;", "O" },
/* 213 */ { "%d5" , "&Otilde;", "O" },
/* 214 */ { "%d6" , "&Ouml;", "Oe" },
/* 215 */ { "%d7" , "x", "x" },
/* 216 */ { "%d8" , "&Oslash;", "O" },
/* 217 */ { "%d9" , "&Ugrave;", "U" },
/* 218 */ { "%da" , "&Uacute;", "U" },
/* 219 */ { "%db" , "&Ucirc;", "U" },
/* 220 */ { "%dc" , "&Uuml;", "Ue" },
/* 221 */ { "%dd" , "&Yacute;", "Y" },
/* 222 */ { "%de" , "&THORN;", NULL },
/* 223 */ { "%df" , "&szlig;", "ss" },
/* 224 */ { "%e0" , "&agrave;", "a" },
/* 225 */ { "%e1" , "&aacute;", "a" },
/* 226 */ { "%e2" , "&acirc;", "a" },
/* 227 */ { "%e3" , "&atilde;", "a" },
/* 228 */ { "%e4" , "&auml;", "ae" },
/* 229 */ { "%e5" , "&aring;", "a" },
/* 230 */ { "%e6" , "&aelig;", "ae" },
/* 231 */ { "%e7" , "&ccedil;", "c" },
/* 232 */ { "%e8" , "&egrave;", "e" },
/* 233 */ { "%e9" , "&eacute;", "e" },
/* 234 */ { "%ea" , "&ecirc;", "e" },
/* 235 */ { "%eb" , "&euml;", "e" },
/* 236 */ { "%ec" , "&igrave;", "i" },
/* 237 */ { "%ed" , "&iacute;", "i" },
/* 238 */ { "%ee" , "&icirc;", "i" },
/* 239 */ { "%ef" , "&iuml;", "i" },
/* 240 */ { "%f0" , "&eth;", "eth" },
/* 241 */ { "%f1" , "&ntilde;", "n" },
/* 242 */ { "%f2" , "&ograve;", "o" },
/* 243 */ { "%f3" , "&oacute;", "o" },
/* 244 */ { "%f4" , "&ocirc;", "o" },
/* 245 */ { "%f5" , "&otilde;", "o" },
/* 246 */ { "%f6" , "&ouml;", "oe" },
/* 247 */ { "%f7" , "/", "/" },
/* 248 */ { "%f8" , "&oslash;", "o" },
/* 249 */ { "%f9" , "&ugrave;", "u" },
/* 250 */ { "%fa" , "&uacute;", "u" },
/* 251 */ { "%fb" , "&ucirc;", "u" },
/* 252 */ { "%fc" , "&uuml;", "ue" },
/* 253 */ { "%fd" , "&yacute;", "y" },
/* 254 */ { "%fe" , "&thorn;", NULL },
/* 255 */ { "%ff" , "&yuml;", "y" },
/* 256 EOF*/ { NULL, NULL, NULL },
};
#endif /* _SUPPORT_ */

View File

@ -0,0 +1,68 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* support_exp.h *
* *
* Function:..WorldWideWeb-X.500-Gateway - Supporting Routines *
* Based on web500gw.c 1.3 written by Frank Richter, TU Chemmniz *
* which is based on go500gw by Tim Howes, University of *
* Michigan - All rights reserved *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* December 2 1995 Z D D V V *
* Last modification: Z D D V V *
* September 7 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: support_exp.h,v 1.6 1999/09/10 15:01:20 zrnsk01 Exp $
*
*/
#ifndef _SUPPORT_EXP_H_
#define _SUPPORT_EXP_H_
PUBLIC char * hex_decode ();
PUBLIC char * hex_qdecode ();
PUBLIC char * form_encode ();
PUBLIC char * format_date ();
PUBLIC char * friendly_dn ();
PUBLIC char * format_time ();
PUBLIC char * strQuoteChr();
PUBLIC int strlstcmp (/* char *s1, char *s2, char sep */);
PUBLIC void re_fail ();
PUBLIC char *dnrcut(/*rdn, target, basecount*/);
PUBLIC void disp_file (/* GLOB_STRUCT glob, char *filename, FILE *fp */);
PUBLIC char *elapsed();
PUBLIC char *hex_html_encode();
#define hex_encode(x) hex_html_encode((x), 0)
#define char2html(x) hex_html_encode((x), 1)
#define flatten_chars(x) hex_html_encode((x), 2)
PUBLIC char * get_parentDN();
PUBLIC char **dn2charray();
PUBLIC char * strrQuoteChr();
PUBLIC int exit_tweb();
/* dn_cmp and return codes */
PUBLIC int dn_cmp( /* dn1, dn2 */ );
PUBLIC int dn_cmp_parts( /* dn1, dn2, &matched */ );
#define DN_EQUAL 0 /* dns are exactly equal */
#define DN_LESS -1 /* dn1 is part of dn2 */
#define DN_GREATER 1 /* dn2 is part of dn1 */
#define DN_UNMATCHED -2 /* dns differ, matched is the same */
/* (matched as seen from c down) */
#endif

246
contrib/tweb/tgeneral.h Normal file
View File

@ -0,0 +1,246 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* tgeneral.h. *
* *
* Function:..General-Headerfile for TWEB *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* August 16 1995 Z D D V V *
* Last modification: Z D D V V *
* May 14 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: tgeneral.h,v 1.6 1999/09/10 15:01:20 zrnsk01 Exp $
*
*/
#ifndef _TGENERAL_
#define _TGENERAL_
#define PUBLIC
#define PRIVATE static
/* For changes see file CHANGES */
#ifdef __hpux
#define _INCLUDE_POSIX_SOURCE
#define _INCLUDE_XOPEN_SOURCE
#define _INCLUDE_HPUX_SOURCE
#define TIOCNOTTY _IO('t', 113)
#define getdtablesize() _NFILE
#endif
#if defined( __linux__ ) && !defined( _BSD_SOURCE )
#define _BSD_SOURCE
#define _SVID_SOURCE
#define _GNU_SOURCE
#define _POSIX_SOURCE
#endif
#include <string.h>
#include <strings.h>
#include <sys/time.h>
#include <time.h>
#include "lber.h"
#include "ldap.h"
#include <stdio.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <syslog.h>
#include <sys/wait.h>
#include <signal.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
extern int errno;
#include "strng_exp.h"
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#define OK 1
#define NOTOK 0
#define DONE -1
#define _TIMEOUT_LEN 31
#define _LOG_TIME "%a, %d.%m.%y, %H:%M:%S"
#include "init_exp.h"
extern GLOB_STRUCT *globP;
/*
***************************************************************************
* If you are not a University of Tuebingen site,
* you probably want to tailor the following:
***************************************************************************
*/
/* Special code for DFN-Project AMBIX-D */
#ifdef AMBIXGW
# define SELBST_CN glob->selbsteintrag[0]
# define SELBST_CN_NAME glob->selbsteintrag[1]
# define SELBST_STUDIE_ATTR glob->selbsteintrag[2]
# define SELBST_INSERT_MODE glob->selbsteintrag[3]
# define SELBST_INSERT_WHO glob->selbsteintrag[4]
# define SELBST_INSERT_NO glob->selbsteintrag[5]
# define SELBST_INSERT_WORK glob->selbsteintrag[6]
# define SELBST_INSERT_ALL glob->selbsteintrag[7]
# define SELBST_INSERT_STUD glob->selbsteintrag[8]
# define MAXDN_LEN 2048
extern void self_insert();
#endif
/* Flags for print_attr */
#define DEFAULT 0
#define MULTILINE 1
#define HREF 2
#define FINGER 3
#define DATE 4
#define URL 5
#define MAILTO 6
#define MOVETO 7
#define BMP 8
#define JPEG 9
#define JPEG2GIF 10
#define BOOLEAN 11
#define URI 12
#define PGPKEY 13
#define INDEXURL 14
#define DYNAMICDN 15
#define REFERRAL 20
#define PRE 21
#define HEADER 22
#ifdef TUE_TEL
#define PHONREFSHORT 16
#define PHONREFLONG 17
#define TFUNCPERS 18
#define FAXTABLE 19
#endif
/* Patch for hpux from ksp: */
#ifdef __hpux
# define rewind(a) fflush(a)
#endif
#define G3TOXBM "cat"
#define JPEGTOGIF "/soft/bin/djpeg -gif"
/*
*************************************************************************
* The rest of this stuff probably does not need to be changed
*************************************************************************
*/
#define TIMEOUT 240
#define WEB500PORT 8889
#ifndef FD_SET
#define NFDBITS 32
#define FD_SETSIZE 32
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
#endif
#define from_hex(c) ((c>='0')&&(c<='9') ? c-'0' : (c>='A')&&(c<='F') ?\
c-'A'+10 : (c>='a')&&(c<='f') ? c-'a'+10 : 0)
/*
* HTTP request we are implementing
*/
#define UNKNOWN 0
#define GET 1
#define HEAD 2
/*
* HTTP response status
*/
#define DOCUMENT_FOLLOWS 200
#define REDIRECT 302
#define BAD_REQUEST 400
#define AUTH_REQUIRED 401
#define FORBIDDEN 403
#define NOT_FOUND 404
#define SERVER_ERROR 500
#define NOT_IMPLEMENTED 501
#define PRINT_HTML_HEADER (fprintf(fp, \
"HTTP/1.0 %d Document follows\n\
MIME-Version: 1.0\n\
Server: %s\n\
Date: %s\n\
Content-Type: text/html\n\
Last-Modified: %s\n\
%s\n",\
DOCUMENT_FOLLOWS, version, glob->nowtimestr, glob->nowtimestr,\
glob->caching ? glob->expiretimestr : "Pragma: no-cache\n" ))
#define PRINT_PLAIN_HEADER (fprintf(fp, \
"HTTP/1.0 %d Document follows\n\
MIME-Version: 1.0\n\
Server: %s\n\
Date: %s\n\
Content-Type: text/plain\n\
Last-Modified: %s\n\
%s\n",\
DOCUMENT_FOLLOWS, version, glob->nowtimestr, glob->nowtimestr,\
glob->caching ? glob->expiretimestr : "Pragma: no-cache\n" ))
#define PRINT_REDIRECT_HEADER (fprintf(fp, \
"HTTP/1.0 302 Found\n\
MIME-Version: 1.0\n\
Server: %s\n\
Date: %s\n\
Location: %s\n\
Content-Type: text/html\n\
Last-Modified: %s\n\
%s\n",\
version, glob->nowtimestr, query, glob->nowtimestr,\
glob->caching ? glob->expiretimestr : "Pragma: no-cache\n" ))
#define HTML_HEAD_TITLE "<HTML><HEAD><TITLE>%s</TITLE></HEAD><%s>"
#define PRINT_HTML_FOOTER (fprintf(fp, "</BODY></HTML>"))
/* Meta-Syntax of Gateway-Switching feature */
#define GWS "(gw)"
#define GWS_FORMAT "(gw-%s)"
#define OUT_TIME 900
/* Separator in UFNs */
#define UFNSEP ","
#endif /* _TGENERAL_ */

68
contrib/tweb/tglobal.h Normal file
View File

@ -0,0 +1,68 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* tglobal.h.. *
* *
* Function:..Global variables for TWEB *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* August 16 1996 Z D D V V *
* Last modification: Z D D V V *
* December 29 1998 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: tglobal.h,v 1.6 1999/09/10 15:01:20 zrnsk01 Exp $
*
*/
#ifndef _TGLOBAL_
#define _TGLOBAL_
#include "lber.h"
#include "ldap.h"
extern int debug;
extern int dosyslog;
extern struct timeval timestore[];
extern int items_displayed;
extern int searchaliases;
#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION
# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010
extern LDAPFriendlyMap *fm;
# else
extern LDAPFriendlyMap *fm;
# endif
#else
extern FriendlyMap *fm;
#endif
extern LDAPFiltDesc *filtd;
extern char version[];
extern char copyright[];
extern int http; /* HTTP-header in request -> also in reply */
extern int request;
#endif /* _TGLOBAL */

179
contrib/tweb/tweb.c Normal file
View File

@ -0,0 +1,179 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* tweb.c..... *
* *
* Function:..WorldWideWeb-X.500-Gateway MAIN-Routine *
* Based on web500gw.c 1.3 written by Frank Richter, TU Chemmniz *
* which is based on go500gw by Tim Howes, University of *
* Michigan - All rights reserved *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* August 16 1995 Z D D V V *
* Last modification: Z D D V V *
* December 31 1996 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: tweb.c,v 1.6 1999/09/10 15:01:20 zrnsk01 Exp $
*
*/
/*
* redesign BW 94/08/16
* patched for HPUX 9.x by /KSp, 94/04/28
* patched for AMBIX-D and use at University of Tuebingen by /KSp,
* patched for always-assume-nonleaf-behaviour-and-reread-on-demand; /KSp
* patched for restricted listing of Tuebinger students; /KSp
* patched for mailto HREF in mail attribute; /KSp
* patched for automatic referral to Chemnitz in case of ROOT access
* (AMBIX version only); /KSp
* patched for correct response in case of not found error; /MCl
* neg patched: subtree search below locality removed; /KSp
* patched for automatic referral to AMBIX in case of l=DFN access
* (non-AMBIX version only); /KSp
* patched for lower case compare during access control; /KSp
* patched for menu-'seeAlso' in AMBIXGW; /KSp
* patched for pgpPubKey formatting as MULTILINE; /KSP
* correction of MULTILINE handling; /KSp
* objectClass deleted from menu list entry in html-code; /KSp
* patched for "Selbsteintrag" needed by AMBIX-Project /mc
* last update: 95/07/07
*
* 95/07/17 changed to ANSI-C, deleted lots of compiletime-options. /mc
*
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Tuebingen. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*
* ----------------------------------------------------------------------
*/
#include "tweb.h"
PUBLIC int main (argc, argv)
int argc;
char **argv;
{
/* The Glob-structure is NOT a global variable, but is stored here for
all other functions !!! */
GLOB_STRUCT glob;
char lang[BUFSIZ];
int pid, i;
/* make glob global available */
globP = &glob;
/* first of all the language-parameter is scanned from the command-line
and is written as first value to the Glob-structure */
get_lang(argc, argv, lang);
bzero((char *) &glob, sizeof(GLOB_STRUCT));
glob.olang = strdup(lang);
/* Now start a process for each language and terminate the super-process */
for(i=0; i<strlen(lang); i++){
/* memorize the sub-process-language */
*glob.lang = lang[i];
switch( pid = fork() ) {
/* the Sub-Process */
case 0:
do_child(argc, argv,lang, &glob);
break;
/* A Sub-Process could not be created !!! */
case -1:
perror( "fork" );
break;
/* the Parent-Process */
default:
if ( debug )
fprintf( stderr, "forked child %d\n", pid );
break;
}
}
return( 0 );
}
/* end of function: main */
/**
** do_child()
**
** Main-Function for the working-processes; until now only the
** language is initialized. The rest of the configuration
** must be scanned now.
**/
PRIVATE void do_child(argc, argv,lang, glob)
int argc;
char **argv;
char *lang;
GLOB_STRUCT *glob;
{
FILE *fp = NULL;
char filename[BUFSIZ];
/* read language-independent (.rc) and -dependent (.conf) configuration */
init(argv, lang, glob);
/* read commandline-parameter (they overwrite conf) */
getopts (argc, argv, glob);
/* If debug-Mode: Configuration Output */
if (debug) {
sprintf(filename, "%s.debug", glob->myname);
fp =fopen(filename, "a");
fprintf(fp, "\n\n\n#####%s.%s-log Date: %s\n\n",
glob->myname, glob->lang, format_time(NULL));
output(fp, glob, FALSE);
}
/* read language-strings (from .lang) and write out if desired */
langinit(glob);
if (debug) {
langoutput(fp, glob, FALSE);
fclose(fp);
}
/* Final Configuration-Test */
check(glob);
/* If dynamic Gateway-Switching is enabled the language-dependent
recognition-string for the meta-Syntax must be fixed
(language-independent recognition-string is given in Macro GWS ) */
if(glob->gw_switch->dynamic) {
char strbuf[BUFSIZ];
sprintf(strbuf, GWS_FORMAT, glob->la[0]);
glob->gw_switch->lagws = strdup(strbuf);
}
/* and now start the Gateway ... */
start_server(glob);
}
/* end of function: do_child */

72
contrib/tweb/tweb.h Normal file
View File

@ -0,0 +1,72 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* tweb.h..... *
* *
* Function:..Header-File for TWEB-SOFTWARE *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* August 16 1995 Z D D V V *
* Last modification: Z D D V V *
* December 31 1998 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: tweb.h,v 1.6 1999/09/10 15:01:20 zrnsk01 Exp $
*
*/
#ifndef _TWEB_
#define _TWEB_
#include "tgeneral.h"
#include "init_exp.h"
#include "server_exp.h"
#include "support_exp.h"
PRIVATE void do_child();
int debug;
int dosyslog = 0;
GLOB_STRUCT *globP;
int searchaliases = 1;
#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION
# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010
LDAPFriendlyMap *fm = NULL;
# else
LDAPFriendlyMap *fm = NULL;
# endif
#else
FriendlyMap *fm = NULL;
#endif
LDAPFiltDesc *filtd;
extern char version[];
int http = 1; /* HTTP Version ??? */
int request = UNKNOWN;
#endif /* _TWEB_ */

2164
contrib/tweb/x500.c Normal file

File diff suppressed because it is too large Load Diff

61
contrib/tweb/x500.h Normal file
View File

@ -0,0 +1,61 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* x500.h..... *
* *
* Function:..Header-File for TWEB-Software *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* February 13 1996 Z D D V V *
* Last modification: Z D D V V *
* February 18 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: x500.h,v 1.6 1999/09/10 15:01:21 zrnsk01 Exp $
*
*/
#ifndef _X500_
#define _X500_
#include "x500_exp.h"
#include "charray_exp.h"
#include "ch_malloc_exp.h"
typedef LDAPMessage *(*LFP)();
typedef struct _my_ldap_list {
LDAPMessage *e;
struct _my_ldap_list *next;
} MY_LDAP_LIST, *pMY_LDAP_LIST;
pMY_LDAP_LIST mllroot = NULL;
PRIVATE int compare(/*a,b*/);
PRIVATE char * pick_oc(/*oclist*/);
PRIVATE int make_scope(/*ld, dn, glob*/);
PRIVATE int no_show(/* rdn, glob*/);
PRIVATE int sort_result(/*ld, res, dn, no_browse, glob*/);
PRIVATE void list_output(/*fp, flag, glob*/);
PRIVATE void make_la_buttons(/*sep, fp, dn, la_url, glob*/);
PRIVATE void make_la_buttons_pull_down(/*sep, fp, dn, la_url, glob*/);
PRIVATE void print_rdn(/*fp, dn, glob*/);
PRIVATE void print_rdn_pull_down(/*fp, dn, glob*/);
PRIVATE void make_search_box(/*fp, ld, dn, glob*/);
PRIVATE LDAPMessage *my_first_entry();
PRIVATE LDAPMessage *my_next_entry();
PRIVATE LDAPMessage *ldap_list_eval();
PRIVATE void sort_parse();
PRIVATE void get_ref_attrs();
PRIVATE void disp_form_button();
#endif /* _X500_ */

40
contrib/tweb/x500_exp.h Normal file
View File

@ -0,0 +1,40 @@
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
* *
* x500_exp.h. *
* *
* Function:..Header-Datei fuer TWEB-Software *
* *
* *
* *
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
* neuer Dienste, Universitaet Tuebingen, GERMANY *
* *
* ZZZZZ DDD V V *
* Creation date: Z D D V V *
* February 13 1996 Z D D V V *
* Last modification: Z D D V V *
* January 10 1999 ZZZZ DDD V *
* *
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
/*
* $Id: x500_exp.h,v 1.6 1999/09/10 15:01:21 zrnsk01 Exp $
*
*/
#ifndef _X500_EXP_
#define _X500_EXP_
PUBLIC void do_menu(/*ld, fp, dn, glob*/);
PUBLIC void do_xtend(/*ld, fp, dn, glob*/);
PUBLIC int do_search(/*ld, fp, query, glob*/);
PUBLIC void do_read(/*ld, fp, dn, amore, glob*/);
PUBLIC void do_form(/*ld, fp, query, glob*/);
PUBLIC void do_modify(/*ld, fp, query, glob*/);
PUBLIC char * make_oc_to_string(/*oc*/);
PUBLIC LDAP *get_ldap_connection( /* host, port, glob */ );
PUBLIC void close_ldap_connections();
#endif /* _X500_EXP_ */