|
|
|
|
File: [XFree86 CVS] / xc / programs / xdm / policy.c
(download)
Revision: 3.4, Sun Dec 6 06:08:48 1998 UTC (14 years, 5 months ago) by dawes Branch: MAIN CVS Tags: xf-4_0g, xf-4_0f, xf-4_0e, xf-4_0d, xf-4_0c, xf-4_0b, xf-4_0a, xf-4_0_3b, xf-4_0_3a, xf-4_0_3, xf-4_0_2c, xf-4_0_2b, xf-4_0_2a, xf-4_0_2-branch, xf-4_0_2-bindist, xf-4_0_2, xf-4_0_1h, xf-4_0_1g, xf-4_0_1f, xf-4_0_1e, xf-4_0_1d, xf-4_0_1c, xf-4_0_1b, xf-4_0_1a, xf-4_0_1Zc, xf-4_0_1Zb, xf-4_0_1Za, xf-4_0_1Z, xf-4_0_1-bindist, xf-4_0_1, xf-4_0Z, xf-4_0-bindist, xf-4_0, xf-3_9_18b, xf-3_9_18a, xf-3_9_18Za, xf-3_9_18Z, xf-3_9_18, xf-3_9_17f, xf-3_9_17e, xf-3_9_17d, xf-3_9_17c, xf-3_9_17b, xf-3_9_17a, xf-3_9_17Z, xf-3_9_17, xf-3_9_16f, xf-3_9_16e, xf-3_9_16d, xf-3_9_16c, xf-3_9_16b, xf-3_9_16a, xf-3_9_16Za, xf-3_9_16Z, xf-3_9_16, xf-3_9_15d, xf-3_9_15c, xf-3_9_15b, xf-3_9_15a, xf-3_9_15, xf-3_9Py, xf-3_9Px, xf-3_9Pw, xf-3_9Pv, xf-3_9Pu, xf-3_9Pt, xf-3_9Ps, xf-3_9Pr, xf-3_9Pq, xf-3_9Pp, xf-3_9Po, xf-3_9Pn, xf-3_9Pm, xf-3_9Pl, xf-3_9Pk, xf-3_9Pj, xf-3_9Pi, xf-3_9Phb, xf-3_9Pha, xf-3_9Ph-branch, xf-3_9Ph, xf-3_9Pg, xf-3_9Pf, xf-3_9Pe, xf-3_9Pd, xf-3_9Pc, xf-3_9Pb, xf-3_9Pa, xf-3_9P, xf-3_9Nz, xf-3_9Ny, xf-3_9Nx, xf-3_9Nw, xf-3_9Nva, xf-3_9Nv-branch, xf-3_9Nv, xf-3_9Nu, xf-3_9Nt, xf-3_9Ns, xf-3_9Nr, xf-3_9Nq, xf-3_9Np, pre-R651-import Changes since 3.3: +15 -2 lines #2269-2291, for 3.9Np |
/* $TOG: policy.c /main/13 1998/02/09 13:55:49 kaleb $ */
/*
Copyright 1988, 1998 The Open Group
All Rights Reserved.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
/*
* xdm - display manager daemon
* Author: Keith Packard, MIT X Consortium
*
* policy.c. Implement site-dependent policy for XDMCP connections
*/
/* $XFree86: xc/programs/xdm/policy.c,v 3.3 1998/10/10 15:25:36 dawes Exp $ */
# include "dm.h"
# include "dm_auth.h"
#ifdef XDMCP
# include <X11/X.h>
# include "dm_socket.h"
static ARRAY8 noAuthentication = { (CARD16) 0, (CARD8Ptr) 0 };
typedef struct _XdmAuth {
ARRAY8 authentication;
ARRAY8 authorization;
} XdmAuthRec, *XdmAuthPtr;
static XdmAuthRec auth[] = {
#ifdef HASXDMAUTH
{ {(CARD16) 20, (CARD8 *) "XDM-AUTHENTICATION-1"},
{(CARD16) 19, (CARD8 *) "XDM-AUTHORIZATION-1"},
},
#endif
{ {(CARD16) 0, (CARD8 *) 0},
{(CARD16) 0, (CARD8 *) 0},
}
};
#define NumAuth (sizeof auth / sizeof auth[0])
ARRAY8Ptr
ChooseAuthentication (ARRAYofARRAY8Ptr authenticationNames)
{
int i, j;
for (i = 0; i < (int)authenticationNames->length; i++)
for (j = 0; j < NumAuth; j++)
if (XdmcpARRAY8Equal (&authenticationNames->data[i],
&auth[j].authentication))
return &authenticationNames->data[i];
return &noAuthentication;
}
int
CheckAuthentication (
struct protoDisplay *pdpy,
ARRAY8Ptr displayID,
ARRAY8Ptr name,
ARRAY8Ptr data)
{
#ifdef HASXDMAUTH
if (name->length && !strncmp ((char *)name->data, "XDM-AUTHENTICATION-1", 20))
return XdmCheckAuthentication (pdpy, displayID, name, data);
#endif
return TRUE;
}
int
SelectAuthorizationTypeIndex (
ARRAY8Ptr authenticationName,
ARRAYofARRAY8Ptr authorizationNames)
{
int i, j;
for (j = 0; j < NumAuth; j++)
if (XdmcpARRAY8Equal (authenticationName,
&auth[j].authentication))
break;
if (j < NumAuth)
{
for (i = 0; i < (int)authorizationNames->length; i++)
if (XdmcpARRAY8Equal (&authorizationNames->data[i],
&auth[j].authorization))
return i;
}
for (i = 0; i < (int)authorizationNames->length; i++)
if (ValidAuthorization (authorizationNames->data[i].length,
(char *) authorizationNames->data[i].data))
return i;
return -1;
}
/*ARGSUSED*/
int
Willing (
ARRAY8Ptr addr,
CARD16 connectionType,
ARRAY8Ptr authenticationName,
ARRAY8Ptr status,
xdmOpCode type)
{
char statusBuf[256];
int ret;
ret = AcceptableDisplayAddress (addr, connectionType, type);
if (!ret)
sprintf (statusBuf, "Display not authorized to connect");
else
{
if (*willing)
{ FILE *fd;
if ((fd = popen(willing, "r")) && fgets(statusBuf, 256, fd))
{
statusBuf[strlen(statusBuf)-1] = 0; /* chop newline */
}
else
sprintf (statusBuf, "Willing, but %s failed",willing);
if (fd) pclose(fd);
}
else
sprintf (statusBuf, "Willing to manage");
}
status->length = strlen (statusBuf);
status->data = (CARD8Ptr) malloc (status->length);
if (!status->data)
status->length = 0;
else
memmove( status->data, statusBuf, status->length);
return ret;
}
/*ARGSUSED*/
ARRAY8Ptr
Accept (
struct sockaddr *from,
int fromlen,
CARD16 displayNumber)
{
return 0;
}
/*ARGSUSED*/
int
SelectConnectionTypeIndex (
ARRAY16Ptr connectionTypes,
ARRAYofARRAY8Ptr connectionAddresses)
{
return 0;
}
#endif /* XDMCP */
|
Powered by ViewCVS 0.9.2 |