1/* 2 3Copyright 1990, 1991, 1998 The Open Group 4 5Permission to use, copy, modify, distribute, and sell this software and its 6documentation for any purpose is hereby granted without fee, provided that 7the above copyright notice appear in all copies and that both that 8copyright notice and this permission notice appear in supporting 9documentation. 10 11The above copyright notice and this permission notice shall be included in 12all copies or substantial portions of the Software. 13 14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 21Except as contained in this notice, the name of The Open Group shall not be 22used in advertising or otherwise to promote the sale, use or other dealings 23in 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 61long MaxClients = DEFAULT_CLIENT_LIMIT; 62 63void 64AccessSetConnectionLimit(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 */ 81int 82CheckClientAuthorization( 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