~ubuntu-branches/ubuntu/maverick/xdm/maverick

1 by Fabio M. Di Nitto
Import upstream version 0.99.1
1
/* $Xorg: mitauth.c,v 1.4 2001/02/09 02:05:40 xorgcvs Exp $ */
2
/*
3
4
Copyright 1988, 1998  The Open Group
5
6
Permission to use, copy, modify, distribute, and sell this software and its
7
documentation for any purpose is hereby granted without fee, provided that
8
the above copyright notice appear in all copies and that both that
9
copyright notice and this permission notice appear in supporting
10
documentation.
11
12
The above copyright notice and this permission notice shall be included
13
in all copies or substantial portions of the Software.
14
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
19
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21
OTHER DEALINGS IN THE SOFTWARE.
22
23
Except as contained in this notice, the name of The Open Group shall
24
not be used in advertising or otherwise to promote the sale, use or
25
other dealings in this Software without prior written authorization
26
from The Open Group.
27
28
*/
29
/* $XFree86: xc/programs/xdm/mitauth.c,v 1.5 2003/05/27 22:27:00 tsi Exp $ */
30
31
/*
32
 * xdm - display manager daemon
33
 * Author:  Keith Packard, MIT X Consortium
34
 *
35
 * mitauth
36
 *
37
 * generate authorization keys
38
 * for MIT-MAGIC-COOKIE-1 type authorization
39
 */
40
41
# include   <X11/Xos.h>
42
43
# include   "dm.h"
44
# include   "dm_auth.h"
45
46
# define AUTH_DATA_LEN	16	/* bytes of authorization data */
47
static char	auth_name[256];
48
49
void
50
MitInitAuth (unsigned short name_len, char *name)
51
{
52
    if (name_len > 256)
53
	name_len = 256;
54
    memmove( auth_name, name, name_len);
55
}
56
57
Xauth *
58
MitGetAuth (unsigned short namelen, char *name)
59
{
60
    Xauth   *new;
61
    new = (Xauth *) malloc (sizeof (Xauth));
62
63
    if (!new)
64
	return (Xauth *) 0;
65
    new->family = FamilyWild;
66
    new->address_length = 0;
1.1.4 by Julien Cristau
Import upstream version 1.1.4
67
    new->address = NULL;
1 by Fabio M. Di Nitto
Import upstream version 0.99.1
68
    new->number_length = 0;
1.1.4 by Julien Cristau
Import upstream version 1.1.4
69
    new->number = NULL;
1 by Fabio M. Di Nitto
Import upstream version 0.99.1
70
71
    new->data = (char *) malloc (AUTH_DATA_LEN);
72
    if (!new->data)
73
    {
74
	free ((char *) new);
75
	return (Xauth *) 0;
76
    }
77
    new->name = (char *) malloc (namelen);
78
    if (!new->name)
79
    {
80
	free ((char *) new->data);
81
	free ((char *) new);
82
	return (Xauth *) 0;
83
    }
84
    memmove( (char *)new->name, name, namelen);
85
    new->name_length = namelen;
86
    if (!GenerateAuthData (new->data, AUTH_DATA_LEN))
87
    {
88
	free((char *) new->name);
89
	free((char *) new->data);
90
	free((char *) new);
91
	return (Xauth *) 0;
92
    }
93
    new->data_length = AUTH_DATA_LEN;
94
    return new;
95
}