Module Name:    src
Committed By:   christos
Date:           Fri Apr 13 23:57:08 UTC 2012

Modified Files:
        src/crypto/external/bsd/openssh/dist: readpassphrase.c

Log Message:
use getpassfd()


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
    src/crypto/external/bsd/openssh/dist/readpassphrase.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/crypto/external/bsd/openssh/dist/readpassphrase.c
diff -u src/crypto/external/bsd/openssh/dist/readpassphrase.c:1.1 src/crypto/external/bsd/openssh/dist/readpassphrase.c:1.2
--- src/crypto/external/bsd/openssh/dist/readpassphrase.c:1.1	Sun Jun  7 18:38:47 2009
+++ src/crypto/external/bsd/openssh/dist/readpassphrase.c	Fri Apr 13 19:57:08 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: readpassphrase.c,v 1.1 2009/06/07 22:38:47 christos Exp $	*/
+/*	$NetBSD: readpassphrase.c,v 1.2 2012/04/13 23:57:08 christos Exp $	*/
 /*
  * Copyright (c) 2000 Todd C. Miller <todd.mil...@courtesan.com>
  * All rights reserved.
@@ -43,16 +43,14 @@ static const char rcsid[] = "$OpenBSD: r
 #include <readpassphrase.h>
 
 char *
-readpassphrase(prompt, buf, bufsiz, flags)
-	const char *prompt;
-	char *buf;
-	size_t bufsiz;
-	int flags;
+readpassphrase(
+	const char *prompt,
+	char *buf,
+	size_t bufsiz,
+	int flags)
 {
-	struct termios term, oterm;
-	char ch, *p, *end;
 	int input, output;
-	sigset_t oset, nset;
+	char *ret;
 
 	/* I suppose we could alloc on demand in this case (XXX). */
 	if (bufsiz == 0) {
@@ -73,6 +71,11 @@ readpassphrase(prompt, buf, bufsiz, flag
 		output = STDERR_FILENO;
 	}
 
+#ifndef GETPASS_ECHO
+	struct termios term, oterm;
+	char ch, *p, *end;
+	sigset_t oset, nset;
+
 	/*
 	 * We block SIGINT and SIGTSTP so the terminal is not left
 	 * in an inconsistent state (ie: no echo).  It would probably
@@ -119,9 +122,33 @@ readpassphrase(prompt, buf, bufsiz, flag
 	if (memcmp(&term, &oterm, sizeof(term)) != 0)
 		(void)tcsetattr(input, TCSAFLUSH|TCSASOFT, &oterm);
 	(void)sigprocmask(SIG_SETMASK, &oset, NULL);
+	ret = buf;
+#else
+	int gflags = 0;
+	int fd[3];
+
+	if (flags & RPP_ECHO_ON)
+		gflags |= GETPASS_ECHO;
+	if (flags & RPP_REQUIRE_TTY)
+		gflags |= GETPASS_NEED_TTY;
+	if (flags & RPP_FORCELOWER)
+		gflags |= GETPASS_FORCE_LOWER;
+	if (flags & RPP_FORCEUPPER)
+		gflags |= GETPASS_FORCE_UPPER;
+	if (flags & RPP_SEVENBIT)
+		gflags |= GETPASS_7BIT;
+
+	fd[0] = input;
+	fd[1] = fd[2] = output;
+	ret = getpassfd(prompt, buf, bufsiz, fd, gflags, 0);
+	if ((gflags & GETPASS_ECHO) == 0)
+		(void)write(output, "\n", 1);
+
+#endif
 	if (input != STDIN_FILENO)
 		(void)close(input);
-	return(buf);
+	
+	return ret;
 }
 
 char *

Reply via email to