home *** CD-ROM | disk | FTP | other *** search
- /* 00010000
- * Name: GOPSRVAU EXEC, authorization function 00020000
- * returns TRUE (1) if the file/menu may be retrieved 00030000
- * returns FALSE (0) otherwise 00040000
- * Date: 1993-Jan-18 00050000
- * Author: Rick Troth, Rice University, Information Systems 00060000
- * 00070000
- * This file is part of CMS Gopher. 00080000
- */ 00090000
- 00100000
- /* 00110000
- * Copyright 1993 Richard M. Troth. This software was developed 00120000
- * with resources provided by Rice University and is intended 00130000
- * to serve Rice's user community. Rice has benefitted greatly 00140000
- * from the free distribution of software, therefore distribution 00150000
- * of unmodified copies of this material is not restricted. 00160000
- * You may change your own copy as needed. Neither Rice 00170000
- * University nor any of its employees or students shall be held 00180000
- * liable for damages resulting from the use of this software. 00190000
- */ 00200000
- 00210000
- /* ---------------------------------------------------------- AUTHORIZED00220000
- * Verify that the client is allowed access, based on IP addr or name. 00230000
- * (we originally used an internal routine called IPA2C(), but Arty's 00240000
- * RXSOCKET provides an Inet_addr() function, which is now preferred) 00250000
- */ 00260000
- AUTHORIZED: 00270000
- Parse Upper Arg Client,AuthList 00280000
- If AuthList = "" Then Return 1 00290000
- ClientAddr = Inet_addr(Client) 00300000
- 00310000
- rc = Socket('GetHostByAddr', ClientAddr, 'ClientName') 00320000
- If rc = "-1" Then ClientName = Client 00330000
- Say "Client looks like" ClientName Inet_ntoa(ClientAddr) 00340000
- Upper ClientName 00350000
- 00360000
- allow = 1 00370000
- Do While AuthList ^= "" 00380000
- 00390000
- Parse Var AuthList Auth AuthList 00400000
- If Auth = "DENY" Then Do 00410000
- allow = 0; Parse Var AuthList Auth AuthList 00420000
- End /* If .. Do */ 00430000
- If Auth = "ALLOW" Then Do 00440000
- allow = 1; Parse Var AuthList Auth AuthList 00450000
- End /* If .. Do */ 00460000
- Say "Auth" Auth 00470000
- If Auth = '*' Then Return allow 00480000
- 00490000
- Parse Var Auth Auth "," AuthMask "," . 00500000
- AuthAddr = Inet_addr(Auth) 00510000
- If AuthAddr = "-1" Then Do /* process as a name spec */00520000
- If Left(Auth,1) = '.' Then Do 00530000
- TruncName = Right(ClientName,Length(Auth)) 00540000
- Say "Truncated ClientName" TruncName 00550000
- If TruncName = Auth Then Return allow 00560000
- End /* If .. Do */ 00570000
- Else If ClientName = Auth Then Return allow 00580000
- End /* If .. Do */ 00590000
- 00600000
- Else Do /* must be a numeric spec */00610000
- AuthMask = Inet_addr(AuthMask) 00620000
- If AuthMask = "-1" Then Do 00630000
- AuthMask = bitand(AuthAddr,'C0000000'x) 00640000
- Select /* AuthMask */ 00650000
- When AuthMask = '00000000'x Then AuthMask = 'FF000000'x 00660000
- When AuthMask = '80000000'x Then AuthMask = 'FFFF0000'x 00670000
- When AuthMask = 'C0000000'x Then AuthMask = 'FFFFFF00'x 00680000
- End /* Select AuthMask */ 00690000
- End /* If .. Do */ 00700000
- Say "ADDR" c2x(AuthAddr) "MASK" c2x(AuthMask) 00710000
- AuthAddr = bitxor(AuthAddr,ClientAddr) 00720000
- AuthAddr = bitand(AuthAddr,AuthMask) 00730000
- If AuthAddr = '00000000'x Then Return allow 00740000
- End /* Else Do */ 00750000
- 00760000
- End /* Do While */ 00770000
- 00780000
- Return 0 00790000
- 00800000
-