]> andersk Git - openssh.git/blobdiff - cli.c
missed sshconnect.c part of:
[openssh.git] / cli.c
diff --git a/cli.c b/cli.c
index 27d0d9e18cbc861b48ab746f24bad94527f7e334..52bb34aa01eaad78530a123c392709e6e0999ebc 100644 (file)
--- a/cli.c
+++ b/cli.c
@@ -1,8 +1,9 @@
 #include "includes.h"
-RCSID("$OpenBSD: cli.c,v 1.2 2000/10/16 09:38:44 djm Exp $");
+RCSID("$OpenBSD: cli.c,v 1.9 2001/02/10 12:44:02 markus Exp $");
 
 #include "xmalloc.h"
-#include "ssh.h"
+#include "log.h"
+#include "cli.h"
 
 static int cli_input = -1;
 static int cli_output = -1;
@@ -31,7 +32,7 @@ cli_open(int from_stdin)
                cli_input = STDIN_FILENO;
                cli_output = STDERR_FILENO;
        } else {
-               cli_input = cli_output = open("/dev/tty", O_RDWR);
+               cli_input = cli_output = open(_PATH_TTY, O_RDWR);
                if (cli_input < 0)
                        fatal("You have no controlling tty.  Cannot read passphrase.");
        }
@@ -42,7 +43,7 @@ cli_open(int from_stdin)
 }
 
 static void
-cli_close()
+cli_close(void)
 {
        if (!cli_from_stdin && cli_input >= 0)
                close(cli_input);
@@ -53,13 +54,13 @@ cli_close()
 }
 
 void
-intrcatch()
+intrcatch(int sig)
 {
        intr = 1;
 }
 
 static void
-cli_echo_disable()
+cli_echo_disable(void)
 {
        sigemptyset(&nset);
        sigaddset(&nset, SIGTSTP);
@@ -82,7 +83,7 @@ cli_echo_disable()
 }
 
 static void
-cli_echo_restore()
+cli_echo_restore(void)
 {
        if (echo_modified != 0) {
                tcsetattr(cli_input, TCSANOW, &otio);
@@ -129,25 +130,28 @@ cli_read(char* buf, int size, int echo)
 }
 
 static int
-cli_write(char* buf, int size)
+cli_write(const char* buf, int size)
 {
        int i, len, pos, ret = 0;
        char *output, *p;
 
        output = xmalloc(4*size);
        for (p = output, i = 0; i < size; i++) {
-                if (buf[i] == '\n')
-                        *p++ = buf[i];
-                else
-                        p = vis(p, buf[i], 0, 0);
-        }
+               if (buf[i] == '\n' || buf[i] == '\r')
+                       *p++ = buf[i];
+               else
+                       p = vis(p, buf[i], 0, 0);
+       }
        len = p - output;
 
        for (pos = 0; pos < len; pos += ret) {
                ret = write(cli_output, output + pos, len - pos);
-               if (ret == -1)
+               if (ret == -1) {
+                       xfree(output);
                        return -1;
+               }
        }
+       xfree(output);
        return 0;
 }
 
@@ -158,7 +162,7 @@ cli_write(char* buf, int size)
  * buffer is storing the response.
  */
 char*
-cli_read_passphrase(char* prompt, int from_stdin, int echo_enable)
+cli_read_passphrase(const char* prompt, int from_stdin, int echo_enable)
 {
        char    buf[BUFSIZ];
        char*   p;
This page took 0.038855 seconds and 4 git commands to generate.