~ubuntu-branches/ubuntu/quantal/xdm/quantal

« back to all changes in this revision

Viewing changes to policy.c

  • Committer: Bazaar Package Importer
  • Author(s): Brice Goglin
  • Date: 2010-03-14 11:44:38 UTC
  • mto: (9.1.1 sid)
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: james.westby@ubuntu.com-20100314114438-xce9zkmf88jtlq0l
Tags: upstream-1.1.9
ImportĀ upstreamĀ versionĀ 1.1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Xorg: policy.c,v 1.4 2001/02/09 02:05:40 xorgcvs Exp $ */
2
1
/*
3
2
 
4
3
Copyright 1988, 1998  The Open Group
33
32
 *
34
33
 * policy.c.  Implement site-dependent policy for XDMCP connections
35
34
 */
36
 
/* $XFree86: policy.c,v 3.8 2002/12/07 20:31:04 herrb Exp $ */
37
35
 
38
 
# include "dm.h"
39
 
# include "dm_auth.h"
 
36
#include "dm.h"
 
37
#include "dm_auth.h"
40
38
 
41
39
#include <errno.h>
42
40
 
54
52
} XdmAuthRec, *XdmAuthPtr;
55
53
 
56
54
static XdmAuthRec auth[] = {
57
 
#ifdef HASXDMAUTH
 
55
# ifdef HASXDMAUTH
58
56
{ {(CARD16) 20, (CARD8 *) "XDM-AUTHENTICATION-1"},
59
57
  {(CARD16) 19, (CARD8 *) "XDM-AUTHORIZATION-1"},
60
58
},
61
 
#endif
 
59
# endif
62
60
{ {(CARD16) 0, (CARD8 *) 0},
63
61
  {(CARD16) 0, (CARD8 *) 0},
64
62
}
65
63
};
66
64
 
67
 
#define NumAuth (sizeof auth / sizeof auth[0])
 
65
# define NumAuth        (sizeof auth / sizeof auth[0])
68
66
 
69
67
ARRAY8Ptr
70
68
ChooseAuthentication (ARRAYofARRAY8Ptr authenticationNames)
86
84
    ARRAY8Ptr           name,
87
85
    ARRAY8Ptr           data)
88
86
{
89
 
#ifdef HASXDMAUTH
 
87
# ifdef HASXDMAUTH
90
88
    if (name->length && !strncmp ((char *)name->data, "XDM-AUTHENTICATION-1", 20))
91
89
        return XdmCheckAuthentication (pdpy, displayID, name, data);
92
 
#endif
 
90
# endif
93
91
    return TRUE;
94
92
}
95
93
 
129
127
{
130
128
    char        statusBuf[256];
131
129
    int         ret;
132
 
    
 
130
 
133
131
    ret = AcceptableDisplayAddress (addr, connectionType, type);
134
132
    if (!ret)
135
 
        sprintf (statusBuf, "Display not authorized to connect");
 
133
        snprintf (statusBuf, sizeof(statusBuf),
 
134
                  "Display not authorized to connect");
136
135
    else
137
136
    {
138
137
        if (*willing)
146
145
                if (s && strlen(statusBuf) > 0)
147
146
                        statusBuf[strlen(statusBuf)-1] = 0; /* chop newline */
148
147
                else
149
 
                        snprintf (statusBuf, sizeof(statusBuf), "Willing, but %s failed",willing);
 
148
                        snprintf (statusBuf, sizeof(statusBuf),
 
149
                                  "Willing, but %s failed", willing);
150
150
            }
151
151
            else
152
 
                snprintf (statusBuf, sizeof(statusBuf), "Willing, but %s failed",willing);
 
152
                snprintf (statusBuf, sizeof(statusBuf),
 
153
                          "Willing, but %s failed", willing);
153
154
            if (fd) pclose(fd);
154
155
        }
155
156
        else
156
 
            sprintf (statusBuf, "Willing to manage");
 
157
            snprintf (statusBuf, sizeof(statusBuf), "Willing to manage");
157
158
    }
158
159
    status->length = strlen (statusBuf);
159
160
    status->data = (CARD8Ptr) malloc (status->length);
182
183
{
183
184
    int i;
184
185
 
185
 
    /* 
186
 
     * Select one supported connection type 
 
186
    /*
 
187
     * Select one supported connection type
187
188
     */
188
189
 
189
190
    for (i = 0; i < connectionTypes->length; i++) {
190
191
        switch (connectionTypes->data[i]) {
191
192
          case FamilyLocal:
192
 
#if defined(TCPCONN)
 
193
# if defined(TCPCONN)
193
194
          case FamilyInternet:
194
 
#if defined(IPv6) && defined(AF_INET6) 
 
195
#  if defined(IPv6) && defined(AF_INET6)
195
196
          case FamilyInternet6:
196
 
#endif /* IPv6 */
197
 
#endif /* TCPCONN */
198
 
#if defined(DNETCONN)
 
197
#  endif /* IPv6 */
 
198
# endif /* TCPCONN */
 
199
# if defined(DNETCONN)
199
200
          case FamilyDECnet:
200
 
#endif /* DNETCONN */
 
201
# endif /* DNETCONN */
201
202
            return i;
202
203
        }
203
204
    } /* for */