/*
*
* mkcookie.c 1.x
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
*
*/
/*
* $XConsortium: auth.c,v 1.17 89/12/14 09:42:18 rws Exp $
*
* Copyright 1988 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* Author: Keith Packard, MIT X Consortium
*/
#include <stdio.h>
#ifdef SYSV
#ifndef bcopy
#endif
#ifndef bzero
#endif
#ifndef bcmp
#endif
#ifndef index
#endif
#ifndef rindex
#endif
#endif
/* 1191081: SIGSEGV when starting openwin - core dumped by mkcookie.
* becuase d.userAuthDir is not assigned any valid directory where
* every one will have access to it.
*/
#include <stdlib.h>
#define Foreign 0
typedef struct displayType {
} DisplayType;
struct display {
int peerlen;
};
struct verify_info {
};
struct AuthProtocol {
int name_length;
const char *name;
void (*InitAuth)(unsigned short, const char *);
int (*GetXdmcpAuth)();
int inited;
};
struct addrList {
unsigned short family;
unsigned short address_length;
char *address;
unsigned short number_length;
char *number;
};
static int auth_name_len;
{ (int) 18, "MIT-MAGIC-COOKIE-1",
},
{ (int) 9, "SUN-DES-1",
}
};
static char *
{
char *result;
if (!result) {
perror ("makeEnv");
return 0;
}
return result;
}
static char **
setEnv (char **e,
const char *name,
const char *value)
{
char *newe;
int envsize;
int l;
if (!newe) {
perror ("setEnv");
return e;
}
if (e) {
break;
if (*old) {
return e;
}
(unsigned) ((envsize + 2) * sizeof (char *)));
} else {
envsize = 0;
}
if (!new) {
perror ("setEnv");
return e;
}
return new;
}
static int
{
while (len-- > 0)
if (*a++ != *b++)
return 0;
return 1;
}
#ifdef DEBUG
static void
{
int i;
for (i = 0; i < len; i++)
printf ("\n");
}
static void
{
printf ("addr: ");
printf ("number: ");
printf ("name: ");
printf ("data: ");
}
#endif
static int
unsigned short address_length, const char *address,
unsigned short number_length, const char *number)
{
struct addrList *a;
a->address_length == address_length &&
a->number_length == number_length &&
{
return 1;
}
}
return 0;
}
static void
unsigned short address_length, const char *address,
unsigned short number_length, const char *number)
{
return;
if (!new) {
perror ("saveAddr");
return;
}
perror ("saveAddr");
return;
}
} else
perror ("saveAddr");
return;
}
} else
}
static void
char *name)
{
int fd;
#ifdef TCPCONN
#ifdef IPv6
#else
#endif
#endif
#ifdef NOTDEF /* DNETCONN */
#endif
}
static void
int family,
int addr_length,
char *addr,
{
}
static int
int s,
int cmd,
char *arg)
{
int ret;
if (cmd == SIOCGIFCONF) {
/* ioc.ic_len = ((struct ifconf *) arg)->ifc_len; */
/* For jup_alpha3, it wants a smaller size in the length field, uncomment above
line and delete the next line once that is fixed. Should not give EINVAL */
} else {
}
return(ret);
}
#endif /* SYSV && TCPCONN */
static void
int fd,
{
register int n;
int len;
char *addr;
int family;
#ifdef SIOCGLIFCONF
#ifdef SIOCGLIFNUM
#endif
#else
#endif
#if defined(SIOCGLIFNUM) && defined(SIOCGLIFCONF)
ifn.lifn_flags = 0;
perror ("Getting interface count");
}
#endif
#ifdef SIOCGLIFCONF
ifc.lifc_flags = 0;
return;
--n >= 0; ifr++)
{
{
&addr);
#else
#else
#endif /* SYSV && TCPCONN */
ifr++)
{
#ifdef NOTDEF /* DNETCONN */
/*
* this is ugly but SIOCGIFCONF returns decnet addresses in
* a different form from other decnet calls
*/
} else
#endif
{
#endif
if (family <= 0)
continue;
/*
* If we get back a 0.0.0.0 IP address, ignore this entry. This
* typically happens when a machine is in a standalone mode.
*/
continue;
#ifdef IPv6
continue;
else
} else
#endif
}
}
}
static void
{
/* stolen from xinit.c */
#ifdef hpux
/* Why not use gethostname()? Well, at least on my system, I've had to
* make an ugly kernel patch to get a name longer than 8 characters, and
* uname() lets me access to the whole string (it smashes release, you
* see), whereas gethostname() kindly truncates it for me.
*/
{
}
#else
#endif
}
static int
int *len,
char **addr)
{
if (len == 0)
return (0);
{
case AF_UNSPEC:
#ifndef hpux
case AF_UNIX:
#endif
return (0);
#ifdef TCPCONN
case AF_INET:
return (AF_INET);
#ifdef IPv6
case AF_INET6:
return (AF_INET6);
#endif
#endif
#ifdef NOTDEF /* DNETCONN */
case AF_DECnet:
return (AF_DECnet);
#endif
default:
break;
}
return (-1);
}
static void
char *name)
{
char *colon;
if (colon) {
++colon;
else
if (number) {
} else {
perror ("setAuthNumber");
auth->number_length = 0;
}
}
}
static int
{
int mask;
if (!*newp) {
return 0;
}
return 1;
}
static void
{
exit(-1);
}
}
static void
doneAddrs (void)
{
struct addrList *a, *n;
for (a = addrs; a; a = n) {
n = a->next;
if (a->address)
if (a->number)
free ((char *) a);
}
}
static void
InitAuth (
unsigned short name_len,
const char *name)
{
if (name_len > 256)
name_len = 256;
}
}
static Xauth *
GetAuth (
int namelen,
const char *name)
{
if (!new)
return (Xauth *) 0;
new->address_length = 0;
new->number_length = 0;
else
{
return (Xauth *) 0;
}
{
return (Xauth *) 0;
}
} else {
perror("user2netname");
}
return new;
}
static void
char *auth,
int len)
{
int seed;
int value;
int i, t;
int fd;
{
for (i = 0; i < (len - 1); i++)
{
}
} else {
for (i = 0; i < (len - 1); i++)
{
auth[i] = (
( (t & 0xff000000) >> 24) ^
( (t & 0xff0000) >> 16) ^
( (t & 0xff00) >> 8) ^
( (t & 0xff) )
) & 0xff;
}
}
}
static int
char *authFile,
{
int mask;
int ret;
if (!auth_file) {
}
else
{
{
}
else
}
return ret;
}
static struct AuthProtocol *
int name_length,
const char *name)
{
int i;
for (i = 0; i < NUM_AUTHORIZATION; i++)
{
return &AuthProtocols[i];
}
return (struct AuthProtocol *) 0;
}
static Xauth *
const char *name,
int name_length)
{
struct AuthProtocol *a;
if (a)
{
if (!a->inited)
{
}
}
return auth;
}
static void
struct display *d)
{
if (d->authorization)
{
XauDisposeAuth (d->authorization);
}
if (d->authName && !d->authNameLen)
if (!auth)
return;
/* Change to real user id, before writing any files */
d->authorization = auth;
else {
exit(-1);
}
}
static void
struct display *d,
struct verify_info *verify)
{
char *name;
char *home;
char *envname = 0;
int lockStatus;
int setenv;
if ((auth = d->authorization)) {
if (home) {
if (lockStatus == LOCK_SUCCESS) {
setenv = 0;
} else {
}
}
}
if (lockStatus != LOCK_SUCCESS) {
if (lockStatus == LOCK_SUCCESS) {
name = backup_name;
setenv = 1;
} else {
}
}
}
if (lockStatus != LOCK_SUCCESS) {
return;
}
addrs = 0;
if (old) {
{
}
}
}
doneAddrs ();
setenv = 1;
} else {
}
if (setenv) {
"XAUTHORITY", envname);
"XAUTHORITY", envname);
}
if (envname)
}
}
static void
{
}
int
{
struct display d;
char *au_name;
if (argc < 2) {
exit(-1);
}
d.authFile);
exit(-1);
}
d.authorization = NULL;
/* 1191081: SIGSEGV when starting openwin - core dumped by mkcookie.
* becuase d.userAuthDir is not assigned any valid directory where
* every one will have access to it.
*/
d.authName = "MIT-MAGIC-COOKIE-1";
if (argv[3])
else {
exit(-1);
}
} else if (argv[2]) {
exit(-1);
}
if (au_name) {
d.authName = "SUN-DES-1";
exit(-1);
}
}
d.peer = 0;
d.peerlen = 0;
SetUserAuthorization(&d, &verify);
exit(0);
}