read_pwd.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* lib/krb5/os/read_pwd.c
*
* Copyright 1990,1991 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* 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.
*
*
* libos: krb5_read_password for BSD 4.3
*/
#include <k5-int.h>
#define DEFINED_KRB5_READ_PASSWORD
#include <stdio.h>
#include <errno.h>
#include <signal.h>
#include <setjmp.h>
/*
* Solaris kerberos: include this for internationalization
*/
#include <libintl.h>
#ifndef ECHO_PASSWORD
#include <termios.h>
#endif /* ECHO_PASSWORD */
/*ARGSUSED*/
static krb5_sigtype
int signo;
{
/*NOTREACHED*/
}
/*ARGSUSED*/
const char *prompt;
const char *prompt2;
char *return_pwd;
unsigned int *size_return;
{
/* adapted from Kerberos v4 des/read_password.c */
/* readin_string is used after a longjmp, so must be volatile */
char *volatile readin_string = 0;
register char *ptr;
int scratchchar;
krb5_sigtype (*volatile ointrfunc)();
#ifndef ECHO_PASSWORD
int fd;
/* get the file descriptor associated with stdin */
return errno;
return errno;
#endif /* ECHO_PASSWORD */
goto cleanup;
}
/* save intrfunc */
/* put out the prompt */
(void) putchar('\n');
goto cleanup;
}
(void) putchar('\n');
/* fgets always null-terminates the returned string */
/* replace newline with null */
*ptr = '\0';
else /* flush rest of input line */
do {
scratchchar = getchar();
if (prompt2) {
/* put out the prompt */
if (!readin_string) {
goto cleanup;
}
(void) putchar('\n');
goto cleanup;
}
(void) putchar('\n');
*ptr = '\0';
else /* need to flush */
do {
scratchchar = getchar();
/* compare */
goto cleanup;
}
}
errcode = 0;
#ifndef ECHO_PASSWORD
errcode == 0)
return errno;
#endif
if (readin_string) {
}
if (errcode)
else
return errcode;
}
#else /* MSDOS */
#ifndef DEFINED_KRB5_READ_PASSWORD
#define DEFINED_KRB5_READ_PASSWORD
/*
* Don't expect to be called, just define it for sanity and the linker.
*/
const char *prompt;
const char *prompt2;
char *return_pwd;
int *size_return;
{
*size_return = 0;
return KRB5_LIBOS_CANTREADPWD;
}
#endif /* DEFINED_KRB5_READ_PASSWORD */
#endif /* MSDOS */