/*
*
* 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>
#include <stdlib.h>
#include <stdarg.h>
#include <errno.h>
#include <netdb.h>
struct display {
};
struct verify_info {
};
struct addrList {
unsigned short family;
unsigned short address_length;
unsigned short number_length;
char * address;
char * number;
};
static const char *programName;
/* PRINTFLIKE1 */
{
}
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 /* DEBUG */
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;
perror("saveAddr");
return;
}
goto fail;
}
}
else
goto fail;
}
}
else
return;
fail:
perror("saveAddr");
return;
}
static void
{
int fd;
}
static void
{
#ifdef DEBUG
printf("--- writeAddr:\n");
#endif
}
static void
{
char * addr;
int n;
int family;
perror("Getting interface count");
}
}
perror("Getting interface list");
return;
}
--n >= 0; ifr++) {
case AF_INET:
/*
* 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;
break;
case AF_INET6:
continue;
break;
default:
continue;
}
}
}
static void
{
else
perror("gethostname");
}
static void
{
const char *colon;
const char *dot;
char *number;
if (colon) {
++colon;
else
if (number) {
}
else {
perror("setAuthNumber");
auth->number_length = 0;
}
}
}
static int
{
int newfd;
if (newfd == -1) {
return 0;
}
return 0;
}
return 1;
}
static void
{
fatalError("Could not write authorization info. for user. exiting");
}
}
static void
doneAddrs(void)
{
struct addrList *a, *n;
n = a->next;
free(a);
}
}
static Xauth *
{
goto fail;
}
goto fail;
}
}
goto fail;
}
goto fail;
}
}
else {
programName, name);
goto fail;
}
goto fail;
}
return new;
fail:
perror("GenerateAuthorization");
}
}
static void
{
int received = 0;
while (needed > 0) {
if (result == -1) {
perror("getrandom");
break;
}
}
else {
}
}
if (needed > 0) { /* fallback if getrandom returns non-retryable error */
int seed;
int i;
}
}
}
static int
{
int auth_fd;
int ret;
if (auth_fd == -1) {
return FALSE;
}
}
else {
}
else {
}
}
return ret;
}
static void
{
if (d->authorization) {
}
return;
/* Change to real user id, before writing any files */
d->authorization = auth;
}
else {
fatalError("Could not write server authorization file. exiting");
}
}
static void
{
char *home;
char *envname;
int lockStatus;
new_name[0] = '\0';
if (home) {
if (lockStatus == LOCK_SUCCESS) {
if (openFiles
}
else {
}
}
}
if (lockStatus != LOCK_SUCCESS) {
int tmpfd;
d->userAuthDir);
if (lockStatus == LOCK_SUCCESS) {
if (openFiles
name = backup_name;
}
else {
}
}
}
if (lockStatus != LOCK_SUCCESS) {
return;
}
if (old) {
}
}
}
doneAddrs();
}
else {
}
if (envname) {
}
}
}
static void
{
}
int
{
struct display d = {
.authorization = NULL,
.authName = "MIT-MAGIC-COOKIE-1"
};
programName = argv[0];
"WARNING: This program will overwrite existing files.\n"
"This may cause your X server to not accept any"
" new client connections.\n");
}
fatalError("Invalid filename: %s\n"
"Filename should include display",
d.authFile);
}
if (argv[3]) {
}
else {
exit(-1);
}
}
else if (argv[2]) {
exit(-1);
}
if (au_name) {
d.authName = "SUN-DES-1";
}
au_name);
exit(-1);
}
}
SetUserAuthorization(&d, &verify);
exit(0);
}