|
|
1.1 root 1: /***********************************************************
2: Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
3: and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
4:
5: All Rights Reserved
6:
7: Permission to use, copy, modify, and distribute this software and its
8: documentation for any purpose and without fee is hereby granted,
9: provided that the above copyright notice appear in all copies and that
10: both that copyright notice and this permission notice appear in
11: supporting documentation, and that the names of Digital or MIT not be
12: used in advertising or publicity pertaining to distribution of the
13: software without specific, written prior permission.
14:
15: DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
16: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
17: DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
18: ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
19: WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
20: ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
21: SOFTWARE.
22:
23: ******************************************************************/
24:
25: /* $XConsortium: access.c,v 1.26 88/09/06 15:51:03 jim Exp $ */
26: #ifdef ISOCONN
27: #include <math.h>
28: /*
29: * i'm sorry, i'm sorry
30: *
31: * By Analogy with per host auth, we keep all the TSAPaddr but
32: * do access control on NSAPaddr part only...
33: */
34: #endif /* ISOCONN */
35:
36: #include "X.h"
37: #include "Xproto.h"
38: #include "misc.h"
39: #include "site.h"
40: #include <errno.h>
41: #include <sys/types.h>
42: #include <sys/socket.h>
43: #include <sys/ioctl.h>
44:
45: #ifdef hpux
46: #include <sys/utsname.h>
47: #else
48: #include <net/if.h>
49: #endif /* hpux */
50:
51: #include <netdb.h>
52: #ifdef TCPCONN
53: #include <netinet/in.h>
54: #endif /* TCPCONN */
55: #ifdef DNETCONN
56: #include <netdnet/dn.h>
57: #include <netdnet/dnetdb.h>
58: #endif
59: #ifdef ISOCONN
60: #include <isode/psap.h>
61: #include <isode/tsap.h>
62: #include <isode/isoservent.h>
63: #endif
64: #undef NULL
65: #include <stdio.h>
66: #include "dixstruct.h"
67: #include "osdep.h"
68:
69: #define acmp(a1, a2, len) bcmp((char *)(a1), (char *)(a2), len)
70: #define acopy(a1, a2, len) bcopy((char *)(a1), (char *)(a2), len)
71:
72: #define DONT_CHECK -1
73: extern char *index();
74:
75: typedef struct _host {
76: short family;
77: short len;
78: #ifdef ISOCONN
79: struct TSAPaddr addr; /* and so it is!! */
80: #else /* ISOCONN */
81: unsigned char addr[4]; /* will need to be bigger eventually */
82: #endif /* ISOCONN */
83: struct _host *next;
84: } HOST;
85:
86: static HOST *selfhosts = NULL;
87: static HOST *validhosts = NULL;
88: static int AccessEnabled = DEFAULT_ACCESS_CONTROL;
89:
90: typedef struct {
91: int af, xf;
92: } FamilyMap;
93:
94: static FamilyMap familyMap[] = {
95: #ifdef ISOCONN
96: /*
97: * This has to be visible to the protocol via X.h...
98: */
99: {AF_OSI, FamilyIso},
100: #endif /* ISOCONN */
101: #ifdef AF_DECnet
102: {AF_DECnet, FamilyDECnet},
103: #endif /* AF_DECnet */
104: #ifdef AF_CHAOS
105: {AF_CHAOS, FamilyChaos},
106: #endif /* AF_CHAOS */
107: #ifdef AF_INET
108: {AF_INET, FamilyInternet}
109: #endif
110: };
111:
112: #define FAMILIES ((sizeof familyMap)/(sizeof familyMap[0]))
113:
114: #ifdef hpux
115: /* Define this host for access control. Find all the hosts the OS knows about
116: * for this fd and add them to the selfhosts list.
117: * HPUX version - hpux does not have SIOCGIFCONF ioctl;
118: */
119: DefineSelf (fd)
120: int fd;
121: {
122: register int n;
123: int len;
124: caddr_t addr;
125: int family;
126: register HOST *host;
127:
128: struct utsname name;
129: register struct hostent *hp;
130:
131: union {
132: struct sockaddr sa;
133: struct sockaddr_in in;
134: } saddr;
135:
136: struct sockaddr_in *inetaddr;
137:
138: /* Why not use gethostname()? Well, at least on my system, I've had to
139: * make an ugly kernel patch to get a name longer than 8 characters, and
140: * uname() lets me access to the whole string (it smashes release, you
141: * see), whereas gethostname() kindly truncates it for me.
142: */
143: uname(&name);
144: hp = gethostbyname (name.nodename);
145: if (hp != NULL) {
146: saddr.sa.sa_family = hp->h_addrtype;
147: inetaddr = (struct sockaddr_in *) (&(saddr.sa));
148: acopy ( hp->h_addr, &(inetaddr->sin_addr), hp->h_length);
149: family = ConvertAddr ( &(saddr.sa), &len, &addr);
150: if ( family > 0) {
151: for (host = selfhosts;
152: host && ( family != host->family ||
153: acmp ( addr, host->addr, len));
154: host = host->next) ;
155: if (!host) {
156: /* add this host to the host list. */
157: host = (HOST *) xalloc (sizeof (HOST));
158: host->family = family;
159: host->len = len;
160: acopy ( addr, host->addr, len);
161: host->next = selfhosts;
162: selfhosts = host;
163: }
164: }
165: }
166: }
167:
168: #else
169: /* Define this host for access control. Find all the hosts the OS knows about
170: * for this fd and add them to the selfhosts list.
171: */
172: DefineSelf (fd)
173: int fd;
174: {
175: char buf[2048];
176: struct ifconf ifc;
177: register int n;
178: int len;
179: pointer addr;
180: int family;
181: register HOST *host;
182: register struct ifreq *ifr;
183: #ifdef ISOCONN
184: AEI aei;
185: struct PSAPaddr *pa;
186: #endif /* ISOCONN */
187:
188: #ifdef TCPCONN || UNIXCONN || DNETCONN
189: ifc.ifc_len = sizeof (buf);
190: ifc.ifc_buf = buf;
191: if (ioctl (fd, (int) SIOCGIFCONF, (pointer) &ifc) < 0)
192: Error ("Getting interface configuration");
193: for (ifr = ifc.ifc_req, n = ifc.ifc_len / sizeof (struct ifreq); --n >= 0;
194: ifr++)
195: {
196: #ifdef DNETCONN
197: /*
198: * this is ugly but SIOCGIFCONF returns decnet addresses in
199: * a different form from other decnet calls
200: */
201: if (ifr->ifr_addr.sa_family == AF_DECnet) {
202: len = sizeof (struct dn_naddr);
203: addr = (pointer)ifr->ifr_addr.sa_data;
204: family = AF_DECnet;
205: } else
206: #endif /* DNETCONN */
207: if ((family = ConvertAddr (&ifr->ifr_addr, &len, &addr)) <= 0)
208: continue;
209: for (host = selfhosts; host && (family != host->family ||
210: acmp (addr, host->addr, len)); host = host->next)
211: ;
212: if (host)
213: continue;
214: host = (HOST *) xalloc (sizeof (HOST));
215: host->family = family;
216: host->len = len;
217: acopy(addr, host->addr, len);
218: host->next = selfhosts;
219: selfhosts = host;
220: }
221: #endif TCPCONN
222: #ifdef ISOCONN
223: /*
224: * This is dubious - we should be able to take an fd (transport
225: * descriptor) and get the list of possible transport interfaces...
226: *
227: * Well strictly, for this TSAP, a list of NSAPs that are valid
228: */
229: host = (HOST *)xalloc (sizeof (HOST));
230: host->family = AF_OSI;
231: aei = str2aei(TLocalHostName(), DEFAULTTSERVICE);
232: if (aei == NULLAEI) {
233: Error("Unknown Display\n");
234: return;
235: }
236: if ((pa = aei2addr (aei)) == NULLPA) {
237: fprintf (stderr, "address translation failed");
238: return;
239: }
240: acopy(&(pa->pa_addr.sa_addr), &(host->addr), sizeof(struct TSAPaddr));
241: host->len = NASIZE;
242: host->next = selfhosts;
243: selfhosts = host;
244: #ifdef ISODEBUG
245: if (isodexbug) {
246: int i; char *hp = (char *)&(host->addr);
247: fprintf(stderr, "Self: ");
248: for(i=0; i<host->len; i++)
249: fprintf(stderr, "%x ", (*hp++)&0xff);
250: fprintf(stderr, "\n");
251: }
252: #endif /* ISODEBUG */
253: #endif /* ISOCONN */
254: }
255: #endif hpux
256:
257: /* Reset access control list to initial hosts */
258: ResetHosts (display)
259: char *display;
260: {
261: register HOST *host, *self;
262: char hostname[120];
263: char fname[32];
264: FILE *fd;
265: char *ptr;
266: union {
267: struct sockaddr sa;
268: #ifdef TCPCONN
269: struct sockaddr_in in;
270: #endif /* TCPCONN */
271: #ifdef DNETCONN
272: struct sockaddr_dn dn;
273: #endif
274: #ifdef ISOCONN
275: struct TSAPaddr ta;
276: #endif /* ISOCONN */
277: } saddr;
278: #ifdef DNETCONN
279: struct nodeent *np;
280: struct dn_naddr dnaddr, *dnaddrp, *dnet_addr();
281: #endif
282: int family;
283: int len;
284: pointer addr;
285: register struct hostent *hp;
286:
287: AccessEnabled = DEFAULT_ACCESS_CONTROL;
288: while (host = validhosts)
289: {
290: validhosts = host->next;
291: xfree (host);
292: }
293: for (self = selfhosts; self; self = self->next)
294: {
295: host = (HOST *) xalloc (sizeof (HOST));
296: *host = *self;
297: host->next = validhosts;
298: validhosts = host;
299: }
300: strcpy (fname, "/etc/X");
301: strcat (fname, display);
302: strcat (fname, ".hosts");
303: if (fd = fopen (fname, "r"))
304: {
305: while (fgets (hostname, sizeof (hostname), fd))
306: {
307: if (ptr = index (hostname, '\n'))
308: *ptr = 0;
309: #ifdef DNETCONN
310: if ((ptr = index (hostname, ':')) && (*(ptr + 1) == ':'))
311: {
312: /* node name (DECnet names end in "::") */
313: *ptr = 0;
314: if (dnaddrp = dnet_addr(hostname))
315: {
316: /* allow nodes to be specified by address */
317: NewHost ((short) AF_DECnet, (pointer) dnaddrp);
318: }
319: else
320: {
321: if (np = getnodebyname (hostname))
322: {
323: /* node was specified by name */
324: saddr.sa.sa_family = np->n_addrtype;
325: if ((family = ConvertAddr (&saddr.sa, &len, &addr)) ==
326: AF_DECnet)
327: {
328: bzero ((pointer) &dnaddr, sizeof (dnaddr));
329: dnaddr.a_len = np->n_length;
330: acopy (np->n_addr, dnaddr.a_addr, np->n_length);
331: NewHost (family, (pointer) &dnaddr);
332: }
333: }
334: }
335: }
336: else
337: {
338: #endif /* DNETCONN */
339: #ifdef ISOCONN
340: /*
341: * ISO displays are host:T-Namedisplay number
342: * only AEI are allowed (i.e. no raw addrs)
343: * XXX Fix to allow T/X and other T-Names...
344: */
345: if ((ptr = index (hostname, ':')) &&
346: ((*(ptr + 1) == 'X') || (*(ptr + 1) == 'T')))
347: {
348: AEI aei;
349: struct PSAPaddr *pa;
350: *ptr++ = '\0';
351: if (ptr)
352: aei = str2aei(hostname, ptr);
353: else
354: aei = str2aei(hostname, DEFAULTTSERVICE);
355: if (aei == NULLAEI) {
356: fprintf (stderr, "%s %s Unknown Display\n",
357: hostname, ptr);
358: continue;
359: }
360: if ((pa = aei2addr (aei)) == NULLPA) {
361: fprintf (stderr, "address translation failed");
362: continue;
363: }
364: family = AF_OSI;
365: NewHost(family, pa);
366: }
367: #endif ISOCONN
368: #ifdef TCPCONN
369: /* host name */
370: if (hp = gethostbyname (hostname))
371: {
372: saddr.sa.sa_family = hp->h_addrtype;
373: if ((family = ConvertAddr (&saddr.sa, &len, &addr)) > 0)
374: #ifdef NEW_HEADER_WITH_OLD_LIBRARY
375: NewHost (family, (pointer)hp->h_addr_list);
376: #else
377: NewHost (family, (pointer)hp->h_addr);
378: #endif
379:
380: }
381: #endif /* TCPCONN */
382: #ifdef DNETCONN
383: }
384: #endif /* DNETCONN */
385: }
386: fclose (fd);
387: }
388: }
389:
390: static Bool
391: AuthorizedClient(client)
392: ClientPtr client;
393: {
394: int alen, family;
395: #ifndef ISOCONN
396: struct sockaddr from;
397: #endif
398: pointer addr;
399: register HOST *host;
400: #ifdef ISOCONN
401: struct TSAPaddr from;
402: #endif /* ISOCONN */
403: #ifdef ISOCONN
404: /*
405: * XXXXXXXXXXXXXXXXX
406: * Just til I fix the X.25 calling addr stuff
407: */
408: return TRUE;
409: #endif /* ISOCONN */
410:
411: alen = sizeof (from);
412: #ifdef ISOCONN
413: if (!SGetPeerName (((OsCommPtr)client->osPrivate)->fd, &from, &alen))
414: #else /* ISOCONN */
415: if (!getpeername (((OsCommPtr)client->osPrivate)->fd, &from, &alen))
416: #endif /* ISOCONN */
417: {
418: if ((family = ConvertAddr (&from, &alen, &addr)) >= 0)
419: {
420: if (family == 0)
421: return TRUE;
422: for (host = selfhosts; host; host = host->next)
423: {
424: #ifdef ISOCONN
425: if (family == host->family && !acmp (addr, &(host->addr), alen))
426: #else /* ISOCONN */
427: if (family == host->family && !acmp (addr, host->addr, alen))
428: #endif /* ISOCONN */
429: return TRUE;
430: }
431: }
432: }
433: return FALSE;
434: }
435:
436: /* Add a host to the access control list. This is the external interface
437: * called from the dispatcher */
438:
439: int
440: AddHost (client, family, length, pAddr)
441: ClientPtr client;
442: int family;
443: unsigned length; /* of bytes in pAddr */
444: pointer pAddr;
445: {
446: int len;
447: register HOST *host;
448: int unixFamily;
449:
450: if (!AuthorizedClient(client))
451: return(BadAccess);
452: unixFamily = UnixFamily(family);
453: if ((len = CheckFamily (DONT_CHECK, unixFamily)) < 0)
454: {
455: client->errorValue = family;
456: return(-len);
457: }
458:
459: if (len != length)
460: {
461: client->errorValue = length;
462: return(BadValue);
463: }
464: for (host = validhosts; host; host = host->next)
465: {
466: #ifdef ISOCONN
467: if (unixFamily == host->family && !acmp (pAddr, &(host->addr), len))
468: return (Success);
469: #else /* ISOCONN */
470: if (unixFamily == host->family && !acmp (pAddr, host->addr, len))
471: return (Success);
472: #endif /* ISOCONN */
473: }
474: host = (HOST *) xalloc (sizeof (HOST));
475: host->family = unixFamily;
476: host->len = len;
477: #ifdef ISOCONN
478: acopy(pAddr, &(host->addr), len);
479: #else /* ISOCONN */
480: acopy(pAddr, host->addr, len);
481: #endif /* ISOCONN */
482: host->next = validhosts;
483: validhosts = host;
484: return (Success);
485: }
486:
487: /* Add a host to the access control list. This is the internal interface
488: * called when starting or resetting the server */
489: NewHost (family, addr)
490: short family;
491: pointer addr;
492: {
493: int len;
494: register HOST *host;
495:
496: if ((len = CheckFamily (DONT_CHECK, family)) < 0)
497: return;
498: for (host = validhosts; host; host = host->next)
499: {
500: #ifdef ISOCONN
501: if (family == host->family && !acmp (addr, &(host->addr), len))
502: return;
503: #else /* ISOCONN */
504: if (family == host->family && !acmp (addr, host->addr, len))
505: return;
506: #endif /* ISOCONN */
507: }
508: host = (HOST *) xalloc (sizeof (HOST));
509: host->family = family;
510: host->len = len;
511: #ifdef ISOCONN
512: acopy(addr, &(host->addr), len);
513: #else /* ISOCONN */
514: acopy(addr, host->addr, len);
515: #endif /* ISOCONN */
516: host->next = validhosts;
517: validhosts = host;
518: }
519:
520: /* Remove a host from the access control list */
521:
522: int
523: RemoveHost (client, family, length, pAddr)
524: ClientPtr client;
525: int family;
526: unsigned length; /* of bytes in pAddr */
527: pointer pAddr;
528: {
529: int len,
530: unixFamily;
531: register HOST *host, **prev;
532:
533: if (!AuthorizedClient(client))
534: return(BadAccess);
535: unixFamily = UnixFamily(family);
536: if ((len = CheckFamily (DONT_CHECK, unixFamily)) < 0)
537: {
538: client->errorValue = family;
539: return(-len);
540: }
541: if (len != length)
542: {
543: client->errorValue = length;
544: return(BadValue);
545: }
546: for (prev = &validhosts;
547: (host = *prev) && (unixFamily != host->family ||
548: #ifdef ISOCONN
549: acmp (pAddr, &(host->addr), len));
550: #else /* ISOCONN */
551: acmp (pAddr, host->addr, len));
552: #endif /* ISOCONN */
553: prev = &host->next)
554: ;
555: if (host)
556: {
557: *prev = host->next;
558: xfree (host);
559: }
560: return (Success);
561: }
562:
563: /* Get all hosts in the access control list */
564: int
565: GetHosts (data, pnHosts, pEnabled)
566: pointer *data;
567: int *pnHosts;
568: BOOL *pEnabled;
569: {
570: int len;
571: register int n = 0;
572: register pointer ptr;
573: register HOST *host;
574: int nHosts = 0;
575: int *lengths = (int *) NULL;
576:
577: *pEnabled = AccessEnabled ? EnableAccess : DisableAccess;
578: for (host = validhosts; host; host = host->next)
579: {
580: if ((len = CheckFamily (DONT_CHECK, host->family)) < 0)
581: return (-1);
582: lengths = (int *) xrealloc(lengths, (nHosts + 1) * sizeof(int));
583: lengths[nHosts++] = len;
584: n += (((len + 3) >> 2) << 2) + sizeof(xHostEntry);
585: }
586: if (n)
587: {
588: *data = ptr = (pointer) xalloc (n);
589: nHosts = 0;
590: for (host = validhosts; host; host = host->next)
591: {
592: #ifdef ISOCONN
593: #ifdef ISODEBUG
594: if (isodexbug)
595: {
596: int i; char *hp = (char *)(&host->addr);
597: fprintf(stderr, "List(%d): ", host->family);
598: for(i=0; i<len; i++)
599: fprintf(stderr, "%x ", (*hp++)&0xff);
600: fprintf(stderr, "\n");
601: }
602: #endif ISODEBUG
603: #endif /* ISOCONN */
604:
605: len = lengths[nHosts++];
606: ((xHostEntry *)ptr)->family = XFamily(host->family);
607: ((xHostEntry *)ptr)->length = len;
608: ptr += sizeof(xHostEntry);
609: #ifdef ISOCONN
610: acopy (&host->addr, ptr, len);
611: #else /* ISOCONN */
612: acopy (host->addr, ptr, len);
613: #endif /* ISOCONN */
614: ptr += ((len + 3) >> 2) << 2;
615: }
616: }
617: *pnHosts = nHosts;
618: xfree(lengths);
619: return (n);
620: }
621:
622: /* Check for valid address family, and for local host if client modification.
623: * Return address length.
624: */
625:
626: CheckFamily (connection, family)
627: int connection;
628: int family;
629: {
630: #ifdef ISOCONN
631: struct TSAPaddr from;
632: #else /* ISOCONN */
633: struct sockaddr from;
634: #endif /* ISOCONN */
635: int alen;
636: pointer addr;
637: register HOST *host;
638: int len;
639:
640: switch (family)
641: {
642: #ifdef TCPCONN
643: case AF_INET:
644: len = sizeof (struct in_addr);
645: break;
646: #endif
647: #ifdef DNETCONN
648: case AF_DECnet:
649: len = sizeof (struct dn_naddr);
650: break;
651: #endif
652: #ifdef ISOCONN
653: case AF_OSI:
654: len = NASIZE;
655: break;
656: #endif /* ISOCONN */
657: default:
658: return (-BadValue);
659: }
660: if (connection == DONT_CHECK)
661: return (len);
662: #ifdef ISOCONN
663: alen = NASIZE;
664: if (!SGetPeerName(connection, &from, &alen))
665: #else /* ISOCONN */
666: alen = sizeof (from);
667: if (!getpeername (connection, &from, &alen))
668: #endif /* ISOCONN */
669: {
670: if ((family = ConvertAddr (&from, &alen, &addr)) >= 0)
671: {
672: if (family == 0)
673: return (len);
674: for (host = selfhosts; host; host = host->next)
675: {
676: if (family == host->family &&
677: #ifdef ISOCONN
678: !acmp (addr, &(host->addr), alen))
679: #else /* ISOCONN */
680: !acmp (addr, host->addr, alen))
681: #endif /* ISOCONN */
682: return (len);
683: }
684: }
685: }
686: /* Bad Access */
687: return (-1);
688: }
689:
690: /* Check if a host is not in the access control list.
691: * Returns 1 if host is invalid, 0 if we've found it. */
692:
693: InvalidHost (saddr, len)
694: #ifdef ISOCONN
695: register struct TSAPaddr *saddr;
696: #else /* ISOCONN */
697: register struct sockaddr *saddr;
698: #endif /* ISOCONN */
699: int len;
700: {
701: int family;
702: pointer addr;
703: register HOST *host;
704: #ifdef ISOCONN
705: len = NASIZE;
706: #endif /* ISOCONN */
707:
708: if ((family = ConvertAddr (saddr, len ? &len : 0, &addr)) < 0)
709: return (1);
710: #ifdef ISOCONN
711: #ifdef ISODEBUG
712: if (isodexbug) {
713: int i; char *hp = (char *)(addr);
714: fprintf(stderr, "Other(%d): ", family);
715: for(i=0; i<len; i++)
716: fprintf(stderr, "%x ", (*hp++)&0xff);
717: fprintf(stderr, "\n");
718: }
719: #endif /* ISODEBUG */
720: #endif /* ISOCONN */
721: if (family == 0)
722: return (0);
723:
724: #ifdef ISOCONN
725: /*
726: * XXXXXXXXXXXXXXXXX
727: * Just til I fix the X.25 calling addr stuff
728: */
729: return 0;
730: #endif
731:
732: if (!AccessEnabled) /* just let them in */
733: return(0);
734: for (host = validhosts; host; host = host->next)
735: {
736: #ifdef ISOCONN
737: #ifdef ISODEBUG
738: if (isodexbug) {
739: int i; char *hp = (char *)&(host->addr);
740: fprintf(stderr, "List(%d): ", host->family);
741: for(i=0; i<host->len; i++)
742: fprintf(stderr, "%x ", (*hp++)&0xff);
743: fprintf(stderr, "\n");
744: }
745: #endif /* ISODEBUG */
746: if (family == host->family && !acmp (addr, &(host->addr), len))
747: #else /* ISOCONN */
748: if (family == host->family && !acmp (addr, host->addr, len))
749: #endif /* ISOCONN */
750: return (0);
751: }
752: return (1);
753: }
754:
755: ConvertAddr (saddr, len, addr)
756: #ifdef ISOCONN
757: register struct TSAPaddr *saddr;
758: #else /* ISOCONN */
759: register struct sockaddr *saddr;
760: #endif /* ISOCONN */
761: int *len;
762: pointer *addr;
763: {
764: if (len == 0)
765: return (0);
766: #ifdef ISOCONN
767: /*
768: * NULL ish type acttion, but maybe later we'd change this to
769: * use AEIs as the thing for access ctl, and need to get from
770: * transport descriptor to T-SAPs to AEI...
771: */
772: *len = NASIZE;
773: *addr = (pointer)saddr;
774: return (AF_OSI);
775:
776: #else /* ISOCONN */
777: switch (saddr->sa_family)
778: {
779: case AF_UNSPEC:
780: #ifndef hpux
781: case AF_UNIX:
782: #endif
783: return (0);
784: case AF_INET:
785: #ifdef TCPCONN
786: *len = sizeof (struct in_addr);
787: *addr = (pointer) &(((struct sockaddr_in *) saddr)->sin_addr);
788: return (AF_INET);
789: #else
790: break;
791: #endif
792:
793: #ifdef DNETCONN
794: case AF_DECnet:
795: *len = sizeof (struct dn_naddr);
796: *addr = (pointer) &(((struct sockaddr_dn *) saddr)->sdn_add);
797: return (AF_DECnet);
798: #else
799: break;
800: #endif
801: default:
802: break;
803: }
804: return (-1);
805: #endif /* ISOCONN */
806: }
807:
808: int
809: ChangeAccessControl(client, fEnabled)
810: ClientPtr client;
811: int fEnabled;
812: {
813: if (!AuthorizedClient(client))
814: return BadAccess;
815: AccessEnabled = fEnabled;
816: return Success;
817: }
818:
819: static int XFamily(af)
820: int af;
821: {
822: int i;
823: for (i = 0; i < FAMILIES; i++)
824: if (familyMap[i].af == af)
825: return familyMap[i].xf;
826: return -1;
827: }
828:
829: static int UnixFamily(xf)
830: int xf;
831: {
832: int i;
833: for (i = 0; i < FAMILIES; i++)
834: if (familyMap[i].xf == xf)
835: return familyMap[i].af;
836: return -1;
837: }
838:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.