readpassphrase.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/* $OpenBSD: readpassphrase.c,v 1.14 2002/06/28 01:43:58 millert Exp $ */
/*
* Copyright (c) 2000-2002 Todd C. Miller <Todd.Miller@courtesan.com>
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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.
*/
static const char rcsid[] = "$OpenBSD: readpassphrase.c,v 1.14 2002/06/28 01:43:58 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include "includes.h"
#ifndef HAVE_READPASSPHRASE
#include <termios.h>
#include <readpassphrase.h>
#ifdef TCSASOFT
#else
#endif
/* SunOS 4.x which lacks _POSIX_VDISABLE, but has VDISABLE */
#if !defined(_POSIX_VDISABLE) && defined(VDISABLE)
# define _POSIX_VDISABLE VDISABLE
#endif
static volatile sig_atomic_t signo;
static void handler(int);
char *
{
/* I suppose we could alloc on demand in this case (XXX). */
if (bufsiz == 0) {
return(NULL);
}
signo = 0;
/*
* stdin and write to stderr unless a tty is required.
*/
if (flags & RPP_REQUIRE_TTY) {
return(NULL);
}
}
/*
* Catch signals that would otherwise cause the user to end
* up with echo turned off in the shell. Don't worry about
* things like SIGXCPU and SIGVTALRM for now.
*/
/* Turn off echo if possible. */
if (!(flags & RPP_ECHO_ON))
#ifdef VSTATUS
#endif
} else {
}
if (p < end) {
if ((flags & RPP_SEVENBIT))
ch &= 0x7f;
if ((flags & RPP_FORCELOWER))
if ((flags & RPP_FORCEUPPER))
}
*p++ = ch;
}
}
*p = '\0';
save_errno = errno;
/* Restore old terminal settings and signals. */
if (input != STDIN_FILENO)
/*
* If we were interrupted by a signal, resend it to ourselves
* now that we have restored the signal handlers.
*/
if (signo) {
switch (signo) {
case SIGTSTP:
case SIGTTIN:
case SIGTTOU:
goto restart;
}
}
errno = save_errno;
}
#if 0
char *
{
}
#endif
static void handler(int s)
{
signo = s;
}
#endif /* HAVE_READPASSPHRASE */
#pragma ident "%Z%%M% %I% %E% SMI"