~ubuntu-branches/ubuntu/trusty/xdm/trusty

« back to all changes in this revision

Viewing changes to xdm/protodpy.c

  • Committer: Package Import Robot
  • Author(s): Micah Gersten
  • Date: 2011-12-09 03:00:26 UTC
  • mfrom: (9.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20111209030026-baa9vul2hhtujjxh
Tags: 1:1.1.11-1ubuntu1
* Merge from Debian testing.  Remaining changes:
  - debian/{rules, xdm.install, local/ubuntu*}:
    + Add Ubuntu graphics and configure xdm to use them by default.
  - debian/patches/ubuntu_no_whiteglass.diff: Don't hardcode
    the default Xcursor theme to whiteglass. Use the Ubuntu
    default x-cursor-theme instead.

* Drop debian/patches/ftbfs_binutils-gold.diff: Fixed upstream
* Change Vcs-* to XS-Debian-Vcs-*
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *
 
3
Copyright 1989, 1998  The Open Group
 
4
 
 
5
Permission to use, copy, modify, distribute, and sell this software and its
 
6
documentation for any purpose is hereby granted without fee, provided that
 
7
the above copyright notice appear in all copies and that both that
 
8
copyright notice and this permission notice appear in supporting
 
9
documentation.
 
10
 
 
11
The above copyright notice and this permission notice shall be included in
 
12
all copies or substantial portions of the Software.
 
13
 
 
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
15
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
16
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
17
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
18
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
19
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
20
 
 
21
Except as contained in this notice, the name of The Open Group shall not be
 
22
used in advertising or otherwise to promote the sale, use or other dealings
 
23
in this Software without prior written authorization from The Open Group.
 
24
 *
 
25
 * Author:  Keith Packard, MIT X Consortium
 
26
 */
 
27
 
 
28
/*
 
29
 * protodpy.c
 
30
 *
 
31
 * manage a collection of proto-displays.  These are displays for
 
32
 * which sessionID's have been generated, but no session has been
 
33
 * started.
 
34
 */
 
35
 
 
36
#include "dm.h"
 
37
#include "dm_error.h"
 
38
 
 
39
#ifdef XDMCP
 
40
 
 
41
# include <sys/types.h>
 
42
# include <time.h>
 
43
# define Time_t time_t
 
44
 
 
45
static struct protoDisplay      *protoDisplays;
 
46
 
 
47
# ifdef DEBUG
 
48
static
 
49
PrintProtoDisplay (struct protoDisplay *pdpy)
 
50
{
 
51
    Debug ("ProtoDisplay 0x%x\n", pdpy);
 
52
    Debug ("\taddress: ");
 
53
    PrintSockAddr (pdpy->address, pdpy->addrlen);
 
54
    Debug ("\tdate %d (%d from now)\n", pdpy->date, time(0) - pdpy->date);
 
55
    Debug ("\tdisplay Number %d\n", pdpy->displayNumber);
 
56
    Debug ("\tsessionID %d\n", pdpy->sessionID);
 
57
}
 
58
# endif
 
59
 
 
60
struct protoDisplay *
 
61
FindProtoDisplay (
 
62
    XdmcpNetaddr    address,
 
63
    int             addrlen,
 
64
    CARD16          displayNumber)
 
65
{
 
66
    struct protoDisplay *pdpy;
 
67
 
 
68
    Debug ("FindProtoDisplay\n");
 
69
    for (pdpy = protoDisplays; pdpy; pdpy=pdpy->next)
 
70
    {
 
71
        if (pdpy->displayNumber == displayNumber &&
 
72
            addressEqual (address, addrlen, pdpy->address, pdpy->addrlen))
 
73
        {
 
74
            return pdpy;
 
75
        }
 
76
    }
 
77
    return (struct protoDisplay *) 0;
 
78
}
 
79
 
 
80
static void
 
81
TimeoutProtoDisplays (Time_t now)
 
82
{
 
83
    struct protoDisplay *pdpy, *next;
 
84
 
 
85
    for (pdpy = protoDisplays; pdpy; pdpy = next)
 
86
    {
 
87
        next = pdpy->next;
 
88
        if (pdpy->date < now - PROTO_TIMEOUT)
 
89
            DisposeProtoDisplay (pdpy);
 
90
    }
 
91
}
 
92
 
 
93
struct protoDisplay *
 
94
NewProtoDisplay (
 
95
    XdmcpNetaddr    address,
 
96
    int             addrlen,
 
97
    CARD16          displayNumber,
 
98
    CARD16          connectionType,
 
99
    ARRAY8Ptr       connectionAddress,
 
100
    CARD32          sessionID)
 
101
{
 
102
    struct protoDisplay *pdpy;
 
103
    Time_t date;
 
104
 
 
105
    Debug ("NewProtoDisplay\n");
 
106
    time (&date);
 
107
    TimeoutProtoDisplays (date);
 
108
    pdpy = malloc (sizeof *pdpy);
 
109
    if (!pdpy)
 
110
        return NULL;
 
111
    pdpy->address = malloc (addrlen);
 
112
    if (!pdpy->address)
 
113
    {
 
114
        free (pdpy);
 
115
        return NULL;
 
116
    }
 
117
    pdpy->addrlen = addrlen;
 
118
    memmove( pdpy->address, address, addrlen);
 
119
    pdpy->displayNumber = displayNumber;
 
120
    pdpy->connectionType = connectionType;
 
121
    pdpy->date = date;
 
122
    if (!XdmcpCopyARRAY8 (connectionAddress, &pdpy->connectionAddress))
 
123
    {
 
124
        free (pdpy->address);
 
125
        free (pdpy);
 
126
        return NULL;
 
127
    }
 
128
    pdpy->sessionID = sessionID;
 
129
    pdpy->fileAuthorization = (Xauth *) NULL;
 
130
    pdpy->xdmcpAuthorization = (Xauth *) NULL;
 
131
    pdpy->next = protoDisplays;
 
132
    protoDisplays = pdpy;
 
133
    return pdpy;
 
134
}
 
135
 
 
136
void
 
137
DisposeProtoDisplay (struct protoDisplay *pdpy)
 
138
{
 
139
    struct protoDisplay *p, *prev;
 
140
 
 
141
    prev = NULL;
 
142
    for (p = protoDisplays; p; p=p->next)
 
143
    {
 
144
        if (p == pdpy)
 
145
            break;
 
146
        prev = p;
 
147
    }
 
148
    if (!p)
 
149
        return;
 
150
    if (prev)
 
151
        prev->next = pdpy->next;
 
152
    else
 
153
        protoDisplays = pdpy->next;
 
154
    bzero(&pdpy->key, sizeof(pdpy->key));
 
155
    if (pdpy->fileAuthorization)
 
156
        XauDisposeAuth (pdpy->fileAuthorization);
 
157
    if (pdpy->xdmcpAuthorization)
 
158
        XauDisposeAuth (pdpy->xdmcpAuthorization);
 
159
    XdmcpDisposeARRAY8 (&pdpy->connectionAddress);
 
160
    free (pdpy->address);
 
161
    free (pdpy);
 
162
}
 
163
 
 
164
#endif /* XDMCP */