5 March 2002. Daniel Hellerstein (danielh@crosslink.net)
SRE2003

sreLite2 -- an http/1.1 server for OS/2

SRE
 
Abstract sreLite2 ver 1.10 is an http www server for OS/2. It is freeware, and requires the SRE2003 Internet Server.

Contents:

I. Introduction
II. Installation
III. Configuration
III.a.    Description of Configuration Parameters
IV. Assigning client privileges
IVa.   The USERS.IN file
IVa.1.     Host specifc, generic host, and global usernames
IVa.2     Example of a USERS.IN file
V. Special directives
VI. Definitions
VII. Some procedures in the SRELITE2 procedure library
VIII. Disclaimer

I. Introduction

sreLite2 is a moderately featured http/1.1 (WWW) server for OS/2. It requires the SRE2003 Internet Server -- sreLite2 is a "filter" for SRE2003.

Features of sreLite2 include:

Although sreLite2 can be an effective WWW server....
    sreLite2 becomes cumbersome to configure, and looses efficiency, when you have a complicated set of redirections, aliases, and access controls.

If you find that you would benefit from a richer set of features, consider SREhttp/2 (check it out at http://srehttp2.srehttp.org/).

Note sreLite2 is based on the SRELite "GoServe filter". Although the feature set is similar, the configuration files (USERS.IN and SRELITE2.CFG) are somewhat different. Also, unless explicitily indicated, SRE-http addons will NOT run under sreLite2

In other words, migrating from SRELite to SRELite/2 will require some hands on tinkering.


II. Installation

Do you have an up to date version of SRE2003? If not, get it and install it (http://sre2003.srehttp.org/)
Let's assume SRE2003 is installed in the x:\SRE2003 directory
  1. Open up an OS/2 prompt.
  2. Unzip srelite2.zip to an empty temporary directory, You can get unzip from http://www.srehttp.org/pubfiles/unzip.exe
  3. Change directories (CD) to this no-longer empty temporary directory
  4. Run the install.cmd program from an os/2 prompt (the install program will ask you several questions)
  5. Start SRE2003.CMD (from an OS/2 prompt)

Notes:

  • INSTALL.CMD does not modify CONFIG.SYS, OS2.INI, or any other "system" files.
  • After installation, you can edit the SRELITE2 configuration file -- x:\SRE2003\SRELITE2\CFG\SRELITE2.CFG. See section 3 for the details.
  • Advanced users can also edit parameters in SREL_INI.RXX, but most users needn't bother (the defaults are recommended).
  • If you want to use PERL scripts, you should look at the INTERPRET_TYPES parameter in SREL_INI.RXX.
  • If you are running a controlled access web site, you'll also want to edit USERS.IN, the "username/password" file (x:\SRE2003\SRELITE2\CFG\USERS.IN). See section 4 for the details.

    Alternatively, you can use the CONFIG.HTM "configuration" tool (which is available from INDEX.SHT, the sample home page) to configure both SRELITE2.CFG and USERS.IN.

  • Reminder:
    If you are running a multiple host server, you should edit the HOSTSINFO.CFG file (in \SRE2003\CFG)
  • That's it; you can now test it out, by pointing it at your home page. Or (assuming you chose the defaults on installation) you can check out some sreLite2 features by pointing your browser at: /SRE2K/SRELITE2/INDEX.SHT which contains several examples of what sreLite2 can do.

    More Notes:

  • The TESTDEMO.ZIP file in the sreLite2 addon directory contains a demo of the use of the SRE2003 Task Manager. See TESTDEMO.TXT (in TESTDEMO.ZIP) for further details.
  • sreLite2 comes with the standard freeware dislaimer; in a nutshell, use it at your own risk (see the bottom of this document for a more complete disclaimer). That said, we want to know when you run into problems, and are always willing to help.
  • Questions, comments, bug reports?
    Please contact: Daniel Hellerstein at danielh@crosslink.net
    Or visit the SRE2003 website at: http://sre2003.srehttp.org

  • III. Configuration

    Configuration of sreLite2 requires modifying the SRELITE2.CFG configuration file, and the USERS.IN "username" database. Both of these are text files which can be modified using your favorite text editor. If you are running a multiple-host server, you also have to edit the HOSTINFO.CFG file in \sre2003\CFG.

    Alternatively, you can modify these files by using the on-line configuration tools accessible through the INDEX.SHT page (on the /SRE2K/sre2003 sub- directory of your "data directory").

    By default, these configuration tools are:

    1. only accessible from a browser running on the server machine
      You can change i by modifying the SECURITY_LEVEL parameter.

    2. require a superuser privilege. For example, you could use the username and password that the sreLite2 installer asked you to provide.
      Although we do not recommend it... you can change ii by modifying the SEL_REQUIRES parameter of SRELITE2.CFG.

    Notes:

  • Several advanced parameters (that rarely need to be changed) are set in SREL_INI.RXX. See SREL_INI.RXX for further discussion of these advanced parameters.
  • For a description of the USERS.IN file, see section IV.
  • In addition to modifying sreLite2 parameters and usernames; sreLite2's configuration tools let you:
    1. modify sre2003 parameters
    2. modify sre2003 host definitions
    3. modify sre2003 "unallowed ip addresses"
  • If you are very security conscious, we recommend setting SECURITY_LEVEL=0 (in sre2003.CFG). This prevents all web based configuration; which means you'll have to hand edit (using your favorite text editor) the various sre2003 and sreLite2 configuration files.
  • III.a. Description of Configuration Parameters

    Configuration parameters (in sre2003.CFG), and the USERS.IN file, are read when sre2003/SRELite2 first starts. You can modify these parameters on the fly by using the configurators avaiable from the sreLite2 description page. Or, if you like to do things by hand....

    1. edit SRELITE2.CFG, and/or USERS.IN
    2. issue, as a client with SUPERUSER privileges, a /!RESET command.
      or
      issue a /STATUSL? command, and hit the "reset privileges" link at the bottom of the screen.
    3. Parameter reset occurs immediately, username/password reset may take > a few seconds.
    Note that SREL_INI.RXX and SRELITE2.RXX contain several "advanced users" initialization parameters -- in most cases you should use their default values.

    The following parameters are contained in sre2003.CFG.

    ... For more details,see SRECFG1.HTM
    ... For most sites, the most important parameters are: sel_requires, aliases, superusers, and default_requires.
    ACCEPT_RANGE Enable range requests.
    ADD_SLASH Check for "subdirectory without trailing /" entries
    ALIASES Aliasing rules.
    ALWAYS_GET_PRIVS Always get client specific privileges
    DEFAULTS list of default names to use when request ends with a /
    DEFAULT_REQUIRES Default required priviliges
    DIR_EXCLUSIONS Directory exclusion list.
    DOMD5 Create and MD5 response header
    GZIP_THESE On the fly GZIP encoding
    HOME_DIR The users-home directory replacement for ~
    INHOUSEIPS Automatically grant client priviliges by IP address.
    LOAD_ADDON Addons to load into macrospace for quicker execution
    LOGIT Record entries in a common log file.
    NOT_FOUND_FILE A 404 response file
    POST_FILTER A procedure to call after responding to a request
    REALM Define a realm name
    SSI_EXTENSIONS List of server side include extensions.
    SUPERUSERS Define a list of superuers.
    SEL_REQUIRES Selector specific access requirements
    VERBOSE Verbosity of status messages.

    IV. Controlling access on a selector specific basis

    SRELite2 supports a moderately complex set of access controls rules.
    The basic notion is:

    1. a selector can be assigned a set of required privileges.
    2. client can be granted a set of client-privileges
    3. If a selector has a set of required privilege, the client can access it only if one of her client privileges appears in the set of required privileges.
      Note that just one match is required, the client does NOT have to match all of the "required privileges"
    4. on a multi host system, a selector is also associated with a host
    Required-privileges are assigned with the SEL_REQUIRES (and the DEFAULT_REQUIRES) parameters.

    Client privileges are assigned using the SUPERUSERS and INHOUSEIPS parameters, and using the USERS.IN file.

    1. The client's IP address is compared to to the SUPERUSERS parameter. If it appears in this parameter, the client is granted a SUPERUSER privilege.
    2. The client's IP address is then compared to the INHOUSEIPS parameters. If one of them matches, the client is granted
    3. Lastly, the username and password (supplied by the client in an Authorization request header) is compared to entries in the USERS.IN. If a matching username is found, and this username's password also matches, the client is assigned a USERS privilege, as well as all the privileges associated with the matching entry.

    Notes:

  • The extent of client privilege accumulation (i.e.; whether to not bother at all, to stop at step a, or to always do steps a to c) is controlled by the ALWAYS_GET_PRIVS parameter

  • Comparing the * and 0 required privilege
    * Any privilege will match.
    Thus, a client who matches:
  • SUPERUSERS, or
  • one of the INHOUSEIPS, or
  • has a valid username and password,
  • will be allowed to access this resource.

    However, if the client does not have a valid username and pasword, then she will not be granted access to this resource

    0 no privileges are required, this is a "public" resource. In other words, a username and password are not required to access this resource.
      
    Thus, a * is more stringent then a 0

  • In USERS.IN:
  • a username of * means any user; and a password of * means any password
  • wildcarded usernames are checked after the non-wildcarded usernames
  • clients with a valid username and password are granted a USER privileges (in addition to the privileges specified in USERS.IN)
  • comparision of resource and client privileges is case insensitive
  • clients with a SUPERUSER privilege are always granted access to all resources
  • To reiterate: client privileges are cumulative -- username privileges will be added to INHOUSEIPS privileges, which are added to a possible SUPERUSER privilege.
  • On multiple hosts system, be sure to specify the "host-nickname" when defining the INHOUSEIPS, SEL_REQUIRES, and ALIASES parameters.
  • Please note that the .HTACCESS method of access control (that uses .HTACCESS files located in directories) is not supported by sreLite.

  • IVa. The USERS.IN file

    The syntax of entries in USERS.IN is:
         USERNAME  PASSWORD client_Privilege_list
    
     where all fields can contain letters (A-Z, a-z), numbers (0-9), and _ characters:
    
      >  Username is a case insensitive username
         The format of username is one of:
            username                -- username applies to all hosts, including the "Generic" host"
            host_nickname/username  -- username ONLY applies to requests to host_nickname
           /username                -- username ONLY applies to requested to the generic host
      >  Password is possibly case-sensitive (depending on the client's authorization protocol)
         It can contain A-Z, a-z, _, and 0-10.
      >  Client_privilege_list is an optional space delimited list of "privileges".
    
    You can also use a * for either username or password ---
    
      >> the * character for password means "any password will do".
      >> the * in USERNAME is a wildcard -- it means "any username 
         (say, for this host_nickname)
    

    IVa.1. Host specifc, generic host, and global usernames.

    When sreLite2 compares entries in USERS.IN to the username supplied by the client, it will look for 4 different names:
    1. The "host-specific" username. This could be the "generic" host, signified by username.
    2. The non-host-specific username.
    3. The host-specific wildcard
    4. The default wildcard
    Thus, if the host nickname is TIGER and the username is JONES then the following entries will be looked for in the userfile
             TIGER/JONES
             JONES
             TIGER/ *
             * 
    Or, for a request to the "generic host" (i.e.; if you did NOT specify any host nicknames), and the username is PAUL:
             /PAUL
             PAUL
             / *
             *              
    Note that /PAUL means:   check for username PAUL on a request to the generic host only
    whereas PAUL means:   check for username PAUL on ALL requests (perhaps after checking for a host-specific PAUL).

    In any case, if a username is found, it's password is compared to what the client provided. If the password does not match, then the username is not a match.


    IVa.2 Example of a USERS.IN file:

       ; this is a comment (starts with ;)
       OUTATOWN SHEP2  INHOUSE
       MASTER1 12ISIE6 SUPERUSER
       user1 1user     Priv1 Priv2
       ANONYMOUS *  PUBLIC
       TIGERS/Jill  cats dogs
       SHOP/*  shopper visitorx
       /BILL PILL SILL
       TIGERS/BILL WILL NILL
       BILL HILL  MILL
    

    V. Special Directives

    Special directives are selectors that begin with a !. Currently, two special directives are supported:
    !RESET Reset sreLite2 parameters. This requires SUPERUSER privileges
    !RANGE:rtype=a1-a2/asel Add a RANGE item to the IM information. If you've selected XRANGE as your IM_DEFAULT, this RANGE IM information will be used to extract a portion of aselector.

    Rtype defines how to extract this range:

    • If rtype= BYTES, a1 and a2 should be integers.
    • If rtype= STRINGS, a1 and a2 should be url-encoded, case sensitive, strings. Be sure to use + for spaces!

      Note that asel should be a normal selector, which will be subject to the usual access controls and alias transformations.

      For more information on XRANGE, see IM_USE.HTM.


    VI. Definitions

    The following sundry definitions and descriptions of sreLite2 concepts are listed in rough alphabetical order.
    CGI-BIN
    CGI (Common Gateway Interfact) - BIN is a standard by which server side ("gateway") programs can be invoked. It uses environment variables to pass data, as well as standard input and output.

    Client
    The Client (sometimes referred to as the requester) is the individual requesting a URL -- where the URL may point to a file, or may invoke a script.
    Typically, the request was generated by someone running a Web Browser, and clicking on a link or submitting a FORM.

    Default Data Directory
    The Default Data Directory is the root directory of your web site -- it (and it's subdirectories) are the usual locations for your HTML documents, images, etc. By default, the sre2003 Data Directory is used as the Default Data Directory.

    A simple example might help:

  • a request selector of MYFILES/PROJECT1/BIGTASK.HTM is recieved
  • your default data directory is E:\WWW

    then, SRElite2 will use E:\WWW\MYFILES\PROJECT1\BIGTASK.HTM

  • Request selector
    When a client sends a request to a server, it contains three components: the method, the selector, and the protocol. For example, in the following request line: GET /FOO1/BAR.HTM HTTP/1.0
    1. the http method is: GET
    2. the selector is: /FOO1/BAR.HTM:
    3. the http protocol is: HTTP/1.0:

    Note that if a GET HTTP method was used, the request selector may contain information following a ?
    For example... /SHOWINFO?DATABASE=PRICES&ITEM=APPLES

    Selector-specific
    Selector-specific means a piece of information specific to a request selector. In other words, this means that sreLite will use the value of the request selector to find information (such as the required privileges).

    URL: Uniform Resource Identifier (URI), and Uniform Resource Locator (URL)
    URIs (which are basically synonymous with URLS) are a scheme for specifying Internet resources using a single line of printable ASCII characters. A URL should contain a protocol, domain name, port number (optional), the location of the resource, and an (optional) option list (following a ?).

    Example: http://WWW.SREHTTP.ORG:80/calc/calc.htm

    Wildcard matching
    Wildcard matching use the * as a wildcard character in a natural fashion.

    Examples:

         
             /JOE/*  will match /JOE/FOO.HTM
             /JOAN/SRCH.HTM?*  will match /JOAN/SRCH.HTM?search+me
             /JOAN/SRCH.HTM?*  will NOT match /JOAN/SRCH.HTM
                 (/JOAN/SRCH.HTM* will match BOTH these examples)
             /PETS/*INDEX.HTM will match
             /PETS/INDEX.HTM, /PETS/CAT/INDEX.HTM and /PETS/PUPPY/LAB/INDEX.HTM
                 but will NOT match
             /PETS/CAT/PUREBRED.HTM
    Wildcard matching is used when examining SEL_REQUIRES, ALIASES, and INHOUSEIPS.

    Wildcard matching with substitution
    Wildcard matching with substitution is similar to wildcard matching. However, rather then being a "many to one" match, it is a "many to many" match.

    The basic rule is that both a "target" and a "replacement" should contain * characters. When a wildcard match between the target and a candidate occurs, the "covered portion of the candidate" is inserted into the "replacement". In other words, the * character in the replacement is deleted, and the "covered portion" is inserted.

    Example:

  • If the request selector is: PROJECT/JILLWORK.HTM
  • and there is an alias of: PROJECT/* /RESEARCH/ONGOING/*
  • the resulting match is: /RESEARCH/ONGOING/JILLWORK.HTM

  • VII. Some procedures in the SRELITE2 procedure library

    
    The following lists a few useful procedures provided in the sreLite2
    procedure library. These complement the procedures in the sre2003
    procedure library (as described in SRE2PRC.HTM).
    
      SREL2_RESET           Reread configuration files
      SREL2_MULT_SEND       Send a multi-part document
      SREL2_GET_USERINFO    Extract information on a user
      SREL2_CHECK_PRIVS     Check a list or privileges against a second list
    
                            --------------------------
    
    SREL2_CHECK_PRIVS
    
     Check to see if the user has one of the required privileges.
    
     Syntax: 
        imatch=srel2_check_privs(privs_to_check,privs_granted)
    
    where:
    
       privs_to_check : a space delimited list of privileges (as may be specified
                        if a sel_requires entry).
    
       privs_granted:  the privileges of this user; say, as derived from srel2_get_userinfo
                       (that is, as specified in USERS.IN).
    
    and
    
      imatch:
         0    -- none of the the names in the userlist have any of the 
                 privileges contained in the privs_to_check list
         n    -- the first privilege, in the privs_to_check list, found in privs_granted
    
    Notes:
       *  If privs_granted='', then always return 0
       *  If privs_to_check='', then always return 0
       *   a "*" in Privs_to_check matches anything  (thus, if * is the 3 element in
           privs_to_check, then always return 1, 2, or 3).
    
    
    
    SREL2_GET_USERINFO
    
    
     Determine username, password, and privileges; given either a list
     of possible usernames, or (more commonly) based on information found
     in an authorization request header 
    
     Syntax: 
        imatch=srel2_get_userinfo(userlist,authh,host_nick,id_info)
    
     where:
    
       userlist:   Optional. 
                   The list of users to try finding privileges for.
                   The first "existing" user in this list is used
                   If blank, then construct a user list (see below)
    
       If userlist is not specified (which is the usual mode of operation), 
       then the following two variables may be used:
    
          authh: optional. The authorization header. If not provided, it will
                 be looked up
    
         host_nick: optional. The host nickname. 
                    If not provided, it will be looked up.  
                    If there is no host nickname for this request, the "generic"
                    host is assumed.
    
       id_info: optional, The id_info (include this to speed up processing a bit)
    
    and
    
      Imatch:
        ' '    -- No match. This can happen for a number of reasons:
                    1) none of the the names in the userlist could be found in the
                       userfile
                      Note that if userlist IS specified, then passwords are NOT checked
                    2) userlist was not specified, and
                        a) there was no authorization request header 
                        b) the username in the authorization request header was not
                           found in the userlist, or had a mismatching password
         user_record -- Match found. The user_record contains:
                            username password priv1 ... privn
                         Note that the username indicates which username (in the
                         possibly auto-generated userlist) was matched.
    
     Notes:
    
    
     * When userlist is not specified, a userlist containing 4 usernames is constructed.
       These are derived from the authorization header; and are subject to "password" checking. 
       The 4 names consist of:
    
         1) The "host-specific" username. 
            For request that are not to host for which a host-nickname exist (that is, for
            requests to the "generic" host), use  /username  (i.e.; preface the username 
            with a /).
         2) The non-host-specific username.
         3) The host-specific wildcard
         4) The default wildcard
         
         Thus, if the host nickname is TIGER and the username is JONES 
         then the following entries will be looked for in the userfile
             TIGER/JONES
             JONES
             TIGER/*
             *
    
         Or, for a request to the "generic host" (i.e.; if you did NOT specify any
         host nicknames), and the username is PAUL:
             /PAUL
             PAUL
             /*
             *
         
        In any case, if a username is found, it's password is compared to what the
        client provided. If the password does not match, then the username is NOT 
        used (a ' ' is returned).
    
     * A return of ' ' often means you should send an authorization response
       (i.e.; using sre_auth_response)
    
    
    SREL2_MULT_SEND:
    
      Send a piece or a part of a response.
      For the details, see MULTSEND.DOC.
    
    
    SREL2_RESET:
       Reset the sreLite2 configuration parameters -- re-read sreLite2.CFG,
       USERS.IN, or HOSTINFO.CFG.
    
       Syntax:
            astat=srel2_reset(not_params,douser,dohost)
        where all the parameters are optional:
            doparams = if not_params<>1, then reread sreLite2 configuration
                       parameters file (sreLite2.CFG)
            douse    =  douser=1, then reread the username file (USERS.IN)
            dohost   =  if dohost=1, then reread the sre2003 host definitions file
                        (HOSTINFO.CFG)
    
            astat    = if no errors, a 1 is returned
                       Otherwise, 'ERROR an_error_message'
    
       Example:
             f=srel2_reset()      -- just reread sreLite2 configuration parameters
             f=srel2_reset(,1)    -- configuration parameters and user
             f=srel2_reset(1,,1)  -- reset hostinfo, do NOT reset configuration 
    
    

    VII. Basic copyright and it's never our fault disclaimer:

    Copyright 2002, 2003 by Daniel Hellerstein.

    As an component of the sre2003 suite, the disclaimer for SRElite2 is the same. Basically,

    Permission to use this program for any purpose is hereby granted without fee, provided that the author's name not be used in advertising or publicity pertaining to distribution of the software without specific written prior permision.

    SRELITE2 and related product are NOT guaranteed to be secure.

    THIS SOFTWARE PACKAGE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.

    For the complete disclaimer, please see sre2003.HTM.