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