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