/*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*/
/*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* based on @(#)auth.c 8.1 (Berkeley) 6/4/93 */
/*
* Copyright (C) 1990 by the Massachusetts Institute of Technology
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, 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. Furthermore if you modify this software you must label
* your software as modified software and not distribute it in such a
* fashion that it might be confused with the original M.I.T. software.
* 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.
*/
#include <stdio.h>
#include <signal.h>
#ifdef __STDC__
#include <stdlib.h>
#endif
#include <string.h>
#include "externs.h"
#include "encrypt.h"
#include "auth.h"
static int auth_send_cnt = 0;
/*
* Authentication types supported. Note that these are stored
* in priority order, i.e. try the first one first.
*/
{ 0, },
};
/*
* Traverse the Authenticator array until we find the authentication type
* and matching direction we are looking for. Return a pointer into the
* Authenticator type array.
*
* Returns: 0 - type not found (error)
* nonzero - pointer to authenticator
*/
static Authenticator *
{
++ap;
}
/*
* For each authentication type in the Authenticator array,
* call the associated init routine, and update the i_support bitfield.
*/
void
{
i_support = 0;
if (auth_debug_mode)
(">>>%s: I support auth type %d %d\r\n"),
}
++ap;
}
}
/*
* Search the Authenticator array for the authentication type 'name',
* and disable this type by updating the i_wont_support bitfield.
*/
void
{
uint_t x;
for (x = 0; x < AUTHTYPE_CNT; ++x) {
i_wont_support |= typemask(x);
break;
}
}
if (!i_wont_support)
(void) printf(
gettext("%s : invalid authentication type\n"),
name);
}
/*
* Search the Authenticator array for the authentication type given
* by the character string 'type', and return its integer bitmask
* in maskp.
*
* Returns: 1 - no error
* 0 - type not found (error)
*/
static int
{
uint_t x;
return (1);
}
for (x = 1; x < AUTHTYPE_CNT; ++x) {
return (1);
}
}
return (0);
}
int
{
}
int
{
}
/*
* Responds to the 'auth enable <option>' and 'auth disable <option>' commands.
*
* If <option> is:
* - a valid authentication type, turns support on / off
* - "?" or "help", print a usage message
* - not recognized, print an error message.
*
* Returns: 1 - no error, authentication is enabled or disabled
* 0 - error, or help requested
*/
static int
{
gettext("auth enable 'type'\n") :
gettext("auth disable 'type'\n"));
(void) printf(
gettext("Where 'type' is one of:\n"));
continue;
mask |= i;
}
return (0);
}
(void) printf(
return (0);
}
if (on)
i_wont_support &= ~mask;
else
i_wont_support |= mask;
return (1);
}
/*
* Responds to the 'toggle authdebug' command.
*
* Returns: 1 - always
*/
int
{
if (on < 0)
else
(void) printf(auth_debug_mode ?
gettext("auth debugging enabled\n") :
gettext("auth debugging disabled\n"));
return (1);
}
/*
* Responds to the 'auth status' command.
* Traverses the authenticator array and prints enabled or disabled for
* each authentication type, depencing on the i_wont_support bitfield.
*
* Returns: 1 - always
*/
int
auth_status(void)
{
else
mask = 0;
continue;
mask |= i;
}
return (1);
}
/*
* This is called when an AUTH SEND is received.
* data is a list of authentication mechanisms we support
*/
void
{
if (auth_debug_mode) {
(void) printf("\r\n");
}
/*
* Save the list of authentication mechanisms
*/
auth_send_cnt = cnt;
if (auth_send_cnt > sizeof (_auth_send_data))
auth_send_cnt = sizeof (_auth_send_data);
}
/*
* Try the next authentication mechanism on the list, and see if it
* works.
*/
void
auth_send_retry(void)
{
if (auth_debug_mode)
(void) printf(
gettext(">>>%s: Remote host supports %d\r\n"),
Name, *auth_send_data);
continue;
continue;
continue;
continue;
if (auth_debug_mode)
(void) printf(
/*
* Okay, we found one we like and did it. we can go
* home now.
*/
if (auth_debug_mode)
Name, *auth_send_data);
auth_send_data += 2;
return;
}
}
if (auth_debug_mode)
(void) printf(
auth_finished(0, AUTH_REJECT);
}
void
{
if (cnt < 2)
return;
} else if (auth_debug_mode)
(">>>%s: Invalid authentication in SEND: %d\r\n"),
}
int
{
while (--len >= 0) {
*e++ = IAC;
if (e >= ee)
return (0);
}
*e++ = IAC;
*e++ = SE;
return (1);
}
/* ARGSUSED */
void
{
authenticated = ap;
if (authenticated == NULL)
authenticated = &NoAuth;
}
void
{
else
}
static void
{
if (buflen < 2)
return;
data += 3;
buflen -= 2;
if (buflen == 0)
return;
}
*buf = '\0';
}