summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2004-08-15 10:28:45 +0000
committerSimon Josefsson <simon@josefsson.org>2004-08-15 10:28:45 +0000
commitd30a9c7494351bb538acbecb13cddcaefbbe2f45 (patch)
treef84af7482d7bad396d7d3f091d35ebdb197f5d82 /src
parentecf58cb15a0e3c7ff410d4517395256ba9e50d1a (diff)
downloadgnutls-d30a9c7494351bb538acbecb13cddcaefbbe2f45.tar.gz
Replace ad-hoc 'read_pass' with gnulib module 'getpass-gnu'.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am10
-rw-r--r--src/certtool-cfg.c7
-rw-r--r--src/certtool.c1
-rw-r--r--src/crypt.c7
-rw-r--r--src/getpass.c52
-rw-r--r--src/getpass.h1
6 files changed, 15 insertions, 63 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 3ce2b7469c..620429914d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,7 @@
EXTRA_DIST = common.h crypt.gaa crypt-gaa.h README.srptool \
README cli.gaa cli-gaa.h serv-gaa.h serv.gaa tls_test.gaa \
tls_test-gaa.h tests.h gnutls-http-serv list.h certtool-gaa.h \
- certtool.gaa getpass.h certtool-cfg.h
+ certtool.gaa certtool-cfg.h
SUBDIRS = srp x509 openpgp cfg
@@ -11,8 +11,8 @@ INCLUDES = -I../lib -I../libtasn1/lib -I../includes $(LIBOPENCDK_CFLAGS) \
bin_PROGRAMS = gnutls-serv gnutls-cli srptool gnutls-cli-debug certtool
gnutls_serv_SOURCES = serv-gaa.c serv.c common.c
gnutls_serv_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la $(LIBGCRYPT_LIBS) $(LIBTASN1_LIBS) $(LIBOPENCDK_LIBS) $(SERV_LIBS)
-srptool_SOURCES = crypt-gaa.c crypt.c getpass.c
-srptool_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la $(LIBGCRYPT_LIBS) $(LIBTASN1_LIBS) $(LIBOPENCDK_LIBS)
+srptool_SOURCES = crypt-gaa.c crypt.c
+srptool_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la $(LIBGCRYPT_LIBS) $(LIBTASN1_LIBS) $(LIBOPENCDK_LIBS) ../gl/libgnu.la
gnutls_cli_SOURCES = cli-gaa.c cli.c common.c
gnutls_cli_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la $(LIBGCRYPT_LIBS) $(LIBTASN1_LIBS) $(LIBOPENCDK_LIBS) $(SERV_LIBS)
gnutls_cli_debug_SOURCES = tls_test-gaa.c tls_test.c tests.c common.c
@@ -24,11 +24,11 @@ errcodes_SOURCES = errcodes.c
errcodes_LDADD = ../lib/libgnutls.la $(LIBGCRYPT_LIBS) $(LIBTASN1_LIBS)
if HAVE_LIBCFG
-certtool_SOURCES = certtool-gaa.c certtool.c prime.c getpass.c certtool-cfg.c
+certtool_SOURCES = certtool-gaa.c certtool.c prime.c certtool-cfg.c
certtool_LDADD = ../lib/libgnutls.la $(LIBGCRYPT_LIBS) $(LIBTASN1_LIBS) -lcfg+ \
../gl/libgnu.la
else
-certtool_SOURCES = certtool-gaa.c certtool.c prime.c getpass.c certtool-cfg.c \
+certtool_SOURCES = certtool-gaa.c certtool.c prime.c certtool-cfg.c \
cfg/cfg+.c cfg/cfgfile.c cfg/cmdline.c cfg/parse.c cfg/props.c \
cfg/shared.c cfg/platon/str/dynfgets.c cfg/platon/str/strctype.c \
cfg/platon/str/strdyn.c cfg/platon/str/strplus.c
diff --git a/src/certtool-cfg.c b/src/certtool-cfg.c
index 8dc61858c0..8303502212 100644
--- a/src/certtool-cfg.c
+++ b/src/certtool-cfg.c
@@ -30,6 +30,9 @@
#include <gnutls/x509.h>
#include <string.h>
+/* Gnulib portability files. */
+#include <getpass.h>
+
extern int batch;
typedef struct _cfg_ctx {
@@ -255,7 +258,7 @@ const char *get_pass(void)
if (batch)
return cfg.password;
else
- return read_pass("Enter password: ");
+ return getpass("Enter password: ");
}
const char *get_challenge_pass(void)
@@ -263,7 +266,7 @@ const char *get_challenge_pass(void)
if (batch)
return cfg.challenge_password;
else
- return read_pass("Enter a challenge password: ");
+ return getpass("Enter a challenge password: ");
}
const char *get_crl_dist_point_url(void)
diff --git a/src/certtool.c b/src/certtool.c
index bb44487540..cf09a2e536 100644
--- a/src/certtool.c
+++ b/src/certtool.c
@@ -33,7 +33,6 @@
#include "certtool-gaa.h"
#include <gnutls/pkcs12.h>
#include <unistd.h>
-#include <getpass.h>
#include <certtool-cfg.h>
/* Gnulib portability files. */
diff --git a/src/crypt.c b/src/crypt.c
index b3f7a7cce1..1fa5b8573b 100644
--- a/src/crypt.c
+++ b/src/crypt.c
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2004 Simon Josefsson
* Copyright (C) 2001,2003 Nikos Mavroyanopoulos
* Copyright (C) 2004 Free Software Foundation
*
@@ -40,7 +41,6 @@ int main(int argc, char **argv)
#include <gnutls/extra.h>
#include <gcrypt.h> /* for randomize */
#include <crypt-gaa.h>
-#include <getpass.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -52,6 +52,9 @@ int main(int argc, char **argv)
# include <windows.h>
#endif
+/* Gnulib portability files. */
+#include <getpass.h>
+
#define _MAX(x,y) (x>y?x:y)
/* This may need some rewrite. A lot of stuff which should be here
@@ -409,7 +412,7 @@ int main(int argc, char **argv)
salt = 16;
- passwd = read_pass("Enter password: ");
+ passwd = getpass("Enter password: ");
/* not ready yet */
if (info.verify != 0) {
diff --git a/src/getpass.c b/src/getpass.c
deleted file mode 100644
index 1a73b7ae0a..0000000000
--- a/src/getpass.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <config.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#ifndef _WIN32
-# include <termios.h>
-# include <unistd.h>
-#endif
-
-#define OUT_STREAM stdout
-
-const char *read_pass(const char *msg)
-{
-#ifndef _WIN32
- struct termios old, new;
-#endif
- static char input[128];
- char *p;
-
- fputs(msg, stderr);
-
-#ifndef _WIN32
- /* Turn echoing off and fail if we can't. */
- if (tcgetattr(fileno(OUT_STREAM), &old) != 0) {
- perror("tcgetattr");
- exit(1);
- }
-
- new = old;
- new.c_lflag &= ~ECHO;
- if (tcsetattr(fileno(OUT_STREAM), TCSAFLUSH, &new) != 0) {
- perror("tcsetattr");
- exit(1);
- }
-#endif
-
- /* Read the password. */
- p = fgets(input, sizeof(input), stdin);
-
-#ifndef _WIN32
- /* Restore terminal. */
- (void) tcsetattr(fileno(OUT_STREAM), TCSAFLUSH, &old);
-#endif
-
- if (p == NULL || strlen(p) == 0 || p[0] == '\n')
- return NULL;
-
- /* overwrite the newline */
- input[strlen(p) - 1] = 0;
-
- return p;
-}
diff --git a/src/getpass.h b/src/getpass.h
deleted file mode 100644
index d044cd5af5..0000000000
--- a/src/getpass.h
+++ /dev/null
@@ -1 +0,0 @@
-const char* read_pass (const char *msg);