Home | History | Annotate | Line # | Download | only in os
      1 /*
      2 
      3 Copyright 1990, 1991, 1998  The Open Group
      4 
      5 Permission to use, copy, modify, distribute, and sell this software and its
      6 documentation for any purpose is hereby granted without fee, provided that
      7 the above copyright notice appear in all copies and that both that
      8 copyright notice and this permission notice appear in supporting
      9 documentation.
     10 
     11 The above copyright notice and this permission notice shall be included in
     12 all copies or substantial portions of the Software.
     13 
     14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
     17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
     18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
     19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     20 
     21 Except as contained in this notice, the name of The Open Group shall not be
     22 used in advertising or otherwise to promote the sale, use or other dealings
     23 in this Software without prior written authorization from The Open Group.
     24 
     25  * Copyright 1990, 1991 Network Computing Devices;
     26  * Portions Copyright 1987 by Digital Equipment Corporation
     27  *
     28  * Permission to use, copy, modify, distribute, and sell this software and
     29  * its documentation for any purpose is hereby granted without fee, provided
     30  * that the above copyright notice appear in all copies and that both that
     31  * copyright notice and this permission notice appear in supporting
     32  * documentation, and that the names of Network Computing Devices, or Digital
     33  * not be used in advertising or publicity pertaining to distribution
     34  * of the software without specific, written prior permission.
     35  *
     36  * NETWORK COMPUTING DEVICES, AND DIGITAL DISCLAIM ALL WARRANTIES WITH
     37  * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
     38  * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES,
     39  * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
     40  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
     41  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
     42  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
     43  * THIS SOFTWARE.
     44  */
     45 
     46 #include	"config.h"
     47 
     48 #include	<X11/Xos.h>
     49 #include        <sys/param.h>
     50 #include	<sys/socket.h>
     51 #include	<netdb.h>
     52 #include	<netinet/in.h>
     53 #include	"clientstr.h"
     54 #include	"misc.h"
     55 #include	"site.h"
     56 #include	"osdep.h"
     57 #include	"osstruct.h"
     58 #include	"globals.h"
     59 #include	"access.h"
     60 
     61 long        MaxClients = DEFAULT_CLIENT_LIMIT;
     62 
     63 void
     64 AccessSetConnectionLimit(int num)
     65 {
     66     int newlim = num + 8; /* allow room for serverClient, logs, etc. */
     67     int maxfd = sysconf(_SC_OPEN_MAX) - 1;
     68 
     69     if ((maxfd < 0) || (maxfd > MAXSOCKS)) {
     70 	maxfd = MAXSOCKS;
     71     }
     72     if (newlim > maxfd) {
     73 	ErrorF("Client limit of %d too high; using default of %d\n",
     74 	       num, DEFAULT_CLIENT_LIMIT);
     75 	return;
     76     }
     77     MaxClients = newlim;
     78 }
     79 
     80 /* ARGSUSED */
     81 int
     82 CheckClientAuthorization(
     83     ClientPtr   client,
     84     AuthPtr     client_auth,
     85     int        *accept,
     86     int        *index,
     87     int        *size,
     88     char      **auth_data)
     89 {
     90     OsCommPtr	oc;
     91     int i;
     92 
     93     /* now that it's connected, zero the connect time
     94        so it doesn't get killed */
     95     oc = (OsCommPtr)client->osPrivate;
     96     oc->conn_time = 0;
     97 
     98     *size = 0;
     99     *accept = AuthSuccess;
    100 
    101     client->auth_generation++;
    102 
    103 #define AUTH1_NAME "hp-hostname-1"
    104 #define AUTH2_NAME "hp-printername-1"
    105     for (i = 0; i < *index; i++)
    106 	if ((client_auth[i].namelen == sizeof(AUTH1_NAME) &&
    107 	    !strcmp(client_auth[i].name, AUTH1_NAME)) ||
    108 	    (client_auth[i].namelen == sizeof(AUTH2_NAME) &&
    109 	    !strcmp(client_auth[i].name, AUTH2_NAME))) break;
    110     if (i == *index)
    111 	i = 0;
    112     else
    113 	i++;
    114     *index = i;
    115     return FSSuccess;
    116 }
    117